From 994f1d43ace4c57869e470a519b6bfe8525f54a4 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 25 Apr 2022 09:37:19 -0400 Subject: [PATCH] [NCC] Implemented Waste Management --- .../src/mage/cards/w/WasteManagement.java | 108 ++++++++++++++++++ .../src/mage/sets/NewCapennaCommander.java | 1 + 2 files changed, 109 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WasteManagement.java diff --git a/Mage.Sets/src/mage/cards/w/WasteManagement.java b/Mage.Sets/src/mage/cards/w/WasteManagement.java new file mode 100644 index 0000000000..87cb8b3c61 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WasteManagement.java @@ -0,0 +1,108 @@ +package mage.cards.w; + +import mage.abilities.Ability; +import mage.abilities.condition.common.KickedCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.KickerAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.token.RogueToken; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetCardInASingleGraveyard; +import mage.target.targetadjustment.TargetAdjuster; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WasteManagement extends CardImpl { + + public WasteManagement(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{B}"); + + // Kicker {3}{B} + this.addAbility(new KickerAbility("{3}{B}")); + + // Exile up to two target cards from a single graveyard. If this spell was kicked, instead exile target player's graveyard. Create a 2/2 black Rogue creature token for each creature card exiled this way. + this.getSpellAbility().addEffect(new WasteManagementEffect()); + this.getSpellAbility().setTargetAdjuster(WasteManagementAdjuster.instance); + } + + private WasteManagement(final WasteManagement card) { + super(card); + } + + @Override + public WasteManagement copy() { + return new WasteManagement(this); + } +} + +enum WasteManagementAdjuster implements TargetAdjuster { + instance; + + @Override + public void adjustTargets(Ability ability, Game game) { + ability.getTargets().clear(); + if (KickedCondition.instance.apply(game, ability)) { + ability.addTarget(new TargetPlayer()); + } else { + ability.addTarget(new TargetCardInASingleGraveyard(0, 2, StaticFilters.FILTER_CARD)); + } + } +} + +class WasteManagementEffect extends OneShotEffect { + + WasteManagementEffect() { + super(Outcome.Benefit); + staticText = "exile up to two target cards from a single graveyard. " + + "If this spell was kicked, instead exile target player's graveyard. " + + "Create a 2/2 black Rogue creature token for each creature card exiled this way"; + } + + private WasteManagementEffect(final WasteManagementEffect effect) { + super(effect); + } + + @Override + public WasteManagementEffect copy() { + return new WasteManagementEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Cards cards = new CardsImpl(); + if (KickedCondition.instance.apply(game, source)) { + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); + if (player != null) { + cards.addAll(player.getGraveyard()); + } + } else { + cards.addAll(getTargetPointer().getTargets(game, source)); + } + if (cards.isEmpty()) { + return false; + } + controller.moveCards(cards, Zone.EXILED, source, game); + cards.retainZone(Zone.EXILED, game); + int count = cards.count(StaticFilters.FILTER_CARD_CREATURE, game); + if (count > 0) { + new RogueToken().putOntoBattlefield(count, game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/NewCapennaCommander.java b/Mage.Sets/src/mage/sets/NewCapennaCommander.java index 24474cde77..7351ec279d 100644 --- a/Mage.Sets/src/mage/sets/NewCapennaCommander.java +++ b/Mage.Sets/src/mage/sets/NewCapennaCommander.java @@ -287,6 +287,7 @@ public final class NewCapennaCommander extends ExpansionSet { cards.add(new SetCardInfo("Vorel of the Hull Clade", 357, Rarity.RARE, mage.cards.v.VorelOfTheHullClade.class)); cards.add(new SetCardInfo("Wall of Roots", 319, Rarity.COMMON, mage.cards.w.WallOfRoots.class)); cards.add(new SetCardInfo("Warstorm Surge", 277, Rarity.RARE, mage.cards.w.WarstormSurge.class)); + cards.add(new SetCardInfo("Waste Management", 40, Rarity.RARE, mage.cards.w.WasteManagement.class)); cards.add(new SetCardInfo("Wayfarer's Bauble", 384, Rarity.COMMON, mage.cards.w.WayfarersBauble.class)); cards.add(new SetCardInfo("Whirler Rogue", 238, Rarity.UNCOMMON, mage.cards.w.WhirlerRogue.class)); cards.add(new SetCardInfo("Wickerbough Elder", 320, Rarity.COMMON, mage.cards.w.WickerboughElder.class));