From 522b97c937ee432c5a6fbd3e5051fcfd9309c3d6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 2 Aug 2021 09:51:32 -0400 Subject: [PATCH] [AFC] Implemented Danse Manatee --- Mage.Sets/src/mage/cards/d/DanseMacabre.java | 131 ++++++++++++++++++ .../mage/sets/ForgottenRealmsCommander.java | 1 + 2 files changed, 132 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DanseMacabre.java diff --git a/Mage.Sets/src/mage/cards/d/DanseMacabre.java b/Mage.Sets/src/mage/cards/d/DanseMacabre.java new file mode 100644 index 0000000000..f62acfad28 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DanseMacabre.java @@ -0,0 +1,131 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardIdPredicate; +import mage.filter.predicate.permanent.TokenPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetCardInGraveyard; + +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class DanseMacabre extends CardImpl { + + public DanseMacabre(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}"); + + // Each player sacrifices a nontoken creature. Roll a d20 and add the toughness of the creature you sacrificed this way. + // 1-14 | Return a creature card put into a graveyard this way to the battlefield under your control. + // 15+ | Return up to two creature cards put into a graveyard this way to the battlefield under your control + this.getSpellAbility().addEffect(new DanseMacabreEffect()); + } + + private DanseMacabre(final DanseMacabre card) { + super(card); + } + + @Override + public DanseMacabre copy() { + return new DanseMacabre(this); + } +} + +class DanseMacabreEffect extends OneShotEffect { + + private static final FilterPermanent filter + = new FilterControlledCreaturePermanent("nontoken creature you control"); + + static { + filter.add(Predicates.not(TokenPredicate.instance)); + } + + DanseMacabreEffect() { + super(Outcome.Benefit); + staticText = "each player sacrifices a nontoken creature. Roll a d20 " + + "and add the toughness of the creature you sacrificed this way." + + "
1-14 | Return a creature card put into a graveyard " + + "this way to the battlefield under your control." + + "
15+ | Return up to two creature cards put into " + + "a graveyard this way to the battlefield under your control"; + } + + private DanseMacabreEffect(final DanseMacabreEffect effect) { + super(effect); + } + + @Override + public DanseMacabreEffect copy() { + return new DanseMacabreEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + int toughness = 0; + Cards cards = new CardsImpl(); + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + Player player = game.getPlayer(playerId); + if (player == null || game.getBattlefield().count( + filter, source.getSourceId(), source.getControllerId(), game + ) < 1) { + continue; + } + TargetPermanent target = new TargetPermanent(filter); + target.setNotTarget(true); + player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + continue; + } + if (source.isControlledBy(playerId)) { + toughness += permanent.getToughness().getValue(); + } + cards.add(permanent); + permanent.sacrifice(source, game); + } + int result = controller.rollDice(source, game, 20) + toughness; + cards.retainZone(Zone.GRAVEYARD, game); + if (cards.isEmpty()) { + return true; + } + FilterCard filterCard = new FilterCard("card put into a graveyard this way"); + filterCard.add(Predicates.or( + cards.stream() + .map(cardId -> new CardIdPredicate(cardId)) + .collect(Collectors.toSet()) + )); + TargetCardInGraveyard target; + if (result >= 15) { + target = new TargetCardInGraveyard(0, 2, filterCard); + } else if (result > 0) { + target = new TargetCardInGraveyard(filterCard); + } else { + return true; + } + target.setNotTarget(true); + controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game); + controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java index 8cb3a4a7ea..55a49c5e93 100644 --- a/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java +++ b/Mage.Sets/src/mage/sets/ForgottenRealmsCommander.java @@ -72,6 +72,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet { cards.add(new SetCardInfo("Cultivate", 155, Rarity.UNCOMMON, mage.cards.c.Cultivate.class)); cards.add(new SetCardInfo("Curator of Mysteries", 81, Rarity.RARE, mage.cards.c.CuratorOfMysteries.class)); cards.add(new SetCardInfo("Curse of Verbosity", 82, Rarity.UNCOMMON, mage.cards.c.CurseOfVerbosity.class)); + cards.add(new SetCardInfo("Danse Macabre", 22, Rarity.RARE, mage.cards.d.DanseMacabre.class)); cards.add(new SetCardInfo("Dark-Dweller Oracle", 119, Rarity.RARE, mage.cards.d.DarkDwellerOracle.class)); cards.add(new SetCardInfo("Darkwater Catacombs", 232, Rarity.RARE, mage.cards.d.DarkwaterCatacombs.class)); cards.add(new SetCardInfo("Dead Man's Chest", 97, Rarity.RARE, mage.cards.d.DeadMansChest.class));