From e006119e5d438d9666d68efc1b00d81b74b28ef3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 4 Nov 2020 20:36:59 -0500 Subject: [PATCH] [CMR] Implemented Sakashima's Will --- .../src/mage/cards/s/SakashimasWill.java | 140 ++++++++++++++++++ Mage.Sets/src/mage/sets/CommanderLegends.java | 1 + 2 files changed, 141 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SakashimasWill.java diff --git a/Mage.Sets/src/mage/cards/s/SakashimasWill.java b/Mage.Sets/src/mage/cards/s/SakashimasWill.java new file mode 100644 index 00000000000..1464c12b55c --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SakashimasWill.java @@ -0,0 +1,140 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.condition.common.ControlACommanderCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainControlTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetOpponent; +import mage.target.targetpointer.FixedTarget; +import mage.util.functions.EmptyApplyToPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SakashimasWill extends CardImpl { + + public SakashimasWill(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}"); + + // Choose one. If you control a commander as you cast this spell, you may choose both. + this.getSpellAbility().getModes().setChooseText( + "Choose one. If you control a commander as you cast this spell, you may choose both." + ); + this.getSpellAbility().getModes().setMoreCondition(ControlACommanderCondition.instance); + + // • Target opponent chooses a creature they control. You gain control of it. + this.getSpellAbility().addEffect(new SakashimasWillStealEffect()); + this.getSpellAbility().addTarget(new TargetOpponent()); + + // • Choose a creature you control. Each other creautre you control becomes a copy of that creature until end of turn. + this.getSpellAbility().addMode(new Mode(new SakashimasWillCopyEffect())); + } + + private SakashimasWill(final SakashimasWill card) { + super(card); + } + + @Override + public SakashimasWill copy() { + return new SakashimasWill(this); + } +} + +class SakashimasWillStealEffect extends OneShotEffect { + + SakashimasWillStealEffect() { + super(Outcome.Benefit); + staticText = "target opponent chooses a creature they control. You gain control of it"; + } + + private SakashimasWillStealEffect(final SakashimasWillStealEffect effect) { + super(effect); + } + + @Override + public SakashimasWillStealEffect copy() { + return new SakashimasWillStealEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + TargetPermanent target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + return false; + } + player.choose(outcome, target, source.getSourceId(), game); + if (game.getPermanent(target.getFirstTarget()) == null) { + return false; + } + game.addEffect(new GainControlTargetEffect( + Duration.Custom, true, source.getControllerId() + ).setTargetPointer(new FixedTarget(target.getFirstTarget(), game)), source); + return true; + } +} + +class SakashimasWillCopyEffect extends OneShotEffect { + + SakashimasWillCopyEffect() { + super(Outcome.Benefit); + staticText = "choose a creature you control. Each other creautre you control becomes a copy of that creature until end of turn"; + } + + private SakashimasWillCopyEffect(final SakashimasWillCopyEffect effect) { + super(effect); + } + + @Override + public SakashimasWillCopyEffect copy() { + return new SakashimasWillCopyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetPermanent target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + if (!target.canChoose(source.getSourceId(), player.getId(), game)) { + return false; + } + player.choose(outcome, target, source.getSourceId(), game); + Permanent chosenCreature = game.getPermanent(target.getFirstTarget()); + if (chosenCreature == null) { + return false; + } + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + player.getId(), source.getSourceId(), game + )) { + if (permanent == null || permanent.getId().equals(chosenCreature.getId())) { + continue; + } + game.copyPermanent( + Duration.EndOfTurn, chosenCreature, permanent.getId(), source, new EmptyApplyToPermanent() + ); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index e8b2f2adcfa..c62ab6dd718 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -222,6 +222,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Run Away Together", 87, Rarity.COMMON, mage.cards.r.RunAwayTogether.class)); cards.add(new SetCardInfo("Sakashima of a Thousand Faces", 89, Rarity.MYTHIC, mage.cards.s.SakashimaOfAThousandFaces.class)); cards.add(new SetCardInfo("Sakashima's Protege", 90, Rarity.RARE, mage.cards.s.SakashimasProtege.class)); + cards.add(new SetCardInfo("Sakashima's Will", 91, Rarity.RARE, mage.cards.s.SakashimasWill.class)); cards.add(new SetCardInfo("Sandstone Oracle", 336, Rarity.UNCOMMON, mage.cards.s.SandstoneOracle.class)); cards.add(new SetCardInfo("Sanitarium Skeleton", 148, Rarity.COMMON, mage.cards.s.SanitariumSkeleton.class)); cards.add(new SetCardInfo("Scholar of the Ages", 93, Rarity.UNCOMMON, mage.cards.s.ScholarOfTheAges.class));