From 390075efd45cca47123e2cc55082a15c1a807e6e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Jun 2021 09:05:07 -0400 Subject: [PATCH] [MH2] Implemented Dihada's Ploy --- Mage.Sets/src/mage/cards/d/DihadasPloy.java | 71 +++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons2.java | 1 + .../watchers/common/DiscardedCardWatcher.java | 5 ++ 3 files changed, 77 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DihadasPloy.java diff --git a/Mage.Sets/src/mage/cards/d/DihadasPloy.java b/Mage.Sets/src/mage/cards/d/DihadasPloy.java new file mode 100644 index 00000000000..8c680cad0ea --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DihadasPloy.java @@ -0,0 +1,71 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawDiscardControllerEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.JumpStartAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.game.Game; +import mage.watchers.common.DiscardedCardWatcher; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DihadasPloy extends CardImpl { + + private static final Hint hint = new ValueHint("Cards you've discarded this turn", DihadasPloyValue.instance); + + public DihadasPloy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{B}"); + + // Draw two cards, then discard a card. You gain life equal to the number of cards you've discarded this turn. + this.getSpellAbility().addEffect(new DrawDiscardControllerEffect(2, 1)); + this.getSpellAbility().addEffect(new GainLifeEffect(DihadasPloyValue.instance)); + this.getSpellAbility().addHint(hint); + this.getSpellAbility().addWatcher(new DiscardedCardWatcher()); + + // Jump-start + this.addAbility(new JumpStartAbility(this)); + } + + private DihadasPloy(final DihadasPloy card) { + super(card); + } + + @Override + public DihadasPloy copy() { + return new DihadasPloy(this); + } +} + +enum DihadasPloyValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return DiscardedCardWatcher.getDiscarded(sourceAbility.getControllerId(), game); + } + + @Override + public DihadasPloyValue copy() { + return instance; + } + + @Override + public String getMessage() { + return "1"; + } + + @Override + public String toString() { + return "cards you've discarded this turn"; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons2.java b/Mage.Sets/src/mage/sets/ModernHorizons2.java index e06705b9900..98d28f9a677 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons2.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons2.java @@ -82,6 +82,7 @@ public final class ModernHorizons2 extends ExpansionSet { cards.add(new SetCardInfo("Dakkon, Shadow Slayer", 192, Rarity.MYTHIC, mage.cards.d.DakkonShadowSlayer.class)); cards.add(new SetCardInfo("Darkmoss Bridge", 245, Rarity.COMMON, mage.cards.d.DarkmossBridge.class)); cards.add(new SetCardInfo("Diamond Lion", 225, Rarity.RARE, mage.cards.d.DiamondLion.class)); + cards.add(new SetCardInfo("Dihada's Ploy", 193, Rarity.COMMON, mage.cards.d.DihadasPloy.class)); cards.add(new SetCardInfo("Discerning Taste", 82, Rarity.COMMON, mage.cards.d.DiscerningTaste.class)); cards.add(new SetCardInfo("Disciple of the Sun", 11, Rarity.COMMON, mage.cards.d.DiscipleOfTheSun.class)); cards.add(new SetCardInfo("Dragon's Rage Channeler", 121, Rarity.UNCOMMON, mage.cards.d.DragonsRageChanneler.class)); diff --git a/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java b/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java index 5237835f378..a6483f67819 100644 --- a/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DiscardedCardWatcher.java @@ -37,4 +37,9 @@ public class DiscardedCardWatcher extends Watcher { DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class); return watcher != null && watcher.playerMap.getOrDefault(playerId, 0) > 0; } + + public static int getDiscarded(UUID playerId, Game game) { + DiscardedCardWatcher watcher = game.getState().getWatcher(DiscardedCardWatcher.class); + return watcher == null ? 0 : watcher.playerMap.getOrDefault(playerId, 0); + } }