Implemented Whirlwind Denial

This commit is contained in:
Evan Kranzler 2020-01-08 22:22:15 -05:00
parent b7dba21e9c
commit 08b906010d
2 changed files with 79 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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));
}
}