From 8d48429f5fbb574dde3fb471c2c6dc647655e037 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Tue, 11 Apr 2023 19:51:03 -0400 Subject: [PATCH] [MOC] Implement Dance with Calamity --- .../src/mage/cards/d/DanceWithCalamity.java | 90 +++++++++++++++++++ .../mage/sets/MarchOfTheMachineCommander.java | 1 + 2 files changed, 91 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DanceWithCalamity.java diff --git a/Mage.Sets/src/mage/cards/d/DanceWithCalamity.java b/Mage.Sets/src/mage/cards/d/DanceWithCalamity.java new file mode 100644 index 0000000000..5d947b3f73 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DanceWithCalamity.java @@ -0,0 +1,90 @@ +package mage.cards.d; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DanceWithCalamity extends CardImpl { + + public DanceWithCalamity(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{7}{R}"); + + // Shuffle your library. As many times as you choose, you may exile the top card of your library. If the total mana value of the cards exiled this way is 13 or less, you may cast any number of spells from among those cards without paying their mana costs. + this.getSpellAbility().addEffect(new DanceWithCalamityEffect()); + } + + private DanceWithCalamity(final DanceWithCalamity card) { + super(card); + } + + @Override + public DanceWithCalamity copy() { + return new DanceWithCalamity(this); + } +} + +class DanceWithCalamityEffect extends OneShotEffect { + + DanceWithCalamityEffect() { + super(Outcome.Benefit); + staticText = "shuffle your library. As many times as you choose, you may exile the top card of your library. " + + "If the total mana value of the cards exiled this way is 13 or less, you may cast any number " + + "of spells from among those cards without paying their mana costs"; + } + + private DanceWithCalamityEffect(final DanceWithCalamityEffect effect) { + super(effect); + } + + @Override + public DanceWithCalamityEffect copy() { + return new DanceWithCalamityEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(); + while (player.getLibrary().hasCards()) { + int totalMV = cards + .getCards(game) + .stream() + .mapToInt(MageObject::getManaValue) + .sum(); + if (!player.chooseUse( + outcome, "Exile the top card of your library?", + "Current total mana value is " + totalMV, + "Yes", "No", source, game + )) { + break; + } + Card card = player.getLibrary().getFromTop(game); + player.moveCards(card, Zone.EXILED, source, game); + cards.add(card); + } + if (cards + .getCards(game) + .stream() + .mapToInt(MageObject::getManaValue) + .sum() <= 13) { + CardUtil.castMultipleWithAttributeForFree(player, source, game, cards, StaticFilters.FILTER_CARD); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java b/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java index 155d3f0894..589396b1b8 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachineCommander.java @@ -79,6 +79,7 @@ public final class MarchOfTheMachineCommander extends ExpansionSet { cards.add(new SetCardInfo("Cultivate", 295, Rarity.COMMON, mage.cards.c.Cultivate.class)); cards.add(new SetCardInfo("Cultivator's Caravan", 354, Rarity.RARE, mage.cards.c.CultivatorsCaravan.class)); cards.add(new SetCardInfo("Curse of Opulence", 274, Rarity.UNCOMMON, mage.cards.c.CurseOfOpulence.class)); + cards.add(new SetCardInfo("Dance with Calamity", 29, Rarity.RARE, mage.cards.d.DanceWithCalamity.class)); cards.add(new SetCardInfo("Death-Greeter's Champion", 30, Rarity.RARE, mage.cards.d.DeathGreetersChampion.class)); cards.add(new SetCardInfo("Deluxe Dragster", 21, Rarity.RARE, mage.cards.d.DeluxeDragster.class)); cards.add(new SetCardInfo("Despark", 322, Rarity.UNCOMMON, mage.cards.d.Despark.class));