Fixed a bug of SpellCastOpponentTriggeredAbility and changed FilterCard to FilterSpell.

This commit is contained in:
LevelX2 2013-09-11 17:38:09 +02:00
parent eff2572ee5
commit ff1b2ceb72
6 changed files with 25 additions and 21 deletions

View file

@ -107,8 +107,9 @@ class ReciprocateTarget<T extends TargetCreaturePermanent<T>> extends TargetPerm
@Override @Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int remainingTargets = this.minNumberOfTargets - targets.size(); int remainingTargets = this.minNumberOfTargets - targets.size();
if (remainingTargets == 0) if (remainingTargets == 0) {
return true; return true;
}
int count = 0; int count = 0;
MageObject targetSource = game.getObject(sourceId); MageObject targetSource = game.getObject(sourceId);
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
@ -116,10 +117,11 @@ class ReciprocateTarget<T extends TargetCreaturePermanent<T>> extends TargetPerm
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
&& watcher != null && watcher.damageSources.contains(permanent.getId())) { && watcher != null && watcher.damageSources.contains(permanent.getId())) {
count++; count++;
if (count >= remainingTargets) if (count >= remainingTargets) {
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -126,8 +126,9 @@ class GiltspireAvengerTarget<T extends TargetCreaturePermanent<T>> extends Targe
@Override @Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int remainingTargets = this.minNumberOfTargets - targets.size(); int remainingTargets = this.minNumberOfTargets - targets.size();
if (remainingTargets == 0) if (remainingTargets == 0) {
return true; return true;
}
int count = 0; int count = 0;
MageObject targetSource = game.getObject(sourceId); MageObject targetSource = game.getObject(sourceId);
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId); PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", sourceControllerId);
@ -135,10 +136,11 @@ class GiltspireAvengerTarget<T extends TargetCreaturePermanent<T>> extends Targe
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game) if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
&& watcher != null && watcher.damageSources.contains(permanent.getId())) { && watcher != null && watcher.damageSources.contains(permanent.getId())) {
count++; count++;
if (count >= remainingTargets) if (count >= remainingTargets) {
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -36,7 +36,7 @@ import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -46,7 +46,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
*/ */
public class MoldAdder extends CardImpl<MoldAdder> { public class MoldAdder extends CardImpl<MoldAdder> {
private static final FilterCard filter = new FilterCard("blue or black spell"); private static final FilterSpell filter = new FilterSpell("blue or black spell");
static { static {
filter.add(Predicates.or( filter.add(Predicates.or(

View file

@ -39,7 +39,7 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.mageobject.ColorPredicate;
@ -52,7 +52,7 @@ import mage.players.Player;
*/ */
public class Mindsparker extends CardImpl<Mindsparker> { public class Mindsparker extends CardImpl<Mindsparker> {
private static final FilterCard filter = new FilterCard("white or blue instant or sorcery spell"); private static final FilterSpell filter = new FilterSpell("white or blue instant or sorcery spell");
static { static {
filter.add(Predicates.or( filter.add(Predicates.or(

View file

@ -49,7 +49,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterSpell;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -76,7 +76,7 @@ public class PardicDragon extends CardImpl<PardicDragon> {
this.addAbility(new SuspendAbility(2, new ManaCostsImpl("{R}{R}"), this, true)); this.addAbility(new SuspendAbility(2, new ManaCostsImpl("{R}{R}"), this, true));
// Whenever an opponent casts a spell, if Pardic Dragon is suspended, that player may put a time counter on Pardic Dragon. // Whenever an opponent casts a spell, if Pardic Dragon is suspended, that player may put a time counter on Pardic Dragon.
this.addAbility(new ConditionalTriggeredAbility( this.addAbility(new ConditionalTriggeredAbility(
new SpellCastOpponentTriggeredAbility(Zone.EXILED, new PardicDragonEffect(), new FilterCard(), false, true), new SpellCastOpponentTriggeredAbility(Zone.EXILED, new PardicDragonEffect(), new FilterSpell(), false, true),
SuspendedCondition.getInstance(), SuspendedCondition.getInstance(),
"Whenever an opponent casts a spell, if {this} is suspended, that player may put a time counter on Pardic Dragon." "Whenever an opponent casts a spell, if {this} is suspended, that player may put a time counter on Pardic Dragon."
)); ));

View file

@ -30,7 +30,7 @@ package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterSpell;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
@ -42,23 +42,23 @@ import mage.target.targetpointer.FixedTarget;
*/ */
public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl<SpellCastOpponentTriggeredAbility> { public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl<SpellCastOpponentTriggeredAbility> {
private static final FilterCard spellCard = new FilterCard("a spell"); private static final FilterSpell spellCard = new FilterSpell("a spell");
protected FilterCard filter; protected FilterSpell filter;
protected boolean setTargetPointerPlayer; protected boolean setTargetPointerPlayer;
public SpellCastOpponentTriggeredAbility(Effect effect, boolean optional) { public SpellCastOpponentTriggeredAbility(Effect effect, boolean optional) {
this(effect, spellCard, optional); this(effect, spellCard, optional);
} }
public SpellCastOpponentTriggeredAbility(Effect effect, FilterCard filter, boolean optional) { public SpellCastOpponentTriggeredAbility(Effect effect, FilterSpell filter, boolean optional) {
this(Zone.BATTLEFIELD, effect, filter, optional); this(Zone.BATTLEFIELD, effect, filter, optional);
} }
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterCard filter, boolean optional) { public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional) {
this(zone, effect, filter, optional, false); this(zone, effect, filter, optional, false);
} }
public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterCard filter, boolean optional, boolean setTargetPointerPlayer) { public SpellCastOpponentTriggeredAbility(Zone zone, Effect effect, FilterSpell filter, boolean optional, boolean setTargetPointerPlayer) {
super(zone, effect, optional); super(zone, effect, optional);
this.filter = filter; this.filter = filter;
this.setTargetPointerPlayer = setTargetPointerPlayer; this.setTargetPointerPlayer = setTargetPointerPlayer;
@ -79,8 +79,8 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl<Spel
for (Effect effect: this.getEffects()) { for (Effect effect: this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }
return true;
} }
return true;
} }
} }
return false; return false;