* Umezawa's Jitte - Fixed that combat damage triggered ability triggered wrongly multiple times, if damage of equipped create was dealt to different creatures.

This commit is contained in:
LevelX2 2014-06-23 01:29:21 +02:00
parent 69970258ac
commit 4e06f60f76
2 changed files with 15 additions and 5 deletions

View file

@ -48,6 +48,7 @@ import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
import mage.game.events.GameEvent.EventType;
/**
* @author Loki
@ -90,12 +91,16 @@ public class UmezawasJitte extends CardImpl {
class UmezawasJitteAbility extends TriggeredAbilityImpl {
private boolean usedInPhase;
public UmezawasJitteAbility() {
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.CHARGE.createInstance(2)));
this.usedInPhase = false;
}
public UmezawasJitteAbility(final UmezawasJitteAbility ability) {
super(ability);
this.usedInPhase = ability.usedInPhase;
}
@Override
@ -107,15 +112,19 @@ class UmezawasJitteAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event instanceof DamagedEvent) {
Permanent p = game.getPermanent(event.getSourceId());
if (((DamagedEvent) event).isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
if (!usedInPhase && ((DamagedEvent) event).isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
usedInPhase = true;
return true;
}
}
if (event.getType().equals(EventType.COMBAT_DAMAGE_STEP_PRE)) {
usedInPhase = false;
}
return false;
}
@Override
public String getRule() {
return "Whenever equipped creature deals combat damage, put two charge counters on {this}.";
return "Whenever equipped creature deals combat damage, " + super.getRule();
}
}

View file

@ -42,8 +42,8 @@ import mage.util.CardUtil;
*/
public class RemoveCountersSourceCost extends CostImpl {
private int amount;
private String name;
private final int amount;
private final String name;
public RemoveCountersSourceCost(Counter counter) {
this.amount = counter.getCount();
@ -63,8 +63,9 @@ public class RemoveCountersSourceCost extends CostImpl {
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
Permanent permanent = game.getPermanent(sourceId);
if (permanent.getCounters().getCount(name) >= amount)
if (permanent.getCounters().getCount(name) >= amount) {
return true;
}
return false;
}