From 764bc096cdbbccf2447df90d4010b6336f066468 Mon Sep 17 00:00:00 2001 From: PurpleCrowbar <26198472+PurpleCrowbar@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:54:49 +0100 Subject: [PATCH] Refactor self-suspend cards (#11317) --- Mage.Sets/src/mage/cards/a/ArcBlade.java | 18 ++----- .../src/mage/cards/c/ChronomanticEscape.java | 15 ++---- .../src/mage/cards/c/CyclicalEvolution.java | 14 ++--- .../src/mage/cards/f/FesteringMarch.java | 18 ++----- .../src/mage/cards/i/InspiringRefrain.java | 10 +--- Mage.Sets/src/mage/cards/r/RealityStrobe.java | 19 ++----- .../src/mage/cards/r/RousingRefrain.java | 12 ++--- Mage.Sets/src/mage/cards/v/VentureForth.java | 10 +--- .../ExileSpellWithTimeCountersEffect.java | 52 +++++++++++++++++++ 9 files changed, 77 insertions(+), 91 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/effects/common/ExileSpellWithTimeCountersEffect.java diff --git a/Mage.Sets/src/mage/cards/a/ArcBlade.java b/Mage.Sets/src/mage/cards/a/ArcBlade.java index 9944aea415d..fbc0c70f375 100644 --- a/Mage.Sets/src/mage/cards/a/ArcBlade.java +++ b/Mage.Sets/src/mage/cards/a/ArcBlade.java @@ -1,18 +1,13 @@ - package mage.cards.a; import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.ExileSpellEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.counters.CounterType; import mage.target.common.TargetAnyTarget; /** @@ -24,17 +19,12 @@ public final class ArcBlade extends CardImpl { public ArcBlade(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{R}{R}"); - // Arc Blade deals 2 damage to any target. + // Arc Blade deals 2 damage to any target. Exile Arc Blade with three time counters on it. this.getSpellAbility().addEffect(new DamageTargetEffect(2)); - // Exile Arc Blade - this.getSpellAbility().addEffect(new ExileSpellEffect()); - // with three time counters on it. - Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), StaticValue.get(3), false, true); - effect.setText("with three time counters on it"); - this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetAnyTarget()); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); - // Suspend 3-{2}{R} + // Suspend 3—{2}{R} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{R}"), this)); } diff --git a/Mage.Sets/src/mage/cards/c/ChronomanticEscape.java b/Mage.Sets/src/mage/cards/c/ChronomanticEscape.java index efbc5e9d664..c00746e3ffd 100644 --- a/Mage.Sets/src/mage/cards/c/ChronomanticEscape.java +++ b/Mage.Sets/src/mage/cards/c/ChronomanticEscape.java @@ -1,19 +1,14 @@ - package mage.cards.c; import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.effects.common.combat.CantAttackYouAllEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.counters.CounterType; import mage.filter.StaticFilters; /** @@ -22,18 +17,14 @@ import mage.filter.StaticFilters; */ public final class ChronomanticEscape extends CardImpl { - public ChronomanticEscape(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}{W}"); // Until your next turn, creatures can't attack you. Exile Chronomantic Escape with three time counters on it. getSpellAbility().addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, StaticFilters.FILTER_PERMANENT_CREATURES)); - getSpellAbility().addEffect(new ExileSpellEffect()); - Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), StaticValue.get(3), true, true); - effect.setText("with three time counters on it"); - getSpellAbility().addEffect(effect); + getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); - // Suspend 3-{2}{W} + // Suspend 3—{2}{W} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{W}"), this)); } diff --git a/Mage.Sets/src/mage/cards/c/CyclicalEvolution.java b/Mage.Sets/src/mage/cards/c/CyclicalEvolution.java index daf7599d142..94d9af03000 100644 --- a/Mage.Sets/src/mage/cards/c/CyclicalEvolution.java +++ b/Mage.Sets/src/mage/cards/c/CyclicalEvolution.java @@ -1,19 +1,14 @@ - package mage.cards.c; import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.counters.CounterType; import mage.target.common.TargetCreaturePermanent; /** @@ -28,12 +23,9 @@ public final class CyclicalEvolution extends CardImpl { // Target creature gets +3/+3 until end of turn. Exile Cyclical Evolution with three time counters on it. getSpellAbility().addEffect(new BoostTargetEffect(3, 3, Duration.EndOfTurn)); getSpellAbility().addTarget(new TargetCreaturePermanent()); - getSpellAbility().addEffect(new ExileSpellEffect()); - Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), StaticValue.get(3), true, true); - effect.setText("with three time counters on it"); - getSpellAbility().addEffect(effect); + getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); - // Suspend 3-{2}{G} + // Suspend 3—{2}{G} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{G}"), this)); } diff --git a/Mage.Sets/src/mage/cards/f/FesteringMarch.java b/Mage.Sets/src/mage/cards/f/FesteringMarch.java index 09567b45d77..edef1489665 100644 --- a/Mage.Sets/src/mage/cards/f/FesteringMarch.java +++ b/Mage.Sets/src/mage/cards/f/FesteringMarch.java @@ -1,19 +1,14 @@ - package mage.cards.f; import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.effects.common.continuous.BoostOpponentsEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; -import mage.counters.CounterType; /** * @@ -24,16 +19,11 @@ public final class FesteringMarch extends CardImpl { public FesteringMarch(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); - // Creatures your opponents control get -1/-1 until end of turn. + // Creatures your opponents control get -1/-1 until end of turn. Exile Festering March with three time counters on it. this.getSpellAbility().addEffect(new BoostOpponentsEffect(-1, -1, Duration.EndOfTurn)); - // Exile Festering March - this.getSpellAbility().addEffect(new ExileSpellEffect()); - // with three time counters on it. - Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), StaticValue.get(3), false, true); - effect.setText("with three time counters on it"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); - // Suspend 3-{2}{B} + // Suspend 3—{2}{B} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{B}"), this)); } diff --git a/Mage.Sets/src/mage/cards/i/InspiringRefrain.java b/Mage.Sets/src/mage/cards/i/InspiringRefrain.java index c93c4784771..1bb921d62a9 100644 --- a/Mage.Sets/src/mage/cards/i/InspiringRefrain.java +++ b/Mage.Sets/src/mage/cards/i/InspiringRefrain.java @@ -1,15 +1,12 @@ package mage.cards.i; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.effects.common.ExileSpellEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.counters.CounterType; import java.util.UUID; @@ -23,10 +20,7 @@ public final class InspiringRefrain extends CardImpl { // Draw two cards. Exile Inspiring Refrain with three time counters on it. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(2)); - this.getSpellAbility().addEffect(new ExileSpellEffect()); - this.getSpellAbility().addEffect(new AddCountersSourceEffect( - CounterType.TIME.createInstance(), StaticValue.get(3), false, true - ).setText("with three time counters on it")); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); // Suspend 3—{2}{U} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{U}"), this)); diff --git a/Mage.Sets/src/mage/cards/r/RealityStrobe.java b/Mage.Sets/src/mage/cards/r/RealityStrobe.java index 9190b70a70c..4cd0eb4b580 100644 --- a/Mage.Sets/src/mage/cards/r/RealityStrobe.java +++ b/Mage.Sets/src/mage/cards/r/RealityStrobe.java @@ -1,18 +1,13 @@ - package mage.cards.r; import java.util.UUID; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.counters.CounterType; import mage.target.TargetPermanent; /** @@ -24,18 +19,12 @@ public final class RealityStrobe extends CardImpl { public RealityStrobe(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); - - // Return target permanent to its owner's hand. + // Return target permanent to its owner's hand. Exile Reality Strobe with three time counters on it. this.getSpellAbility().addEffect(new ReturnToHandTargetEffect()); - // Exile Reality Strobe - this.getSpellAbility().addEffect(new ExileSpellEffect()); - // with three time counters on it. - Effect effect = new AddCountersSourceEffect(CounterType.TIME.createInstance(), StaticValue.get(3), false, true); - effect.setText("with three time counters on it"); - this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetPermanent()); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); - // Suspend 3-{2}{U} + // Suspend 3—{2}{U} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{2}{U}"), this)); } diff --git a/Mage.Sets/src/mage/cards/r/RousingRefrain.java b/Mage.Sets/src/mage/cards/r/RousingRefrain.java index 95850251d72..83f42ae5b81 100644 --- a/Mage.Sets/src/mage/cards/r/RousingRefrain.java +++ b/Mage.Sets/src/mage/cards/r/RousingRefrain.java @@ -3,17 +3,14 @@ package mage.cards.r; import mage.Mana; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.ExileSpellEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.ManaType; import mage.constants.Outcome; -import mage.counters.CounterType; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetOpponent; @@ -30,11 +27,8 @@ public final class RousingRefrain extends CardImpl { // Add {R} for each card in target opponent's hand. Until end of turn, you don't lose this mana as steps and phases end. Exile Rousing Refrain with three time counters on it. this.getSpellAbility().addEffect(new RousingRefrainEffect()); - this.getSpellAbility().addEffect(new ExileSpellEffect()); - this.getSpellAbility().addEffect(new AddCountersSourceEffect( - CounterType.TIME.createInstance(), StaticValue.get(3), false, true - ).setText("with three time counters on it")); this.getSpellAbility().addTarget(new TargetOpponent()); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); // Suspend 3—{1}{R} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{1}{R}"), this)); @@ -80,4 +74,4 @@ class RousingRefrainEffect extends OneShotEffect { ); return true; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/v/VentureForth.java b/Mage.Sets/src/mage/cards/v/VentureForth.java index b22a9be2b73..87de4cbd903 100644 --- a/Mage.Sets/src/mage/cards/v/VentureForth.java +++ b/Mage.Sets/src/mage/cards/v/VentureForth.java @@ -2,16 +2,13 @@ package mage.cards.v; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.ExileSpellEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.ExileSpellWithTimeCountersEffect; import mage.abilities.keyword.SuspendAbility; import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; -import mage.counters.CounterType; import mage.game.Game; import mage.players.Player; @@ -27,10 +24,7 @@ public final class VentureForth extends CardImpl { // Exile cards from the top of your library until you exile a land card. Put that onto the battlefield and the rest on the bottom of your library in a random order. Exile Venture Forth with three time counters on it. this.getSpellAbility().addEffect(new VentureForthEffect()); - this.getSpellAbility().addEffect(new ExileSpellEffect()); - this.getSpellAbility().addEffect(new AddCountersSourceEffect( - CounterType.TIME.createInstance(), StaticValue.get(3), false, true - ).setText("with three time counters on it")); + this.getSpellAbility().addEffect(new ExileSpellWithTimeCountersEffect(3)); // Suspend 3—{1}{G} this.addAbility(new SuspendAbility(3, new ManaCostsImpl<>("{1}{G}"), this)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileSpellWithTimeCountersEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileSpellWithTimeCountersEffect.java new file mode 100644 index 00000000000..49d882f42b5 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileSpellWithTimeCountersEffect.java @@ -0,0 +1,52 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.SuspendAbility; +import mage.cards.Card; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author PurpleCrowbar + */ +public class ExileSpellWithTimeCountersEffect extends OneShotEffect { + + private final int counters; + + public ExileSpellWithTimeCountersEffect(int counters) { + super(Outcome.Exile); + this.counters = counters; + this.staticText = "Exile {this} with " + CardUtil.numberToText(this.counters) + " time counters on it"; + } + + private ExileSpellWithTimeCountersEffect(final ExileSpellWithTimeCountersEffect effect) { + super(effect); + this.counters = effect.counters; + } + + @Override + public ExileSpellWithTimeCountersEffect copy() { + return new ExileSpellWithTimeCountersEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Card card = game.getStack().getSpell(source.getId()).getCard(); + if (controller == null || card == null) { + return true; + } + UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game); + if (!card.isCopy() && controller.moveCardsToExile(card, source, game, true, exileId, "Suspended cards of " + controller.getName())) { + card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game); + game.informPlayers(controller.getLogName() + " exiles " + card.getLogName() + " with " + counters + " time counters on it"); + } + return true; + } +}