From fd32d3ea47e360e93cfd3b1af623a50afaa9a440 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 5 Sep 2021 15:12:40 -0400 Subject: [PATCH] [MID] Implemented Galvanic Iteration --- .../src/mage/cards/g/GalvanicIteration.java | 83 +++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + 2 files changed, 84 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GalvanicIteration.java diff --git a/Mage.Sets/src/mage/cards/g/GalvanicIteration.java b/Mage.Sets/src/mage/cards/g/GalvanicIteration.java new file mode 100644 index 0000000000..f275674801 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GalvanicIteration.java @@ -0,0 +1,83 @@ +package mage.cards.g; + +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.CopyTargetSpellEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.keyword.FlashbackAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.TimingRule; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.stack.Spell; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GalvanicIteration extends CardImpl { + + public GalvanicIteration(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{U}{R}"); + + // When you cast your next instant or sorcery spell this turn, copy that spell. You may choose new targets for the copy. + this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new GalvanicIterationAbility())); + + // Flashback {1}{U}{R} + this.addAbility(new FlashbackAbility(new ManaCostsImpl<>("{1}{U}{R}"), TimingRule.INSTANT)); + } + + private GalvanicIteration(final GalvanicIteration card) { + super(card); + } + + @Override + public GalvanicIteration copy() { + return new GalvanicIteration(this); + } +} + +class GalvanicIterationAbility extends DelayedTriggeredAbility { + + GalvanicIterationAbility() { + super(new CopyTargetSpellEffect(true), Duration.EndOfTurn); + } + + private GalvanicIterationAbility(final GalvanicIterationAbility ability) { + super(ability); + } + + @Override + public GalvanicIterationAbility copy() { + return new GalvanicIterationAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.SPELL_CAST; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!isControlledBy(event.getPlayerId())) { + return false; + } + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell == null || !spell.isInstantOrSorcery(game)) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); + return true; + } + + @Override + public String getRule() { + return "When you cast your next instant or sorcery spell this turn, " + + "copy that spell. You may choose new targets for the copy."; + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index ca0563f5d0..5587d01783 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -48,6 +48,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Festival Crasher", 140, Rarity.COMMON, mage.cards.f.FestivalCrasher.class)); cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Foul Play", 101, Rarity.UNCOMMON, mage.cards.f.FoulPlay.class)); + cards.add(new SetCardInfo("Galvanic Iteration", 224, Rarity.RARE, mage.cards.g.GalvanicIteration.class)); cards.add(new SetCardInfo("Graveyard Glutton", 104, Rarity.RARE, mage.cards.g.GraveyardGlutton.class)); cards.add(new SetCardInfo("Graveyard Trespasser", 104, Rarity.RARE, mage.cards.g.GraveyardTrespasser.class)); cards.add(new SetCardInfo("Haunted Ridge", 263, Rarity.RARE, mage.cards.h.HauntedRidge.class));