From c67a7fbaec7da353c100fe8fee237c0d42ff6d07 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 3 Oct 2020 20:01:34 -0400 Subject: [PATCH] [MIR] Implemented Preferred Selection --- .../src/mage/cards/p/PreferredSelection.java | 93 +++++++++++++++++++ Mage.Sets/src/mage/sets/Mirage.java | 1 + 2 files changed, 94 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PreferredSelection.java diff --git a/Mage.Sets/src/mage/cards/p/PreferredSelection.java b/Mage.Sets/src/mage/cards/p/PreferredSelection.java new file mode 100644 index 00000000000..46bd3918406 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PreferredSelection.java @@ -0,0 +1,93 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.costs.CompositeCost; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.LookLibraryAndPickControllerEffect; +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.TargetController; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PreferredSelection extends CardImpl { + + public PreferredSelection(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{G}"); + + // At the beginning of your upkeep, look at the top two cards of your library. You may sacrifice Preferred Selection and pay {2}{G}{G}. If you do, put one of those cards into your hand. If you don't, put one of those cards on the bottom of your library. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new PreferredSelectionEffect(), TargetController.YOU, false + )); + } + + private PreferredSelection(final PreferredSelection card) { + super(card); + } + + @Override + public PreferredSelection copy() { + return new PreferredSelection(this); + } +} + +class PreferredSelectionEffect extends OneShotEffect { + + PreferredSelectionEffect() { + super(Outcome.Benefit); + staticText = "At the beginning of your upkeep, look at the top two cards of your library. " + + "You may sacrifice {this} and pay {2}{G}{G}. If you do, put one of those cards into your hand. " + + "If you don't, put one of those cards on the bottom of your library."; + } + + private PreferredSelectionEffect(final PreferredSelectionEffect effect) { + super(effect); + } + + @Override + public PreferredSelectionEffect copy() { + return new PreferredSelectionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 2)); + player.lookAtCards(source, "Top two cards", cards, game); + Cost cost = new CompositeCost( + new SacrificeSourceCost(), new ManaCostsImpl<>("{2}{G}{G}"), + "sacrifice this permanent and pay {2}{G}{G}" + ); + return new DoIfCostPaid( + new LookLibraryAndPickControllerEffect( + StaticValue.get(2), false, StaticValue.get(1), + StaticFilters.FILTER_CARD, Zone.HAND, true, false + ), + new LookLibraryAndPickControllerEffect( + StaticValue.get(2), false, StaticValue.get(1), + StaticFilters.FILTER_CARD, Zone.HAND, true, false, + false, Zone.LIBRARY, false, true, false + ), cost + ).apply(game, source); + } +} diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index 353cbbf792d..610f29f9fef 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -232,6 +232,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Political Trickery", 81, Rarity.RARE, mage.cards.p.PoliticalTrickery.class)); cards.add(new SetCardInfo("Polymorph", 82, Rarity.RARE, mage.cards.p.Polymorph.class)); cards.add(new SetCardInfo("Power Sink", 83, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Preferred Selection", 233, Rarity.RARE, mage.cards.p.PreferredSelection.class)); cards.add(new SetCardInfo("Prismatic Boon", 274, Rarity.UNCOMMON, mage.cards.p.PrismaticBoon.class)); cards.add(new SetCardInfo("Prismatic Circle", 34, Rarity.COMMON, mage.cards.p.PrismaticCircle.class)); cards.add(new SetCardInfo("Prismatic Lace", 84, Rarity.RARE, mage.cards.p.PrismaticLace.class));