From 690e042b364e744c00c31181c93d85cfcd70254e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 5 Jan 2020 21:55:44 -0500 Subject: [PATCH] Implemented Arena Trickster --- .../src/mage/cards/a/ArenaTrickster.java | 41 +++++++++++++ .../src/mage/cards/s/StingingLionfish.java | 58 +++---------------- .../src/mage/cards/w/WavebreakHippocamp.java | 52 ++--------------- .../src/mage/sets/TherosBeyondDeath.java | 1 + ...rstSpellOpponentsTurnTriggeredAbility.java | 50 ++++++++++++++++ 5 files changed, 104 insertions(+), 98 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/ArenaTrickster.java create mode 100644 Mage/src/main/java/mage/abilities/common/FirstSpellOpponentsTurnTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/a/ArenaTrickster.java b/Mage.Sets/src/mage/cards/a/ArenaTrickster.java new file mode 100644 index 0000000000..6204999c1c --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/ArenaTrickster.java @@ -0,0 +1,41 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.common.FirstSpellOpponentsTurnTriggeredAbility; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.counters.CounterType; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ArenaTrickster extends CardImpl { + + public ArenaTrickster(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SHAMAN); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Whenever you cast your first spell during each opponent's turn, put a +1/+1 counter on Arena Trickster. + this.addAbility(new FirstSpellOpponentsTurnTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false + )); + } + + private ArenaTrickster(final ArenaTrickster card) { + super(card); + } + + @Override + public ArenaTrickster copy() { + return new ArenaTrickster(this); + } +} diff --git a/Mage.Sets/src/mage/cards/s/StingingLionfish.java b/Mage.Sets/src/mage/cards/s/StingingLionfish.java index 4a885ea730..448356bc00 100644 --- a/Mage.Sets/src/mage/cards/s/StingingLionfish.java +++ b/Mage.Sets/src/mage/cards/s/StingingLionfish.java @@ -1,19 +1,15 @@ package mage.cards.s; import mage.MageInt; -import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.Ability; +import mage.abilities.common.FirstSpellOpponentsTurnTriggeredAbility; import mage.abilities.effects.common.MayTapOrUntapTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; -import mage.target.common.TargetNonlandPermanent; -import mage.watchers.common.SpellsCastWatcher; +import mage.target.TargetPermanent; -import java.util.List; import java.util.UUID; /** @@ -29,7 +25,11 @@ public final class StingingLionfish extends CardImpl { this.toughness = new MageInt(1); // Whenever you cast your first spell during each opponent's turn, you may tap or untap target nonland permanent. - this.addAbility(new StingingLionfishTriggeredAbility(), new SpellsCastWatcher()); + Ability ability = new FirstSpellOpponentsTurnTriggeredAbility( + new MayTapOrUntapTargetEffect(), false + ); + ability.addTarget(new TargetPermanent()); + this.addAbility(ability); } private StingingLionfish(final StingingLionfish card) { @@ -41,45 +41,3 @@ public final class StingingLionfish extends CardImpl { return new StingingLionfish(this); } } - -class StingingLionfishTriggeredAbility extends SpellCastControllerTriggeredAbility { - - StingingLionfishTriggeredAbility() { - super(new MayTapOrUntapTargetEffect(), false); - this.addTarget(new TargetNonlandPermanent()); - } - - private StingingLionfishTriggeredAbility(StingingLionfishTriggeredAbility ability) { - super(ability); - } - - @Override - public StingingLionfishTriggeredAbility copy() { - return new StingingLionfishTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (game.getActivePlayerId().equals(this.getControllerId()) // ignore controller turn - || !super.checkTrigger(event, game)) { - return false; - } - - if (!game.getOpponents(this.getControllerId()).contains(game.getActivePlayerId())) { - return false; - } - - SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); - if (watcher == null) { - return false; - } - - List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); - return spells != null && spells.size() == 1; - } - - @Override - public String getRule() { - return "Whenever you cast your first spell during each opponent's turn, you mat tap or untap target permanent."; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/w/WavebreakHippocamp.java b/Mage.Sets/src/mage/cards/w/WavebreakHippocamp.java index f245d20d59..8985a23646 100644 --- a/Mage.Sets/src/mage/cards/w/WavebreakHippocamp.java +++ b/Mage.Sets/src/mage/cards/w/WavebreakHippocamp.java @@ -1,18 +1,13 @@ package mage.cards.w; import mage.MageInt; -import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.common.FirstSpellOpponentsTurnTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.stack.Spell; -import mage.watchers.common.SpellsCastWatcher; -import java.util.List; import java.util.UUID; /** @@ -29,7 +24,9 @@ public final class WavebreakHippocamp extends CardImpl { this.toughness = new MageInt(2); // Whenever you cast your first spell during each opponent's turn, draw a card. - this.addAbility(new WavebreakHippocampTriggeredAbility(), new SpellsCastWatcher()); + this.addAbility(new FirstSpellOpponentsTurnTriggeredAbility( + new DrawCardSourceControllerEffect(1), false + )); } private WavebreakHippocamp(final WavebreakHippocamp card) { @@ -41,44 +38,3 @@ public final class WavebreakHippocamp extends CardImpl { return new WavebreakHippocamp(this); } } - -class WavebreakHippocampTriggeredAbility extends SpellCastControllerTriggeredAbility { - - WavebreakHippocampTriggeredAbility() { - super(new DrawCardSourceControllerEffect(1), false); - } - - private WavebreakHippocampTriggeredAbility(WavebreakHippocampTriggeredAbility ability) { - super(ability); - } - - @Override - public WavebreakHippocampTriggeredAbility copy() { - return new WavebreakHippocampTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (game.getActivePlayerId().equals(this.getControllerId()) // ignore controller turn - || !super.checkTrigger(event, game)) { - return false; - } - - if (!game.getOpponents(this.getControllerId()).contains(game.getActivePlayerId())) { - return false; - } - - SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); - if (watcher == null) { - return false; - } - - List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); - return spells != null && spells.size() == 1; - } - - @Override - public String getRule() { - return "Whenever you cast your first spell during each opponent's turn, draw a card."; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index 7662bc9acc..b3e0b4de92 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -30,6 +30,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Aphemia, the Cacophony", 84, Rarity.RARE, mage.cards.a.AphemiaTheCacophony.class)); cards.add(new SetCardInfo("Arasta of the Endless Web", 165, Rarity.RARE, mage.cards.a.ArastaOfTheEndlessWeb.class)); cards.add(new SetCardInfo("Archon of Falling Stars", 2, Rarity.UNCOMMON, mage.cards.a.ArchonOfFallingStars.class)); + cards.add(new SetCardInfo("Arena Trickster", 126, Rarity.COMMON, mage.cards.a.ArenaTrickster.class)); cards.add(new SetCardInfo("Ashiok's Erasure", 43, Rarity.RARE, mage.cards.a.AshioksErasure.class)); cards.add(new SetCardInfo("Ashiok, Nightmare Muse", 208, Rarity.MYTHIC, mage.cards.a.AshiokNightmareMuse.class)); cards.add(new SetCardInfo("Ashiok, Sculptor of Fears", 274, Rarity.MYTHIC, mage.cards.a.AshiokSculptorOfFears.class)); diff --git a/Mage/src/main/java/mage/abilities/common/FirstSpellOpponentsTurnTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/FirstSpellOpponentsTurnTriggeredAbility.java new file mode 100644 index 0000000000..84aef8d67f --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/FirstSpellOpponentsTurnTriggeredAbility.java @@ -0,0 +1,50 @@ +package mage.abilities.common; + +import mage.abilities.effects.Effect; +import mage.filter.FilterSpell; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.watchers.common.SpellsCastWatcher; + +import java.util.List; + +/** + * @author TheElk801 + */ +public class FirstSpellOpponentsTurnTriggeredAbility extends SpellCastControllerTriggeredAbility { + + private static final FilterSpell defaultFilter + = new FilterSpell("your first spell during each opponent's turn"); + + public FirstSpellOpponentsTurnTriggeredAbility(Effect effect, boolean optional) { + super(effect, defaultFilter, optional); + this.addWatcher(new SpellsCastWatcher()); + } + + private FirstSpellOpponentsTurnTriggeredAbility(final FirstSpellOpponentsTurnTriggeredAbility ability) { + super(ability); + } + + @Override + public FirstSpellOpponentsTurnTriggeredAbility copy() { + return new FirstSpellOpponentsTurnTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (game.isActivePlayer(this.getControllerId()) // ignore controller turn + || !super.checkTrigger(event, game) + || !game.getOpponents(this.getControllerId()).contains(game.getActivePlayerId())) { + return false; + } + + SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class); + if (watcher == null) { + return false; + } + + List spells = watcher.getSpellsCastThisTurn(event.getPlayerId()); + return spells != null && spells.size() == 1; + } +}