Implemented Command the Dreadhorde

This commit is contained in:
Evan Kranzler 2019-04-17 18:44:14 -04:00
parent e6138d7e7f
commit 2dafafad9f
2 changed files with 80 additions and 0 deletions

View file

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

View file

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