diff --git a/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java b/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java new file mode 100644 index 00000000000..d3bf7ca5c9b --- /dev/null +++ b/Mage.Sets/src/mage/cards/w/WrathOfTheSkies.java @@ -0,0 +1,85 @@ +package mage.cards.w; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.PayEnergyCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author DominionSpy + */ +public final class WrathOfTheSkies extends CardImpl { + + public WrathOfTheSkies(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{W}{W}"); + + // You get X {E}, then you may pay any amount of {E}. Destroy each artifact, creature, and enchantment with mana value less than or equal to the amount of {E} paid this way. + this.getSpellAbility().addEffect(new WrathOfTheSkiesEffect()); + } + + private WrathOfTheSkies(final WrathOfTheSkies card) { + super(card); + } + + @Override + public WrathOfTheSkies copy() { + return new WrathOfTheSkies(this); + } +} + +class WrathOfTheSkiesEffect extends OneShotEffect { + + WrathOfTheSkiesEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "You get X {E}, then you may pay any amount of {E}. " + + "Destroy each artifact, creature, and enchantment with mana value " + + "less than or equal to the amount of {E} paid this way."; + } + + private WrathOfTheSkiesEffect(final WrathOfTheSkiesEffect effect) { + super(effect); + } + + @Override + public WrathOfTheSkiesEffect copy() { + return new WrathOfTheSkiesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + int xValue = source.getManaCostsToPay().getX(); + if (xValue > 0) { + new GetEnergyCountersControllerEffect(xValue).apply(game, source); + } + + int numberToPay = controller.getAmount(0, controller.getCounters().getCount(CounterType.ENERGY), + "Pay any amount of {E}", game); + Cost cost = new PayEnergyCost(numberToPay); + if (cost.pay(source, game, source, source.getControllerId(), true)) { + game.getBattlefield() + .getActivePermanents(controller.getId(), game) + .stream() + .filter(permanent -> permanent.isArtifact(game) + || permanent.isCreature(game) + || permanent.isEnchantment(game)) + .filter(permanent -> permanent.getManaValue() <= numberToPay) + .forEach(permanent -> permanent.destroy(source, game, false)); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/ModernHorizons3.java b/Mage.Sets/src/mage/sets/ModernHorizons3.java index 6ca5e6ebf2b..c174938a2b5 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons3.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons3.java @@ -168,6 +168,7 @@ public final class ModernHorizons3 extends ExpansionSet { cards.add(new SetCardInfo("Witch Enchanter", 239, Rarity.UNCOMMON, mage.cards.w.WitchEnchanter.class)); cards.add(new SetCardInfo("Wooded Foothills", 236, Rarity.RARE, mage.cards.w.WoodedFoothills.class)); cards.add(new SetCardInfo("Worn Powerstone", 298, Rarity.UNCOMMON, mage.cards.w.WornPowerstone.class)); + cards.add(new SetCardInfo("Wrath of the Skies", 49, Rarity.RARE, mage.cards.w.WrathOfTheSkies.class)); cards.add(new SetCardInfo("Writhing Chrysalis", 208, Rarity.COMMON, mage.cards.w.WrithingChrysalis.class)); cards.add(new SetCardInfo("Wumpus Aberration", 176, Rarity.UNCOMMON, mage.cards.w.WumpusAberration.class)); cards.add(new SetCardInfo("Wurmcoil Larva", 112, Rarity.UNCOMMON, mage.cards.w.WurmcoilLarva.class));