From 2dafafad9f7db8b7fb1e99ad0912b6a0ee5ecfcb Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 17 Apr 2019 18:44:14 -0400 Subject: [PATCH] Implemented Command the Dreadhorde --- .../mage/cards/c/CommandTheDreadhorde.java | 79 +++++++++++++++++++ Mage.Sets/src/mage/sets/WarOfTheSpark.java | 1 + 2 files changed, 80 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/CommandTheDreadhorde.java diff --git a/Mage.Sets/src/mage/cards/c/CommandTheDreadhorde.java b/Mage.Sets/src/mage/cards/c/CommandTheDreadhorde.java new file mode 100644 index 00000000000..0858ff26986 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CommandTheDreadhorde.java @@ -0,0 +1,79 @@ +package mage.cards.c; + +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.FilterCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class CommandTheDreadhorde extends CardImpl { + + private static final FilterCard filter = new FilterCard("creature and/or planeswalker cards in graveyards"); + + static { + filter.add(Predicates.or( + new CardTypePredicate(CardType.PLANESWALKER), + new CardTypePredicate(CardType.CREATURE) + )); + } + + public CommandTheDreadhorde(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}{B}"); + + // Choose any number of target creature and/or planeswalker cards in graveyards. Command the Dreadhorde deals damage to you equal to the total converted mana cost of those cards. Put them onto the battlefield under your control. + this.getSpellAbility().addEffect(new CommandTheDreadhordeEffect()); + this.getSpellAbility().addTarget(new TargetCardInGraveyard(0, Integer.MAX_VALUE, filter)); + } + + private CommandTheDreadhorde(final CommandTheDreadhorde card) { + super(card); + } + + @Override + public CommandTheDreadhorde copy() { + return new CommandTheDreadhorde(this); + } +} + +class CommandTheDreadhordeEffect extends OneShotEffect { + + CommandTheDreadhordeEffect() { + super(Outcome.Benefit); + staticText = "Choose any number of target creature and/or planeswalker cards in graveyards. " + + "{this} deals damage to you equal to the total converted mana cost of those cards. " + + "Put them onto the battlefield under your control."; + } + + private CommandTheDreadhordeEffect(final CommandTheDreadhordeEffect effect) { + super(effect); + } + + @Override + public CommandTheDreadhordeEffect copy() { + return new CommandTheDreadhordeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(source.getTargets().get(0).getTargets()); + int damage = cards.getCards(game).stream().mapToInt(Card::getConvertedManaCost).sum(); + player.damage(damage, source.getSourceId(), game); + return player.moveCards(cards, Zone.BATTLEFIELD, source, game); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/WarOfTheSpark.java b/Mage.Sets/src/mage/sets/WarOfTheSpark.java index 0e5f8c7d1f1..eaf382491ab 100644 --- a/Mage.Sets/src/mage/sets/WarOfTheSpark.java +++ b/Mage.Sets/src/mage/sets/WarOfTheSpark.java @@ -57,6 +57,7 @@ public final class WarOfTheSpark extends ExpansionSet { cards.add(new SetCardInfo("Chandra's Pyrohelix", 120, Rarity.COMMON, mage.cards.c.ChandrasPyrohelix.class)); cards.add(new SetCardInfo("Chandra's Triumph", 121, Rarity.UNCOMMON, mage.cards.c.ChandrasTriumph.class)); cards.add(new SetCardInfo("Chandra, Fire Artisan", 119, Rarity.RARE, mage.cards.c.ChandraFireArtisan.class)); + cards.add(new SetCardInfo("Command the Dreadhorde", 82, Rarity.RARE, mage.cards.c.CommandTheDreadhorde.class)); cards.add(new SetCardInfo("Commence the Endgame", 45, Rarity.RARE, mage.cards.c.CommenceTheEndgame.class)); cards.add(new SetCardInfo("Courage in Crisis", 158, Rarity.COMMON, mage.cards.c.CourageInCrisis.class)); cards.add(new SetCardInfo("Cruel Celebrant", 188, Rarity.UNCOMMON, mage.cards.c.CruelCelebrant.class));