From a133fb348e0dd2258322f2a564f4f39d8e7b6231 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Wed, 3 Aug 2022 13:45:55 -0500 Subject: [PATCH] [NCC] Implemented Make an Example (#9337) --- Mage.Sets/src/mage/cards/m/MakeAnExample.java | 97 +++++++++++++++++++ .../src/mage/sets/NewCapennaCommander.java | 1 + 2 files changed, 98 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MakeAnExample.java diff --git a/Mage.Sets/src/mage/cards/m/MakeAnExample.java b/Mage.Sets/src/mage/cards/m/MakeAnExample.java new file mode 100644 index 00000000000..8e58ca42e0a --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MakeAnExample.java @@ -0,0 +1,97 @@ +package mage.cards.m; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.StaticFilters; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author weirddan455 + */ +public final class MakeAnExample extends CardImpl { + + public MakeAnExample(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}"); + + // Each opponent separates the creatures they control into two piles. For each opponent, you choose one of their piles. Each opponent sacrifices the creatures in their chosen pile. + this.getSpellAbility().addEffect(new MakeAnExampleEffect()); + } + + private MakeAnExample(final MakeAnExample card) { + super(card); + } + + @Override + public MakeAnExample copy() { + return new MakeAnExample(this); + } +} + +class MakeAnExampleEffect extends OneShotEffect { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creatures to put in the first pile"); + + public MakeAnExampleEffect() { + super(Outcome.Sacrifice); + this.staticText = "Each opponent separates the creatures they control into two piles. For each opponent, you choose one of their piles. Each opponent sacrifices the creatures in their chosen pile"; + } + + private MakeAnExampleEffect(final MakeAnExampleEffect effect) { + super(effect); + } + + @Override + public MakeAnExampleEffect copy() { + return new MakeAnExampleEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + UUID controllerId = source.getControllerId(); + Player controller = game.getPlayer(controllerId); + if (controller == null) { + return false; + } + List toSacrifice = new ArrayList<>(); + for (UUID opponentId : game.getOpponents(controllerId)) { + Player opponent = game.getPlayer(opponentId); + if (opponent == null) { + continue; + } + TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE, filter, true); + opponent.chooseTarget(Outcome.Sacrifice, target, source, game); + List chosenTargets = target.getTargets(); + List pile1 = new ArrayList<>(); + List pile2 = new ArrayList<>(); + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, opponentId, game)) { + if (chosenTargets.contains(permanent.getId())) { + pile1.add(permanent); + } else { + pile2.add(permanent); + } + } + if (controller.choosePile(Outcome.Sacrifice, "Choose a pile for " + opponent.getName() + " to sacrifice", pile1, pile2, game)) { + toSacrifice.addAll(pile1); + } else { + toSacrifice.addAll(pile2); + } + } + for (Permanent permanent : toSacrifice) { + permanent.sacrifice(source, game); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/NewCapennaCommander.java b/Mage.Sets/src/mage/sets/NewCapennaCommander.java index 06d161d1d53..56e9f11fa3a 100644 --- a/Mage.Sets/src/mage/sets/NewCapennaCommander.java +++ b/Mage.Sets/src/mage/sets/NewCapennaCommander.java @@ -193,6 +193,7 @@ public final class NewCapennaCommander extends ExpansionSet { cards.add(new SetCardInfo("Luminarch Aspirant", 205, Rarity.RARE, mage.cards.l.LuminarchAspirant.class)); cards.add(new SetCardInfo("Maestros Confluence", 75, Rarity.RARE, mage.cards.m.MaestrosConfluence.class)); cards.add(new SetCardInfo("Magus of the Wheel", 271, Rarity.RARE, mage.cards.m.MagusOfTheWheel.class)); + cards.add(new SetCardInfo("Make an Example", 37, Rarity.RARE, mage.cards.m.MakeAnExample.class)); cards.add(new SetCardInfo("March of the Multitudes", 346, Rarity.MYTHIC, mage.cards.m.MarchOfTheMultitudes.class)); cards.add(new SetCardInfo("Martial Coup", 206, Rarity.RARE, mage.cards.m.MartialCoup.class)); cards.add(new SetCardInfo("Mask of Riddles", 347, Rarity.UNCOMMON, mage.cards.m.MaskOfRiddles.class));