From 7db4b1a2e68fb4337820bdacf421cc1cb4e922d9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 16 Apr 2018 09:22:54 -0400 Subject: [PATCH] Implemented Final Parting --- Mage.Sets/src/mage/cards/f/FinalParting.java | 125 +++++++++++++++++++ Mage.Sets/src/mage/sets/Dominaria.java | 1 + 2 files changed, 126 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FinalParting.java diff --git a/Mage.Sets/src/mage/cards/f/FinalParting.java b/Mage.Sets/src/mage/cards/f/FinalParting.java new file mode 100644 index 0000000000..33583cda95 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FinalParting.java @@ -0,0 +1,125 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.cards.f; + +import java.util.List; +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +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.FilterCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInLibrary; + +/** + * + * @author TheElk801 + */ +public class FinalParting extends CardImpl { + + public FinalParting(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); + + // Search your library for two cards. Put one into your hand and the other into your graveyard. Then shuffle your library. + this.getSpellAbility().addEffect(new FinalPartingEffect()); + } + + public FinalParting(final FinalParting card) { + super(card); + } + + @Override + public FinalParting copy() { + return new FinalParting(this); + } +} + +class FinalPartingEffect extends OneShotEffect { + + protected static final FilterCard filter = new FilterCard("card to put into your hand"); + + public FinalPartingEffect() { + super(Outcome.PutLandInPlay); + staticText = "Search your library for two cards. Put one into your hand and the other into your graveyard. Then shuffle your library"; + } + + public FinalPartingEffect(final FinalPartingEffect effect) { + super(effect); + } + + @Override + public FinalPartingEffect copy() { + return new FinalPartingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + // Unlike Jarad's Orders, which this mostly copies, you can't fail to find + TargetCardInLibrary target = new TargetCardInLibrary(2, 2, new FilterCard()); + if (controller.searchLibrary(target, game)) { + if (!target.getTargets().isEmpty()) { + Cards searched = new CardsImpl(); + for (UUID cardId : (List) target.getTargets()) { + Card card = controller.getLibrary().getCard(cardId, game); + searched.add(card); + } + if (target.getTargets().size() == 2) { + TargetCard target2 = new TargetCard(Zone.LIBRARY, filter); + controller.choose(Outcome.Benefit, searched, target2, game); + Card card = searched.get(target2.getFirstTarget(), game); + controller.moveCards(card, Zone.HAND, source, game); + searched.remove(card); + card = searched.getCards(game).iterator().next(); + controller.moveCards(card, Zone.GRAVEYARD, source, game); + } else if (target.getTargets().size() == 1) { + Card card = searched.getCards(game).iterator().next(); + controller.moveCards(card, Zone.HAND, source, game); + } + + } + controller.shuffleLibrary(source, game); + return true; + } + controller.shuffleLibrary(source, game); + } + return false; + + } + +} diff --git a/Mage.Sets/src/mage/sets/Dominaria.java b/Mage.Sets/src/mage/sets/Dominaria.java index 1505701134..1b1087e436 100644 --- a/Mage.Sets/src/mage/sets/Dominaria.java +++ b/Mage.Sets/src/mage/sets/Dominaria.java @@ -108,6 +108,7 @@ public class Dominaria extends ExpansionSet { cards.add(new SetCardInfo("Feral Abomination", 92, Rarity.COMMON, mage.cards.f.FeralAbomination.class)); cards.add(new SetCardInfo("Fervent Strike", 117, Rarity.COMMON, mage.cards.f.FerventStrike.class)); cards.add(new SetCardInfo("Fiery Intervention", 118, Rarity.COMMON, mage.cards.f.FieryIntervention.class)); + cards.add(new SetCardInfo("Final Parting", 93, Rarity.UNCOMMON, mage.cards.f.FinalParting.class)); cards.add(new SetCardInfo("Fire Elemental", 120, Rarity.COMMON, mage.cards.f.FireElemental.class)); cards.add(new SetCardInfo("Firefist Adept", 121, Rarity.UNCOMMON, mage.cards.f.FirefistAdept.class)); cards.add(new SetCardInfo("Forebear's Blade", 214, Rarity.RARE, mage.cards.f.ForebearsBlade.class));