From d5aabe4e9d0b9bf1eac83885c844d11dd4ec23cd Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 1 Sep 2019 14:01:25 -0400 Subject: [PATCH] Implemented Sudden Substitution --- .../src/mage/cards/s/SuddenSubstitution.java | 82 +++++++++++++++++++ .../src/mage/sets/Commander2019Edition.java | 1 + 2 files changed, 83 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SuddenSubstitution.java diff --git a/Mage.Sets/src/mage/cards/s/SuddenSubstitution.java b/Mage.Sets/src/mage/cards/s/SuddenSubstitution.java new file mode 100644 index 0000000000..a6deb99443 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SuddenSubstitution.java @@ -0,0 +1,82 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.abilities.keyword.SplitSecondAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.Spell; +import mage.target.TargetSpell; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +import static mage.constants.Outcome.Benefit; + +/** + * @author TheElk801 + */ +public final class SuddenSubstitution extends CardImpl { + + public SuddenSubstitution(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); + + // Split second + this.addAbility(new SplitSecondAbility()); + + // Exchange control of target noncreature spell and target creature. Then the spell's controller may choose new targets for it. + this.getSpellAbility().addEffect(new SuddenSubstitutionEffect()); + this.getSpellAbility().addTarget(new TargetSpell(StaticFilters.FILTER_SPELL_NON_CREATURE)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + private SuddenSubstitution(final SuddenSubstitution card) { + super(card); + } + + @Override + public SuddenSubstitution copy() { + return new SuddenSubstitution(this); + } +} + +class SuddenSubstitutionEffect extends OneShotEffect { + + SuddenSubstitutionEffect() { + super(Benefit); + staticText = "Exchange control of target noncreature spell and target creature. " + + "Then the spell's controller may choose new targets for it."; + } + + private SuddenSubstitutionEffect(final SuddenSubstitutionEffect effect) { + super(effect); + } + + @Override + public SuddenSubstitutionEffect copy() { + return new SuddenSubstitutionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Spell spell = game.getSpell(source.getTargets().get(0).getFirstTarget()); + Permanent creature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); + if (spell == null || creature == null) { + return false; + } + ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, spell.getControllerId()); + effect.setTargetPointer(new FixedTarget(creature, game)); + spell.setControllerId(creature.getControllerId()); + spell.chooseNewTargets(game, creature.getControllerId()); + game.addEffect(effect, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Commander2019Edition.java b/Mage.Sets/src/mage/sets/Commander2019Edition.java index 2d47a00991..d0e7cbe443 100644 --- a/Mage.Sets/src/mage/sets/Commander2019Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2019Edition.java @@ -259,6 +259,7 @@ public final class Commander2019Edition extends ExpansionSet { cards.add(new SetCardInfo("Stratus Dancer", 96, Rarity.RARE, mage.cards.s.StratusDancer.class)); cards.add(new SetCardInfo("Strionic Resonator", 224, Rarity.RARE, mage.cards.s.StrionicResonator.class)); cards.add(new SetCardInfo("Stromkirk Occultist", 153, Rarity.RARE, mage.cards.s.StromkirkOccultist.class)); + cards.add(new SetCardInfo("Sudden Substitution", 11, Rarity.RARE, mage.cards.s.SuddenSubstitution.class)); cards.add(new SetCardInfo("Sultai Charm", 202, Rarity.UNCOMMON, mage.cards.s.SultaiCharm.class)); cards.add(new SetCardInfo("Sun Titan", 76, Rarity.MYTHIC, mage.cards.s.SunTitan.class)); cards.add(new SetCardInfo("Sundering Growth", 203, Rarity.COMMON, mage.cards.s.SunderingGrowth.class));