From 08b906010d488ef1655d1631ae29003d04714336 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 8 Jan 2020 22:22:15 -0500 Subject: [PATCH] Implemented Whirlwind Denial --- .../src/mage/cards/w/WhirlwindDenial.java | 78 +++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + 2 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/w/WhirlwindDenial.java diff --git a/Mage.Sets/src/mage/cards/w/WhirlwindDenial.java b/Mage.Sets/src/mage/cards/w/WhirlwindDenial.java new file mode 100644 index 0000000000..0f70053900 --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WhirlwindDenial.java @@ -0,0 +1,78 @@ +package mage.cards.w; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.players.Player; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class WhirlwindDenial extends CardImpl { + + public WhirlwindDenial(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); + + // For each spell and ability your opponents control, counter it unless its controller pays {4}. + this.getSpellAbility().addEffect(new WhirlwindDenialEffect()); + } + + private WhirlwindDenial(final WhirlwindDenial card) { + super(card); + } + + @Override + public WhirlwindDenial copy() { + return new WhirlwindDenial(this); + } +} + +class WhirlwindDenialEffect extends OneShotEffect { + + WhirlwindDenialEffect() { + super(Outcome.Benefit); + staticText = "For each spell and ability your opponents control, " + + "counter it unless its controller pays {4}."; + } + + private WhirlwindDenialEffect(final WhirlwindDenialEffect effect) { + super(effect); + } + + @Override + public WhirlwindDenialEffect copy() { + return new WhirlwindDenialEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + game.getStack() + .stream() + .filter(Objects::nonNull) + .forEachOrdered(stackObject -> { + if (!game.getOpponents(stackObject.getControllerId()).contains(source.getControllerId())) { + return; + } + Player player = game.getPlayer(stackObject.getControllerId()); + if (player == null) { + return; + } + Cost cost = new GenericManaCost(4); + if (player.chooseUse(outcome, "Pay {4} to prevent " + stackObject.getIdName() + " from being countered?", source, game) + && cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { + return; + } + stackObject.counter(source.getSourceId(), game); + }); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index a338e25fb9..a51ffd0aad 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -165,6 +165,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Victory's Envoy", 289, Rarity.RARE, mage.cards.v.VictorysEnvoy.class)); cards.add(new SetCardInfo("Warden of the Chained", 230, Rarity.UNCOMMON, mage.cards.w.WardenOfTheChained.class)); cards.add(new SetCardInfo("Wavebreak Hippocamp", 80, Rarity.RARE, mage.cards.w.WavebreakHippocamp.class)); + cards.add(new SetCardInfo("Whirlwind Denial", 81, Rarity.UNCOMMON, mage.cards.w.WhirlwindDenial.class)); cards.add(new SetCardInfo("Woe Strider", 123, Rarity.RARE, mage.cards.w.WoeStrider.class)); } }