From b4e2059a6178e1c88331d49fafef4ed457c058c8 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Tue, 4 Apr 2023 19:31:17 -0400 Subject: [PATCH] [MOM] Implement Ozolith, the Shattered Spine --- .../src/mage/cards/b/BenevolentHydra.java | 67 ++++-------------- .../src/mage/cards/c/ConclaveMentor.java | 58 +--------------- .../src/mage/cards/h/HardenedScales.java | 60 ++-------------- .../cards/o/OzolithTheShatteredSpire.java | 56 +++++++++++++++ .../mage/cards/p/PirImaginativeRascal.java | 66 ++++-------------- .../src/mage/cards/w/WindingConstrictor.java | 60 +++------------- .../src/mage/sets/MarchOfTheMachine.java | 1 + .../ModifyCountersAddedEffect.java | 69 +++++++++++++++++++ 8 files changed, 170 insertions(+), 267 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/o/OzolithTheShatteredSpire.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/replacement/ModifyCountersAddedEffect.java diff --git a/Mage.Sets/src/mage/cards/b/BenevolentHydra.java b/Mage.Sets/src/mage/cards/b/BenevolentHydra.java index 8422a3c948..7b88b9f540 100644 --- a/Mage.Sets/src/mage/cards/b/BenevolentHydra.java +++ b/Mage.Sets/src/mage/cards/b/BenevolentHydra.java @@ -7,28 +7,33 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.SubType; import mage.counters.CounterType; +import mage.filter.FilterPermanent; import mage.filter.StaticFilters; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.mageobject.AnotherPredicate; import mage.target.TargetPermanent; -import mage.util.CardUtil; import java.util.UUID; /** - * * @author Grath */ public final class BenevolentHydra extends CardImpl { + private static final FilterPermanent filter = new FilterControlledCreaturePermanent("another creature you control"); + + static { + filter.add(AnotherPredicate.instance); + } + public BenevolentHydra(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}{G}"); @@ -42,7 +47,7 @@ public final class BenevolentHydra extends CardImpl { )); // If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BenevolentHydraEffect())); + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(filter, CounterType.P1P1))); // {T}, Remove a +1/+1 counter from Benevolent Hydra: Put a +1/+1 counter on another target creature you control. Ability ability = new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()).setText("Put a +1/+1 counter on another target creature you control"), new TapSourceCost()); @@ -60,49 +65,3 @@ public final class BenevolentHydra extends CardImpl { return new BenevolentHydra(this); } } - -class BenevolentHydraEffect extends ReplacementEffectImpl { - - BenevolentHydraEffect() { - super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); - staticText = "If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead"; - } - - BenevolentHydraEffect(final BenevolentHydraEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true); - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ADD_COUNTERS; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) { - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent == null) { - permanent = game.getPermanentEntering(event.getTargetId()); - } - return permanent != null && permanent.isControlledBy(source.getControllerId()) - && permanent.isCreature(game) && !event.getTargetId().equals(source.getSourceId()); - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public BenevolentHydraEffect copy() { - return new BenevolentHydraEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/ConclaveMentor.java b/Mage.Sets/src/mage/cards/c/ConclaveMentor.java index 6412ec6ef5..26559bee18 100644 --- a/Mage.Sets/src/mage/cards/c/ConclaveMentor.java +++ b/Mage.Sets/src/mage/cards/c/ConclaveMentor.java @@ -1,23 +1,18 @@ package mage.cards.c; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; +import mage.filter.StaticFilters; import java.util.UUID; @@ -37,7 +32,7 @@ public final class ConclaveMentor extends CardImpl { this.toughness = new MageInt(2); // If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on that creature instead. - this.addAbility(new SimpleStaticAbility(new ConclaveMentorEffect())); + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(StaticFilters.FILTER_CONTROLLED_CREATURE, CounterType.P1P1))); // When Conclave Mentor dies, you gain life equal to its power. this.addAbility(new DiesSourceTriggeredAbility(new GainLifeEffect(xValue, "you gain life equal to its power"))); @@ -52,50 +47,3 @@ public final class ConclaveMentor extends CardImpl { return new ConclaveMentor(this); } } - -class ConclaveMentorEffect extends ReplacementEffectImpl { - - ConclaveMentorEffect() { - super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); - staticText = "If one or more +1/+1 counters would be put on a creature you control, " + - "that many plus one +1/+1 counters are put on that creature instead"; - } - - private ConclaveMentorEffect(final ConclaveMentorEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - event.setAmountForCounters(event.getAmount() + 1, true); - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ADD_COUNTERS; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) { - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent == null) { - permanent = game.getPermanentEntering(event.getTargetId()); - } - return permanent != null && permanent.isControlledBy(source.getControllerId()) - && permanent.isCreature(game); - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public ConclaveMentorEffect copy() { - return new ConclaveMentorEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/h/HardenedScales.java b/Mage.Sets/src/mage/cards/h/HardenedScales.java index 9fbbd80b02..1c74807edd 100644 --- a/Mage.Sets/src/mage/cards/h/HardenedScales.java +++ b/Mage.Sets/src/mage/cards/h/HardenedScales.java @@ -1,18 +1,12 @@ package mage.cards.h; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; +import mage.filter.StaticFilters; import java.util.UUID; @@ -25,7 +19,9 @@ public final class HardenedScales extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); // If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HardenedScalesEffect())); + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect( + StaticFilters.FILTER_CONTROLLED_CREATURE, CounterType.P1P1 + ))); } @@ -38,49 +34,3 @@ public final class HardenedScales extends CardImpl { return new HardenedScales(this); } } - -class HardenedScalesEffect extends ReplacementEffectImpl { - - HardenedScalesEffect() { - super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); - staticText = "If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead"; - } - - HardenedScalesEffect(final HardenedScalesEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - event.setAmountForCounters(event.getAmount() + 1, true); - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ADD_COUNTERS; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) { - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent == null) { - permanent = game.getPermanentEntering(event.getTargetId()); - } - return permanent != null && permanent.isControlledBy(source.getControllerId()) - && permanent.isCreature(game); - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public HardenedScalesEffect copy() { - return new HardenedScalesEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/o/OzolithTheShatteredSpire.java b/Mage.Sets/src/mage/cards/o/OzolithTheShatteredSpire.java new file mode 100644 index 0000000000..d931368092 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OzolithTheShatteredSpire.java @@ -0,0 +1,56 @@ +package mage.cards.o; + +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; +import mage.abilities.keyword.CyclingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SuperType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class OzolithTheShatteredSpire extends CardImpl { + + public OzolithTheShatteredSpire(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{G}"); + + this.addSuperType(SuperType.LEGENDARY); + + // If one or more +1/+1 counters would be put on an artifact or creature you control, that many plus one +1/+1 counters are put on it instead. + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect( + StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, CounterType.P1P1 + ))); + + // {1}{G}, {T}: Put a +1/+1 counter on target artifact or creature you control. Activate only as a sorcery. + Ability ability = new ActivateAsSorceryActivatedAbility( + new AddCountersTargetEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl<>("{1}{G}") + ); + ability.addCost(new TapSourceCost()); + ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE)); + this.addAbility(ability); + + // Cycling {2} + this.addAbility(new CyclingAbility(new ManaCostsImpl<>("{2}"))); + } + + private OzolithTheShatteredSpire(final OzolithTheShatteredSpire card) { + super(card); + } + + @Override + public OzolithTheShatteredSpire copy() { + return new OzolithTheShatteredSpire(this); + } +} diff --git a/Mage.Sets/src/mage/cards/p/PirImaginativeRascal.java b/Mage.Sets/src/mage/cards/p/PirImaginativeRascal.java index a039df0fd5..ac6196e076 100644 --- a/Mage.Sets/src/mage/cards/p/PirImaginativeRascal.java +++ b/Mage.Sets/src/mage/cards/p/PirImaginativeRascal.java @@ -1,17 +1,16 @@ package mage.cards.p; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; import mage.abilities.keyword.PartnerWithAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.constants.TargetController; +import mage.filter.FilterPermanent; import java.util.UUID; @@ -20,6 +19,12 @@ import java.util.UUID; */ public final class PirImaginativeRascal extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent("permanent your team controls"); + + static { + filter.add(TargetController.TEAM.getControllerPredicate()); + } + public PirImaginativeRascal(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); @@ -32,7 +37,7 @@ public final class PirImaginativeRascal extends CardImpl { this.addAbility(new PartnerWithAbility("Toothy, Imaginary Friend", true)); // If one or more counters would be put on a permanent your team controls, that many plus one of each of those kinds of counters are put on that permanent instead. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PirImaginativeRascalEffect())); + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(filter, null))); } private PirImaginativeRascal(final PirImaginativeRascal card) { @@ -44,48 +49,3 @@ public final class PirImaginativeRascal extends CardImpl { return new PirImaginativeRascal(this); } } - -class PirImaginativeRascalEffect extends ReplacementEffectImpl { - - PirImaginativeRascalEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit, false); - staticText = "If one or more counters would be put on a permanent your team controls, " - + "that many plus one of each of those kinds of counters are put on that permanent instead"; - } - - PirImaginativeRascalEffect(final PirImaginativeRascalEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - event.setAmountForCounters(event.getAmount() + 1, true); - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ADD_COUNTERS; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - Permanent permanent = game.getPermanent(event.getTargetId()); - Player player = game.getPlayer(source.getControllerId()); - if (permanent == null) { - permanent = game.getPermanentEntering(event.getTargetId()); - } - return permanent != null && player != null && event.getAmount() > 0 - && !player.hasOpponent(permanent.getControllerId(), game); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public PirImaginativeRascalEffect copy() { - return new PirImaginativeRascalEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/w/WindingConstrictor.java b/Mage.Sets/src/mage/cards/w/WindingConstrictor.java index 8cf5ab95ba..621691a60c 100644 --- a/Mage.Sets/src/mage/cards/w/WindingConstrictor.java +++ b/Mage.Sets/src/mage/cards/w/WindingConstrictor.java @@ -4,12 +4,16 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; import mage.players.Player; import java.util.UUID; @@ -27,10 +31,12 @@ public final class WindingConstrictor extends CardImpl { this.toughness = new MageInt(3); // If one or more counters would be put on an artifact or creature you control, that many plus one of each of those kinds of counters are put on that permanent instead. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindingConstrictorPermanentEffect())); + this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect( + StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, null + ))); // If you would get one or more counters, you get that many plus one of each of those kinds of counters instead. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindingConstrictorPlayerEffect())); + this.addAbility(new SimpleStaticAbility(new WindingConstrictorPlayerEffect())); } private WindingConstrictor(final WindingConstrictor card) { @@ -43,52 +49,6 @@ public final class WindingConstrictor extends CardImpl { } } -class WindingConstrictorPermanentEffect extends ReplacementEffectImpl { - - WindingConstrictorPermanentEffect() { - super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); - staticText = "If one or more counters would be put on an artifact or creature you control, " - + "that many plus one of each of those kinds of counters are put on that permanent instead"; - } - - WindingConstrictorPermanentEffect(final WindingConstrictorPermanentEffect effect) { - super(effect); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - event.setAmountForCounters(event.getAmount() + 1, true); - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ADD_COUNTERS; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent == null) { - permanent = game.getPermanentEntering(event.getTargetId()); - } - return permanent != null - && event.getAmount() > 0 - && (permanent.isCreature(game) || permanent.isArtifact(game)) - && permanent.isControlledBy(source.getControllerId()); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public WindingConstrictorPermanentEffect copy() { - return new WindingConstrictorPermanentEffect(this); - } -} - class WindingConstrictorPlayerEffect extends ReplacementEffectImpl { WindingConstrictorPlayerEffect() { diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index 7adba8aa12..31568d8865 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -85,6 +85,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Norn's Inquisitor", 29, Rarity.UNCOMMON, mage.cards.n.NornsInquisitor.class)); cards.add(new SetCardInfo("Omen Hawker", 70, Rarity.UNCOMMON, mage.cards.o.OmenHawker.class)); cards.add(new SetCardInfo("Oracle of Tragedy", 71, Rarity.UNCOMMON, mage.cards.o.OracleOfTragedy.class)); + cards.add(new SetCardInfo("Ozolith, the Shattered Spire", 198, Rarity.RARE, mage.cards.o.OzolithTheShatteredSpire.class)); cards.add(new SetCardInfo("Phyrexian Awakening", 30, Rarity.UNCOMMON, mage.cards.p.PhyrexianAwakening.class)); cards.add(new SetCardInfo("Phyrexian Gargantua", 121, Rarity.UNCOMMON, mage.cards.p.PhyrexianGargantua.class)); cards.add(new SetCardInfo("Phyrexian Pegasus", 324, Rarity.COMMON, mage.cards.p.PhyrexianPegasus.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/replacement/ModifyCountersAddedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/replacement/ModifyCountersAddedEffect.java new file mode 100644 index 0000000000..917da46beb --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/replacement/ModifyCountersAddedEffect.java @@ -0,0 +1,69 @@ +package mage.abilities.effects.common.replacement; + +import mage.abilities.Ability; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public class ModifyCountersAddedEffect extends ReplacementEffectImpl { + + private final FilterPermanent filter; + private final CounterType counterType; + + public ModifyCountersAddedEffect(FilterPermanent filter, CounterType counterType) { + super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false); + this.filter = filter; + this.counterType = counterType; + staticText = "if one or more " + (counterType != null ? counterType + " " : "") + "counters would be put on " + + CardUtil.addArticle(filter.getMessage()) + " you control, that many plus one " + + (counterType != null ? counterType : "of each of those kinds of") + " counters are put on it instead"; + } + + private ModifyCountersAddedEffect(final ModifyCountersAddedEffect effect) { + super(effect); + this.filter = effect.filter; + this.counterType = effect.counterType; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + event.setAmountForCounters(event.getAmount() + 1, true); + return false; + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ADD_COUNTERS; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if ((counterType != null && !event.getData().equals(counterType.getName())) || event.getAmount() <= 0) { + return false; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null) { + permanent = game.getPermanentEntering(event.getTargetId()); + } + return permanent != null && filter.match(permanent, source.getControllerId(), source, game); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ModifyCountersAddedEffect copy() { + return new ModifyCountersAddedEffect(this); + } +}