use staticfilter for 'a spell'

This commit is contained in:
Ingmar Goudt 2021-04-28 08:39:01 +02:00
parent dfc290a206
commit b4d806211c
23 changed files with 46 additions and 31 deletions

View file

@ -26,6 +26,7 @@ import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
@ -47,7 +48,7 @@ public final class BINGO extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// Whenever a player casts a spell, put a chip counter on its converted mana cost.
this.addAbility(new SpellCastAllTriggeredAbility(new BingoEffect(), new FilterSpell("a spell"), false, SetTargetPointer.SPELL));
this.addAbility(new SpellCastAllTriggeredAbility(new BingoEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL));
// B-I-N-G-O gets +9/+9 for each set of three numbers in a row with chip counters on them.
BingoCount count = new BingoCount();

View file

@ -12,6 +12,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
@ -31,7 +32,7 @@ public final class ChecksAndBalances extends CardImpl {
this.addAbility(new CastOnlyIfConditionIsTrueAbility(ChecksAndBalancesCondition.instance, "Cast this spell only if there are three or more players in the game"));
// Whenever a player casts a spell, each of that players opponents may discard a card. If they do, counter that spell.
this.addAbility(new SpellCastAllTriggeredAbility(new ChecksAndBalancesEffect(), new FilterSpell("a spell"), false, SetTargetPointer.SPELL));
this.addAbility(new SpellCastAllTriggeredAbility(new ChecksAndBalancesEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL));
}
private ChecksAndBalances(final ChecksAndBalances card) {

View file

@ -20,6 +20,7 @@ import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.target.TargetSpell;
/**
@ -34,7 +35,7 @@ public final class DecreeOfSilence extends CardImpl {
// Whenever an opponent casts a spell, counter that spell and put a depletion counter on Decree of Silence. If there are three or more depletion counters on Decree of Silence, sacrifice it.
Effect effect = new CounterTargetEffect();
effect.setText("counter that spell");
Ability ability = new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, effect, new FilterSpell("a spell"),
Ability ability = new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, effect, StaticFilters.FILTER_SPELL_A,
false, SetTargetPointer.SPELL);
effect = new AddCountersSourceEffect(CounterType.DEPLETION.createInstance());
effect.setText("and put a depletion counter on {this}.");

View file

@ -13,6 +13,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import java.util.UUID;
@ -33,7 +34,7 @@ public final class HermitOfTheNatterknolls extends CardImpl {
// Whenever an opponent casts a spell during your turn, draw a card.
this.addAbility(new ConditionalTriggeredAbility(
new SpellCastOpponentTriggeredAbility(new DrawCardSourceControllerEffect(1), new FilterSpell("a spell"), true),
new SpellCastOpponentTriggeredAbility(new DrawCardSourceControllerEffect(1), StaticFilters.FILTER_SPELL_A, true),
MyTurnCondition.instance,
"Whenever an opponent casts a spell during your turn, draw a card."
).addHint(MyTurnHint.instance));

View file

@ -12,6 +12,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
/**
*
@ -23,7 +24,7 @@ public final class Hesitation extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}");
// When a player casts a spell, sacrifice Hesitation and counter that spell.
Ability ability = new SpellCastAllTriggeredAbility(new SacrificeSourceEffect(), new FilterSpell("a spell"), false, SetTargetPointer.SPELL);
Ability ability = new SpellCastAllTriggeredAbility(new SacrificeSourceEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL);
Effect effect = new CounterTargetEffect();
effect.setText("and counter that spell");
ability.addEffect(effect);

View file

@ -16,6 +16,7 @@ import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.constants.TargetController;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
@ -30,7 +31,7 @@ public final class HornOfPlenty extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}");
// Whenever a player casts a spell, they may pay {1}. If that player does, they draw a card at the beginning of the next end step.
this.addAbility(new SpellCastAllTriggeredAbility(new HornOfPlentyEffect(), new FilterSpell("a spell"), false, SetTargetPointer.PLAYER));
this.addAbility(new SpellCastAllTriggeredAbility(new HornOfPlentyEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.PLAYER));
}
private HornOfPlenty(final HornOfPlenty card) {

View file

@ -10,6 +10,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
/**
*
@ -25,7 +26,7 @@ public final class JackalopeHerd extends CardImpl {
this.toughness = new MageInt(5);
// When you cast a spell, return Jackalope Herd to its owner's hand.
this.addAbility(new SpellCastControllerTriggeredAbility(new ReturnToHandSourceEffect(true), new FilterSpell("a spell"), false));
this.addAbility(new SpellCastControllerTriggeredAbility(new ReturnToHandSourceEffect(true), StaticFilters.FILTER_SPELL_A, false));
}
private JackalopeHerd(final JackalopeHerd card) {

View file

@ -12,6 +12,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import java.util.UUID;
@ -32,7 +33,7 @@ public final class LoneWolfOfTheNatterknolls extends CardImpl {
// Whenever an opponent cast a spell during your turn, draw two cards.
this.addAbility(new ConditionalTriggeredAbility(
new SpellCastOpponentTriggeredAbility(new DrawCardSourceControllerEffect(2), new FilterSpell("a spell"), true),
new SpellCastOpponentTriggeredAbility(new DrawCardSourceControllerEffect(2), StaticFilters.FILTER_SPELL_A, true),
MyTurnCondition.instance,
"Whenever an opponent casts a spell during your turn, draw two cards."
).addHint(MyTurnHint.instance));

View file

@ -13,6 +13,7 @@ import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
/**
*
@ -25,7 +26,7 @@ public final class LunarForce extends CardImpl {
// Whenever an opponent casts a spell, sacrifice Lunar Force and counter that spell.
Ability ability = new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new SacrificeSourceEffect(),
new FilterSpell("a spell"), false, SetTargetPointer.SPELL);
StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL);
Effect effect = new CounterTargetEffect();
effect.setText("and counter that spell");
ability.addEffect(effect);

View file

@ -11,6 +11,7 @@ import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.constants.SuperType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
/**
*
@ -23,7 +24,7 @@ public final class NetherVoid extends CardImpl {
addSuperType(SuperType.WORLD);
// Whenever a player casts a spell, counter it unless that player pays {3}.
this.addAbility(new SpellCastAllTriggeredAbility(new CounterUnlessPaysEffect(new GenericManaCost(3)), new FilterSpell("a spell"), false, SetTargetPointer.SPELL));
this.addAbility(new SpellCastAllTriggeredAbility(new CounterUnlessPaysEffect(new GenericManaCost(3)), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL));
}
private NetherVoid(final NetherVoid card) {

View file

@ -15,6 +15,7 @@ import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -56,8 +57,6 @@ public final class OpalineSliver extends CardImpl {
class OpalineSliverTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterSpell spellCard = new FilterSpell("a spell");
public OpalineSliverTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
}
@ -85,7 +84,7 @@ class OpalineSliverTriggeredAbility extends TriggeredAbilityImpl {
} else {
return event.getTargetId().equals(this.getSourceId())
&& game.getOpponents(this.controllerId).contains(event.getPlayerId())
&& spellCard.match(spell, getSourceId(), getControllerId(), game);
&& StaticFilters.FILTER_SPELL_A.match(spell, getSourceId(), getControllerId(), game);
}
}

View file

@ -15,6 +15,7 @@ import mage.constants.SetTargetPointer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
@ -33,7 +34,7 @@ public final class PlanarChaos extends CardImpl {
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new PlanarChaosUpkeepEffect(), TargetController.YOU, false));
// Whenever a player casts a spell, that player flips a coin. If they lose the flip, counter that spell.
this.addAbility(new SpellCastAllTriggeredAbility(new PlanarChaosCastAllEffect(), new FilterSpell("a spell"), false, SetTargetPointer.SPELL));
this.addAbility(new SpellCastAllTriggeredAbility(new PlanarChaosCastAllEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL));
}
private PlanarChaos(final PlanarChaos card) {

View file

@ -20,6 +20,7 @@ import mage.constants.SuperType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
@ -42,7 +43,7 @@ public final class RamosDragonEngine extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever you cast a spell, put a +1/+1 counter on Ramos, Dragon Engine for each of that spell's colors.
this.addAbility(new SpellCastControllerTriggeredAbility(new RamosDragonEngineAddCountersEffect(), new FilterSpell("a spell"), false, true));
this.addAbility(new SpellCastControllerTriggeredAbility(new RamosDragonEngineAddCountersEffect(), StaticFilters.FILTER_SPELL_A, false, true));
// Remove five +1/+1 counters from Ramos: Add {W}{W}{U}{U}{B}{B}{R}{R}{G}{G}. Activate this ability only once each turn.
Ability ability = new ActivateOncePerTurnManaAbility(Zone.BATTLEFIELD, new BasicManaEffect(new Mana(2, 2, 2, 2, 2, 0, 0, 0)), new RemoveCountersSourceCost(CounterType.P1P1.createInstance(5)));

View file

@ -12,6 +12,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
@ -35,7 +36,7 @@ public final class StaffOfTheLetterMagus extends CardImpl {
this.addAbility(new AsEntersBattlefieldAbility(new StaffOfTheLetterMagusChooseLetterEffect()));
// Whenever a player casts a spell, you gain 1 life for each time the chosen letter appears in that spells name.
this.addAbility(new SpellCastAllTriggeredAbility(new StaffOfTheLetterMagusEffect(), new FilterSpell("a spell"), false, SetTargetPointer.SPELL));
this.addAbility(new SpellCastAllTriggeredAbility(new StaffOfTheLetterMagusEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.SPELL));
}
private StaffOfTheLetterMagus(final StaffOfTheLetterMagus card) {

View file

@ -14,6 +14,7 @@ import mage.choices.ChoiceColor;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
@ -32,7 +33,7 @@ public final class TabletOfTheGuilds extends CardImpl {
this.addAbility(new AsEntersBattlefieldAbility(new TabletOfTheGuildsEntersBattlefieldEffect()));
// Whenever you cast a spell, if it's at least one of the chosen colors, you gain 1 life for each of the chosen colors it is.
this.addAbility(new SpellCastControllerTriggeredAbility(new TabletOfTheGuildsGainLifeEffect(), new FilterSpell("a spell"), false, true));
this.addAbility(new SpellCastControllerTriggeredAbility(new TabletOfTheGuildsGainLifeEffect(), StaticFilters.FILTER_SPELL_A, false, true));
}
private TabletOfTheGuilds(final TabletOfTheGuilds card) {

View file

@ -13,6 +13,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
@ -28,7 +29,7 @@ public final class UnifyingTheory extends CardImpl {
// Whenever a player casts a spell, that player may pay {2}. If the player does, they draw a card.
this.addAbility(new SpellCastAllTriggeredAbility(new UnifyingTheoryEffect() , new FilterSpell("a spell"), false, SetTargetPointer.PLAYER));
this.addAbility(new SpellCastAllTriggeredAbility(new UnifyingTheoryEffect() , StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.PLAYER));
}
private UnifyingTheory(final UnifyingTheory card) {

View file

@ -11,6 +11,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -25,7 +26,7 @@ public final class VeilstoneAmulet extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}");
// Whenever you cast a spell, creatures you control can't be the targets of spells or abilities your opponents control this turn.
this.addAbility(new SpellCastControllerTriggeredAbility(new VeilstoneAmuletEffect(), new FilterSpell("a spell"), false));
this.addAbility(new SpellCastControllerTriggeredAbility(new VeilstoneAmuletEffect(), StaticFilters.FILTER_SPELL_A, false));
}
private VeilstoneAmulet(final VeilstoneAmulet card) {

View file

@ -15,6 +15,7 @@ import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.permanent.token.VoiceOfResurgenceToken;
import java.util.UUID;
@ -34,7 +35,7 @@ public final class VoiceOfResurgence extends CardImpl {
// Whenever an opponent casts a spell during your turn or when Voice of Resurgence dies, create a green and white Elemental creature token with "This creature's power and toughness are each equal to the number of creatures you control."
OrTriggeredAbility ability = new OrTriggeredAbility(Zone.BATTLEFIELD, new CreateTokenEffect(new VoiceOfResurgenceToken()),
new ConditionalTriggeredAbility(
new SpellCastOpponentTriggeredAbility(null, new FilterSpell("a spell"), false),
new SpellCastOpponentTriggeredAbility(null, StaticFilters.FILTER_SPELL_A, false),
MyTurnCondition.instance,
"Whenever an opponent casts a spell during your turn, "),
new DiesSourceTriggeredAbility(null, false));

View file

@ -5,6 +5,7 @@ import mage.abilities.effects.Effect;
import mage.constants.SetTargetPointer;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
@ -15,12 +16,11 @@ import mage.target.targetpointer.FixedTarget;
*/
public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterSpell spellCard = new FilterSpell("a spell");
protected FilterSpell filter;
protected SetTargetPointer setTargetPointer;
public SpellCastOpponentTriggeredAbility(Effect effect, boolean optional) {
this(effect, spellCard, optional);
this(effect, StaticFilters.FILTER_SPELL_A, optional);
}
public SpellCastOpponentTriggeredAbility(Effect effect, FilterSpell filter, boolean optional) {

View file

@ -7,6 +7,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.command.Emblem;
import mage.target.common.TargetAnyTarget;
@ -21,7 +22,7 @@ public final class ChandraTorchOfDefianceEmblem extends Emblem {
this.setName("Emblem Chandra");
Effect effect = new DamageTargetEffect(5);
effect.setText("this emblem deals 5 damage to any target");
Ability ability = new SpellCastControllerTriggeredAbility(Zone.COMMAND, effect, new FilterSpell("a spell"), false, false);
Ability ability = new SpellCastControllerTriggeredAbility(Zone.COMMAND, effect, StaticFilters.FILTER_SPELL_A, false, false);
ability.addTarget(new TargetAnyTarget());
getAbilities().add(ability);
}

View file

@ -6,6 +6,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.MillCardsTargetEffect;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.command.Emblem;
import mage.target.common.TargetOpponent;
@ -19,7 +20,7 @@ public final class JaceTelepathUnboundEmblem extends Emblem {
this.setName("Emblem Jace");
Effect effect = new MillCardsTargetEffect(5);
effect.setText("target opponent mills five cards");
Ability ability = new SpellCastControllerTriggeredAbility(Zone.COMMAND, effect, new FilterSpell("a spell"), false, false);
Ability ability = new SpellCastControllerTriggeredAbility(Zone.COMMAND, effect, StaticFilters.FILTER_SPELL_A, false, false);
ability.addTarget(new TargetOpponent());
getAbilities().add(ability);
}

View file

@ -7,6 +7,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.command.Emblem;
import mage.game.events.GameEvent;
@ -36,8 +37,6 @@ public final class VenserTheSojournerEmblem extends Emblem {
class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterSpell spellCard = new FilterSpell("a spell");
protected FilterSpell filter;
/**
* If true, the source that triggered the ability will be set as target to
@ -46,12 +45,10 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl {
public VenserTheSojournerSpellCastTriggeredAbility(Effect effect, boolean optional) {
super(Zone.COMMAND, effect, optional);
this.filter = spellCard;
}
public VenserTheSojournerSpellCastTriggeredAbility(final VenserTheSojournerSpellCastTriggeredAbility ability) {
super(ability);
filter = ability.filter;
}
@Override
@ -63,7 +60,7 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
return spell != null && filter.match(spell, game);
return spell != null && StaticFilters.FILTER_SPELL_A.match(spell, game);
}
return false;
}

View file

@ -14,6 +14,7 @@ import mage.abilities.effects.common.RollPlanarDieEffect;
import mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect;
import mage.constants.*;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.command.Plane;
import mage.players.Player;
@ -29,14 +30,13 @@ import java.util.List;
*/
public class FieldsOfSummerPlane extends Plane {
private static final FilterSpell filter = new FilterSpell("a spell");
public FieldsOfSummerPlane() {
this.setPlaneType(Planes.PLANE_FIELDS_OF_SUMMER);
this.setExpansionSetCodeForImage("PCA");
// Whenever a player casts a spell, that player may gain 2 life
SpellCastAllTriggeredAbility ability = new SpellCastAllTriggeredAbility(Zone.COMMAND, new FieldsOfSummerEffect(), filter, false, SetTargetPointer.PLAYER);
SpellCastAllTriggeredAbility ability = new SpellCastAllTriggeredAbility(Zone.COMMAND, new FieldsOfSummerEffect(), StaticFilters.FILTER_SPELL_A, false, SetTargetPointer.PLAYER);
this.getAbilities().add(ability);
// Active player can roll the planar die: Whenever you roll {CHAOS}, you may gain 10 life