From 80b3e282a764a7281513a264ea0e60f8940cc2f6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 1 Jun 2022 21:49:42 -0400 Subject: [PATCH] [CLB] Implemented Split the Spoils --- .../src/mage/cards/s/SplitTheSpoils.java | 96 +++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 97 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/s/SplitTheSpoils.java diff --git a/Mage.Sets/src/mage/cards/s/SplitTheSpoils.java b/Mage.Sets/src/mage/cards/s/SplitTheSpoils.java new file mode 100644 index 00000000000..5a7a715184e --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SplitTheSpoils.java @@ -0,0 +1,96 @@ +package mage.cards.s; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInYourGraveyard; +import mage.target.common.TargetOpponent; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SplitTheSpoils extends CardImpl { + + public SplitTheSpoils(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}"); + + // Exile up to five target permanent cards from your graveyard and separate them into two piles. An opponent chooses one of those piles. Put that pile into your hand and the other into your graveyard. + this.getSpellAbility().addEffect(new SplitTheSpoilsEffect()); + this.getSpellAbility().addTarget(new TargetCardInYourGraveyard( + 0, 5, StaticFilters.FILTER_CARD_PERMANENT + )); + } + + private SplitTheSpoils(final SplitTheSpoils card) { + super(card); + } + + @Override + public SplitTheSpoils copy() { + return new SplitTheSpoils(this); + } +} + +class SplitTheSpoilsEffect extends OneShotEffect { + + SplitTheSpoilsEffect() { + super(Outcome.Benefit); + staticText = "exile up to five target permanent cards from your graveyard and separate them into two piles. " + + "An opponent chooses one of those piles. Put that pile into your hand and the other into your graveyard"; + } + + private SplitTheSpoilsEffect(final SplitTheSpoilsEffect effect) { + super(effect); + } + + @Override + public SplitTheSpoilsEffect copy() { + return new SplitTheSpoilsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source)); + if (player == null || cards.isEmpty()) { + return false; + } + player.moveCards(cards, Zone.EXILED, source, game); + TargetCard target = new TargetCardInYourGraveyard(0, 5); + target.withChooseHint("To put in pile 1").setNotTarget(true); + player.choose(outcome, cards, target, game); + List pile1 = new ArrayList<>(); + target.getTargets() + .stream() + .map(game::getCard) + .filter(Objects::nonNull) + .forEach(pile1::add); + List pile2 = new ArrayList<>(); + cards.removeIf(target.getTargets()::contains); + pile2.addAll(cards.getCards(game)); + TargetOpponent targetOpponent = new TargetOpponent(); + targetOpponent.setNotTarget(true); + if (game.getPlayer(targetOpponent.getFirstTarget()).choosePile( + outcome, "Choose a pile to go to hand (the other goes to graveyard)", pile1, pile2, game + )) { + player.moveCards(new CardsImpl(pile1), Zone.HAND, source, game); + player.moveCards(new CardsImpl(pile2), Zone.GRAVEYARD, source, game); + } else { + player.moveCards(new CardsImpl(pile2), Zone.HAND, source, game); + player.moveCards(new CardsImpl(pile1), Zone.GRAVEYARD, source, game); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index b6c23a58e00..a042b5d8412 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -287,6 +287,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Solemn Doomguide", 672, Rarity.RARE, mage.cards.s.SolemnDoomguide.class)); cards.add(new SetCardInfo("Spectacular Showdown", 679, Rarity.RARE, mage.cards.s.SpectacularShowdown.class)); cards.add(new SetCardInfo("Spire Garden", 361, Rarity.RARE, mage.cards.s.SpireGarden.class)); + cards.add(new SetCardInfo("Split the Spoils", 257, Rarity.UNCOMMON, mage.cards.s.SplitTheSpoils.class)); cards.add(new SetCardInfo("Steadfast Unicorn", 44, Rarity.COMMON, mage.cards.s.SteadfastUnicorn.class)); cards.add(new SetCardInfo("Stick Together", 661, Rarity.RARE, mage.cards.s.StickTogether.class)); cards.add(new SetCardInfo("Stirge", 150, Rarity.COMMON, mage.cards.s.Stirge.class));