From 05c4419cdd545385ef771690b2eceec1dc76052e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 25 Apr 2022 22:03:21 -0400 Subject: [PATCH] [NCC] Implemented Change of Plans --- Mage.Sets/src/mage/cards/c/ChangeOfPlans.java | 112 ++++++++++++++++++ .../src/mage/sets/NewCapennaCommander.java | 1 + 2 files changed, 113 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ChangeOfPlans.java diff --git a/Mage.Sets/src/mage/cards/c/ChangeOfPlans.java b/Mage.Sets/src/mage/cards/c/ChangeOfPlans.java new file mode 100644 index 0000000000..4ec4a4f750 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ChangeOfPlans.java @@ -0,0 +1,112 @@ +package mage.cards.c; + +import mage.MageItem; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.keyword.ConniveSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.PermanentIdPredicate; +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.targetadjustment.TargetAdjuster; + +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class ChangeOfPlans extends CardImpl { + + public ChangeOfPlans(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{1}{U}"); + + // Each of X target creatures you control connive. You may have any number of them phase out. + this.getSpellAbility().addEffect(new ChangeOfPlansEffect()); + this.getSpellAbility().setTargetAdjuster(ChangeOfPlansAdjuster.instance); + } + + private ChangeOfPlans(final ChangeOfPlans card) { + super(card); + } + + @Override + public ChangeOfPlans copy() { + return new ChangeOfPlans(this); + } +} + +enum ChangeOfPlansAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + ability.getTargets().clear(); + ability.addTarget(new TargetControlledCreaturePermanent(ability.getManaCostsToPay().getX())); + } +} + +class ChangeOfPlansEffect extends OneShotEffect { + + ChangeOfPlansEffect() { + super(Outcome.Benefit); + staticText = "each of X target creatures you control connive. You may have any number of them phase out"; + } + + private ChangeOfPlansEffect(final ChangeOfPlansEffect effect) { + super(effect); + } + + @Override + public ChangeOfPlansEffect copy() { + return new ChangeOfPlansEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Set permanents = this + .getTargetPointer() + .getTargets(game, source) + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + if (permanents.isEmpty()) { + return false; + } + for (Permanent permanent : permanents) { + ConniveSourceEffect.connive(permanent, 1, source, game); + } + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return true; + } + FilterPermanent filter = new FilterPermanent("creatures"); + filter.add(Predicates.or( + permanents + .stream() + .map(MageItem::getId) + .map(PermanentIdPredicate::new) + .collect(Collectors.toSet()) + )); + TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); + player.choose(outcome, target.withChooseHint("to phase out"), source, game); + for (UUID targetId : target.getTargets()) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + permanent.phaseOut(game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/NewCapennaCommander.java b/Mage.Sets/src/mage/sets/NewCapennaCommander.java index 3239dc6fd9..9ca56d9d12 100644 --- a/Mage.Sets/src/mage/sets/NewCapennaCommander.java +++ b/Mage.Sets/src/mage/sets/NewCapennaCommander.java @@ -69,6 +69,7 @@ public final class NewCapennaCommander extends ExpansionSet { cards.add(new SetCardInfo("Chain Reaction", 265, Rarity.RARE, mage.cards.c.ChainReaction.class)); cards.add(new SetCardInfo("Champion of Lambholt", 284, Rarity.RARE, mage.cards.c.ChampionOfLambholt.class)); cards.add(new SetCardInfo("Champion of Wits", 213, Rarity.RARE, mage.cards.c.ChampionOfWits.class)); + cards.add(new SetCardInfo("Change of Plans", 24, Rarity.RARE, mage.cards.c.ChangeOfPlans.class)); cards.add(new SetCardInfo("Chaos Warp", 266, Rarity.RARE, mage.cards.c.ChaosWarp.class)); cards.add(new SetCardInfo("Chasm Skulker", 214, Rarity.RARE, mage.cards.c.ChasmSkulker.class)); cards.add(new SetCardInfo("Choked Estuary", 393, Rarity.RARE, mage.cards.c.ChokedEstuary.class));