From 52e8f9bcfc9d5e3ab1de635def70208fa86bdd65 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 21 Jun 2019 20:05:50 -0400 Subject: [PATCH] Implemented Diviner's Lockbox --- .../src/mage/cards/d/DivinersLockbox.java | 92 +++++++++++++++++++ Mage.Sets/src/mage/sets/CoreSet2020.java | 1 + 2 files changed, 93 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DivinersLockbox.java diff --git a/Mage.Sets/src/mage/cards/d/DivinersLockbox.java b/Mage.Sets/src/mage/cards/d/DivinersLockbox.java new file mode 100644 index 0000000000..4945d95f4d --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DivinersLockbox.java @@ -0,0 +1,92 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.SacrificeSourceEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.cards.repository.CardRepository; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DivinersLockbox extends CardImpl { + + public DivinersLockbox(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + // {1}, {T}: Choose a card name, then reveal the top card of your library. If that card has the chosen name, sacrifice Diviner's Lockbox and draw three cards. Activate this ability only any time you could cast a sorcery. + Ability ability = new ActivateAsSorceryActivatedAbility( + Zone.BATTLEFIELD, new DivinersLockboxEffect(), new GenericManaCost(1) + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private DivinersLockbox(final DivinersLockbox card) { + super(card); + } + + @Override + public DivinersLockbox copy() { + return new DivinersLockbox(this); + } +} + +class DivinersLockboxEffect extends OneShotEffect { + + private static final Effect sacEffect = new SacrificeSourceEffect(); + + DivinersLockboxEffect() { + super(Outcome.Benefit); + staticText = "Choose a card name, then reveal the top card of your library. " + + "If that card has the chosen name, sacrifice {this} and draw three cards. " + + "Activate this ability only any time you could cast a sorcery."; + } + + private DivinersLockboxEffect(final DivinersLockboxEffect effect) { + super(effect); + } + + @Override + public DivinersLockboxEffect copy() { + return new DivinersLockboxEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Choice choice = new ChoiceImpl(); + choice.setChoices(CardRepository.instance.getNames()); + choice.setMessage("Choose a card name"); + if (!player.choose(outcome, choice, game)) { + return false; + } + game.informPlayers(source.getSourceObject(game).getLogName() + ", chosen name: [" + choice.getChoice() + ']'); + Card card = player.getLibrary().getFromTop(game); + player.revealCards(source, new CardsImpl(card), game); + if (choice.getChoice().equals(card.getName())) { + sacEffect.apply(game, source); + player.drawCards(3, game); + } + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 71f96301ff..38bd1ebd66 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -58,6 +58,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Disenchant", 14, Rarity.COMMON, mage.cards.d.Disenchant.class)); cards.add(new SetCardInfo("Disfigure", 95, Rarity.UNCOMMON, mage.cards.d.Disfigure.class)); cards.add(new SetCardInfo("Dismal Backwater", 245, Rarity.COMMON, mage.cards.d.DismalBackwater.class)); + cards.add(new SetCardInfo("Diviner's Lockbox", 225, Rarity.UNCOMMON, mage.cards.d.DivinersLockbox.class)); cards.add(new SetCardInfo("Dragon Mage", 135, Rarity.UNCOMMON, mage.cards.d.DragonMage.class)); cards.add(new SetCardInfo("Drawn from Dreams", 56, Rarity.RARE, mage.cards.d.DrawnFromDreams.class)); cards.add(new SetCardInfo("Dread Presence", 96, Rarity.RARE, mage.cards.d.DreadPresence.class));