From f942c36651aa5bc53f0a987ea724c2cc21bf3a71 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Thu, 26 Jan 2023 08:35:39 -0500 Subject: [PATCH] consolidate effects which add counters to players --- .../src/mage/cards/d/DaxosTheReturned.java | 16 +++--- .../src/mage/cards/e/EzuriClawOfProgress.java | 21 ++++---- Mage.Sets/src/mage/cards/i/IchorRats.java | 17 +++---- .../src/mage/cards/i/InfectiousBite.java | 11 ++-- .../mage/cards/k/KalemneDiscipleOfIroas.java | 23 +++------ .../src/mage/cards/k/KelsienThePlague.java | 4 +- .../src/mage/cards/m/MerenOfClanNelToth.java | 8 +-- .../src/mage/cards/m/MizzixOfTheIzmagnus.java | 11 ++-- .../src/mage/cards/p/PhyrexianVatmother.java | 17 +++---- .../src/mage/cards/r/RelicPutrescence.java | 16 +++--- .../counter/AddCountersControllerEffect.java | 50 ------------------- ...ect.java => AddCountersPlayersEffect.java} | 32 +++++------- 12 files changed, 74 insertions(+), 152 deletions(-) delete mode 100644 Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersControllerEffect.java rename Mage/src/main/java/mage/abilities/effects/common/counter/{AddPoisonCounterAllEffect.java => AddCountersPlayersEffect.java} (74%) diff --git a/Mage.Sets/src/mage/cards/d/DaxosTheReturned.java b/Mage.Sets/src/mage/cards/d/DaxosTheReturned.java index 3cffc64b0b..5d7c8e2040 100644 --- a/Mage.Sets/src/mage/cards/d/DaxosTheReturned.java +++ b/Mage.Sets/src/mage/cards/d/DaxosTheReturned.java @@ -1,15 +1,11 @@ - package mage.cards.d; -import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.CreateTokenEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; @@ -17,8 +13,9 @@ import mage.counters.CounterType; import mage.filter.FilterSpell; import mage.game.permanent.token.DaxosSpiritToken; +import java.util.UUID; + /** - * * @author fireshoes */ public final class DaxosTheReturned extends CardImpl { @@ -38,10 +35,9 @@ public final class DaxosTheReturned extends CardImpl { this.toughness = new MageInt(2); // Whenever you cast an enchantment spell, you get an experience counter. - Effect effect = new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1)); - effect.setText("you get an experience counter"); - Ability ability = new SpellCastControllerTriggeredAbility(effect, filter, false); - this.addAbility(ability); + this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect( + CounterType.EXPERIENCE.createInstance(), TargetController.YOU + ), filter, false)); // {1}{W}{B}: Create a white and black Spirit enchantment creature token. It has // "This creature's power and toughness are each equal to the number of experience counters you have." diff --git a/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java b/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java index 430d6b5fdb..3eb0f13597 100644 --- a/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java +++ b/Mage.Sets/src/mage/cards/e/EzuriClawOfProgress.java @@ -1,32 +1,32 @@ - package mage.cards.e; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfCombatTriggeredAbility; -import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.counters.CounterType; import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.AnotherPredicate; +import mage.filter.predicate.mageobject.PowerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetControlledCreaturePermanent; +import java.util.UUID; + /** - * * @author fireshoes */ public final class EzuriClawOfProgress extends CardImpl { - final private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(); + final private static FilterControlledCreaturePermanent filter + = new FilterControlledCreaturePermanent("a creature with power 2 or less"); final private static FilterControlledCreaturePermanent filter2 = new FilterControlledCreaturePermanent(); static { @@ -34,8 +34,6 @@ public final class EzuriClawOfProgress extends CardImpl { filter2.add(AnotherPredicate.instance); } - private static final String rule = "Whenever a creature with power 2 or less enters the battlefield under your control, you get an experience counter."; - public EzuriClawOfProgress(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}"); addSuperType(SuperType.LEGENDARY); @@ -46,8 +44,9 @@ public final class EzuriClawOfProgress extends CardImpl { this.toughness = new MageInt(3); // Whenever a creature with power 2 or less enters the battlefield under your control, you get an experience counter. - this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new AddCountersControllerEffect( - CounterType.EXPERIENCE.createInstance(1)), filter, false, rule, true)); + this.addAbility(new EntersBattlefieldControlledTriggeredAbility(new AddCountersPlayersEffect( + CounterType.EXPERIENCE.createInstance(), TargetController.YOU + ), filter)); // At the beginning of combat on your turn, put X +1/+1 counters on another target creature you control, where X is the number of experience counters you have. Ability ability = new BeginningOfCombatTriggeredAbility(new EzuriClawOfProgressEffect(), TargetController.YOU, false); diff --git a/Mage.Sets/src/mage/cards/i/IchorRats.java b/Mage.Sets/src/mage/cards/i/IchorRats.java index eaec41dbf6..7acfc772a2 100644 --- a/Mage.Sets/src/mage/cards/i/IchorRats.java +++ b/Mage.Sets/src/mage/cards/i/IchorRats.java @@ -1,22 +1,17 @@ package mage.cards.i; -import java.util.UUID; - import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.keyword.InfectAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; import mage.constants.TargetController; import mage.counters.CounterType; -import mage.game.Game; -import mage.players.Player; + +import java.util.UUID; /** * @author Loki @@ -31,9 +26,9 @@ public final class IchorRats extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(1); this.addAbility(InfectAbility.getInstance()); - this.addAbility(new EntersBattlefieldTriggeredAbility( - new AddPoisonCounterAllEffect(TargetController.EACH_PLAYER), false - )); + this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersPlayersEffect( + CounterType.POISON.createInstance(), TargetController.EACH_PLAYER + ), false)); } private IchorRats(final IchorRats card) { diff --git a/Mage.Sets/src/mage/cards/i/InfectiousBite.java b/Mage.Sets/src/mage/cards/i/InfectiousBite.java index 4e1cd20ec3..3d77ad7eab 100644 --- a/Mage.Sets/src/mage/cards/i/InfectiousBite.java +++ b/Mage.Sets/src/mage/cards/i/InfectiousBite.java @@ -1,17 +1,18 @@ package mage.cards.i; -import java.util.UUID; - import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect; -import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.TargetController; +import mage.counters.CounterType; import mage.filter.StaticFilters; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** * @author TheElk801 */ @@ -24,7 +25,9 @@ public final class InfectiousBite extends CardImpl { this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); - this.getSpellAbility().addEffect(new AddPoisonCounterAllEffect(TargetController.OPPONENT)); + this.getSpellAbility().addEffect(new AddCountersPlayersEffect( + CounterType.POISON.createInstance(), TargetController.OPPONENT + )); } private InfectiousBite(final InfectiousBite card) { diff --git a/Mage.Sets/src/mage/cards/k/KalemneDiscipleOfIroas.java b/Mage.Sets/src/mage/cards/k/KalemneDiscipleOfIroas.java index 1ea7a1b6dc..b02b9dfc6b 100644 --- a/Mage.Sets/src/mage/cards/k/KalemneDiscipleOfIroas.java +++ b/Mage.Sets/src/mage/cards/k/KalemneDiscipleOfIroas.java @@ -1,7 +1,5 @@ - package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -9,25 +7,21 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; import mage.abilities.effects.common.continuous.BoostSourceEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.ComparisonType; -import mage.constants.Duration; -import mage.constants.SuperType; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.CounterType; import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.ManaValuePredicate; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** - * * @author fireshoes */ public final class KalemneDiscipleOfIroas extends CardImpl { @@ -40,7 +34,7 @@ public final class KalemneDiscipleOfIroas extends CardImpl { } public KalemneDiscipleOfIroas(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{W}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.GIANT); this.subtype.add(SubType.SOLDIER); @@ -54,10 +48,9 @@ public final class KalemneDiscipleOfIroas extends CardImpl { this.addAbility(VigilanceAbility.getInstance()); // Whenever you cast a creature spell with converted mana cost 5 or greater, you get an experience counter. - Effect effect = new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1)); - effect.setText("you get an experience counter"); - Ability ability = new SpellCastControllerTriggeredAbility(effect, filterSpell, false); - this.addAbility(ability); + this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect( + CounterType.EXPERIENCE.createInstance(), TargetController.YOU + ), filterSpell, false)); // Kalemne, Disciple of Iroas gets +1/+1 for each experience counter you have. DynamicValue value = new SourceControllerExperienceCountersCount(); diff --git a/Mage.Sets/src/mage/cards/k/KelsienThePlague.java b/Mage.Sets/src/mage/cards/k/KelsienThePlague.java index 3a0b1b7923..2e87d7f16a 100644 --- a/Mage.Sets/src/mage/cards/k/KelsienThePlague.java +++ b/Mage.Sets/src/mage/cards/k/KelsienThePlague.java @@ -11,7 +11,7 @@ import mage.abilities.effects.Effect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.continuous.BoostSourceEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.VigilanceAbility; import mage.cards.CardImpl; @@ -53,7 +53,7 @@ public final class KelsienThePlague extends CardImpl { // {T}: Kelsien deals 1 damage to target creature you don't control. When that creature dies this turn, you get an experience counter. Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new TapSourceCost()); ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new WhenTargetDiesDelayedTriggeredAbility( - new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance()) + new AddCountersPlayersEffect(CounterType.EXPERIENCE.createInstance(), TargetController.YOU) ))); ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/m/MerenOfClanNelToth.java b/Mage.Sets/src/mage/cards/m/MerenOfClanNelToth.java index 07dea86b44..378688f079 100644 --- a/Mage.Sets/src/mage/cards/m/MerenOfClanNelToth.java +++ b/Mage.Sets/src/mage/cards/m/MerenOfClanNelToth.java @@ -5,7 +5,7 @@ import mage.abilities.Ability; import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility; import mage.abilities.common.DiesCreatureTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -42,9 +42,9 @@ public final class MerenOfClanNelToth extends CardImpl { this.toughness = new MageInt(4); // Whenever another creature you control dies, you get an experience counter. - this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersControllerEffect( - CounterType.EXPERIENCE.createInstance(1) - ).setText("you get an experience counter"), false, filter)); + this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersPlayersEffect( + CounterType.EXPERIENCE.createInstance(), TargetController.YOU + ), false, filter)); // At the beginning of your end step, choose target creature card in your graveyard. // If that card's converted mana cost is less than or equal to the number of experience counters you have, return it to the battlefield. Otherwise, put it into your hand. diff --git a/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java b/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java index 6237a53da4..2439466894 100644 --- a/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java +++ b/Mage.Sets/src/mage/cards/m/MizzixOfTheIzmagnus.java @@ -1,6 +1,5 @@ package mage.cards.m; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -8,7 +7,7 @@ import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.effects.common.cost.CostModificationEffectImpl; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -22,8 +21,9 @@ import mage.game.stack.Spell; import mage.players.Player; import mage.util.CardUtil; +import java.util.UUID; + /** - * * @author emerald000 */ public final class MizzixOfTheIzmagnus extends CardImpl { @@ -43,8 +43,9 @@ public final class MizzixOfTheIzmagnus extends CardImpl { this.toughness = new MageInt(2); // Whenever you cast an instant or sorcery spell with converted mana cost greater than the number of experience counters you have, you get an experience counter. - this.addAbility(new SpellCastControllerTriggeredAbility( - new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1)), filter, false)); + this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect( + CounterType.EXPERIENCE.createInstance(), TargetController.YOU + ), filter, false)); // Instant and sorcery spells you cast cost {1} less to cast for each experience counter you have. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MizzixOfTheIzmagnusCostReductionEffect())); diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianVatmother.java b/Mage.Sets/src/mage/cards/p/PhyrexianVatmother.java index 7e54e67cf3..1cd83990fd 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianVatmother.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianVatmother.java @@ -1,24 +1,17 @@ package mage.cards.p; -import java.util.UUID; - import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.common.OnEventTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.keyword.InfectAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.constants.Outcome; import mage.constants.TargetController; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.events.GameEvent.EventType; -import mage.players.Player; + +import java.util.UUID; /** * @author Viserion @@ -34,7 +27,9 @@ public final class PhyrexianVatmother extends CardImpl { this.toughness = new MageInt(5); this.addAbility(InfectAbility.getInstance()); this.addAbility(new BeginningOfUpkeepTriggeredAbility( - new AddPoisonCounterAllEffect(TargetController.YOU), TargetController.YOU, false + new AddCountersPlayersEffect( + CounterType.POISON.createInstance(), TargetController.YOU + ), TargetController.YOU, false )); } diff --git a/Mage.Sets/src/mage/cards/r/RelicPutrescence.java b/Mage.Sets/src/mage/cards/r/RelicPutrescence.java index a73e05a84e..4373e8d2ef 100644 --- a/Mage.Sets/src/mage/cards/r/RelicPutrescence.java +++ b/Mage.Sets/src/mage/cards/r/RelicPutrescence.java @@ -1,23 +1,22 @@ package mage.cards.r; -import java.util.UUID; - import mage.abilities.Ability; import mage.abilities.common.BecomesTappedAttachedTriggeredAbility; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.counter.AddCountersControllerEffect; -import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect; +import mage.abilities.effects.common.counter.AddCountersPlayersEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.TargetController; import mage.counters.CounterType; import mage.target.TargetPermanent; import mage.target.common.TargetArtifactPermanent; +import java.util.UUID; + /** * @author nantuko */ @@ -34,10 +33,9 @@ public final class RelicPutrescence extends CardImpl { this.addAbility(ability); // Whenever enchanted artifact becomes tapped, its controller gets a poison counter. - this.addAbility(new BecomesTappedAttachedTriggeredAbility( - new AddPoisonCounterAllEffect(TargetController.CONTROLLER_ATTACHED_TO), - "enchanted artifact" - )); + this.addAbility(new BecomesTappedAttachedTriggeredAbility(new AddCountersPlayersEffect( + CounterType.POISON.createInstance(), TargetController.CONTROLLER_ATTACHED_TO + ), "enchanted artifact")); } public RelicPutrescence(final RelicPutrescence card) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersControllerEffect.java deleted file mode 100644 index 270d1b8c38..0000000000 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersControllerEffect.java +++ /dev/null @@ -1,50 +0,0 @@ -package mage.abilities.effects.common.counter; - -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.constants.Outcome; -import mage.counters.Counter; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; - -import java.util.UUID; - -/** - * @author nantuko - */ -public class AddCountersControllerEffect extends OneShotEffect { - - private Counter counter; - - /** - * @param counter Counter to add. Includes type and amount. - */ - public AddCountersControllerEffect(Counter counter) { - super(Outcome.Benefit); - this.counter = counter.copy(); - staticText = "you get" + counter.getDescription(); - } - - public AddCountersControllerEffect(final AddCountersControllerEffect effect) { - super(effect); - if (effect.counter != null) { - this.counter = effect.counter.copy(); - } - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.addCounters(counter, source.getControllerId(), source, game); - return true; - } - return false; - } - - @Override - public AddCountersControllerEffect copy() { - return new AddCountersControllerEffect(this); - } -} diff --git a/Mage/src/main/java/mage/abilities/effects/common/counter/AddPoisonCounterAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java similarity index 74% rename from Mage/src/main/java/mage/abilities/effects/common/counter/AddPoisonCounterAllEffect.java rename to Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java index 844daafbcb..51ec854d7a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/counter/AddPoisonCounterAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/counter/AddCountersPlayersEffect.java @@ -1,46 +1,40 @@ package mage.abilities.effects.common.counter; import mage.abilities.Ability; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; import mage.constants.TargetController; -import mage.counters.CounterType; +import mage.counters.Counter; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.util.CardUtil; import java.util.*; /** * @author TheElk801 */ -public class AddPoisonCounterAllEffect extends OneShotEffect { +public class AddCountersPlayersEffect extends OneShotEffect { - private final int amount; + private final Counter counter; private final TargetController targetController; - public AddPoisonCounterAllEffect(TargetController targetController) { - this(1, targetController); - } - - public AddPoisonCounterAllEffect(int amount, TargetController targetController) { + public AddCountersPlayersEffect(Counter counter, TargetController targetController) { super(Outcome.Benefit); - this.amount = amount; + this.counter = counter; this.targetController = targetController; staticText = makeText(); } - private AddPoisonCounterAllEffect(final AddPoisonCounterAllEffect effect) { + private AddCountersPlayersEffect(final AddCountersPlayersEffect effect) { super(effect); - this.amount = effect.amount; + this.counter = effect.counter; this.targetController = effect.targetController; } @Override - public AddPoisonCounterAllEffect copy() { - return new AddPoisonCounterAllEffect(this); + public AddCountersPlayersEffect copy() { + return new AddCountersPlayersEffect(this); } private Collection getPlayers(Game game, Ability source) { @@ -71,7 +65,7 @@ public class AddPoisonCounterAllEffect extends OneShotEffect { for (UUID playerId : getPlayers(game, source)) { Player player = game.getPlayer(playerId); if (player != null) { - player.addCounters(CounterType.POISON.createInstance(amount), source.getControllerId(), source, game); + player.addCounters(counter, source.getControllerId(), source, game); } } return true; @@ -96,10 +90,8 @@ public class AddPoisonCounterAllEffect extends OneShotEffect { default: throw new UnsupportedOperationException(targetController + " not supported"); } - sb.append(' ' + CardUtil.numberToText(amount, "a") + " poison counter"); - if (amount > 1) { - sb.append('s'); - } + sb.append(' '); + sb.append(counter.getDescription()); return sb.toString(); } }