From 6c4310738772d8b1d9d71935b68f88fc6ab0cc7e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 6 Sep 2019 20:25:51 -0400 Subject: [PATCH] Implemented Knight's Charge --- Mage.Sets/src/mage/cards/k/KnightsCharge.java | 88 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 89 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/k/KnightsCharge.java diff --git a/Mage.Sets/src/mage/cards/k/KnightsCharge.java b/Mage.Sets/src/mage/cards/k/KnightsCharge.java new file mode 100644 index 0000000000..31d33c18a2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KnightsCharge.java @@ -0,0 +1,88 @@ +package mage.cards.k; + +import mage.abilities.Ability; +import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.abilities.effects.common.LoseLifeOpponentsEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class KnightsCharge extends CardImpl { + + private static final FilterControlledCreaturePermanent filter + = new FilterControlledCreaturePermanent(SubType.KNIGHT); + + public KnightsCharge(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{B}"); + + // Whenever a Knight you control attacks, each opponent loses 1 life and you gain 1 life. + Ability ability = new AttacksCreatureYouControlTriggeredAbility( + new LoseLifeOpponentsEffect(1), false, filter + ); + ability.addEffect(new GainLifeEffect(1).concatBy("and")); + this.addAbility(ability); + + // {6}{W}{B}, Sacrifice Knights' Charge: Return all Knight creature cards from your graveyard to the battlefield. + ability = new SimpleActivatedAbility(new KnightsChargeEffect(), new ManaCostsImpl("{6}{W}{B}")); + ability.addCost(new SacrificeSourceCost()); + this.addAbility(ability); + } + + private KnightsCharge(final KnightsCharge card) { + super(card); + } + + @Override + public KnightsCharge copy() { + return new KnightsCharge(this); + } +} + +class KnightsChargeEffect extends OneShotEffect { + + KnightsChargeEffect() { + super(Outcome.Benefit); + staticText = "return all Knight creature cards from your graveyard to the battlefield"; + } + + private KnightsChargeEffect(final KnightsChargeEffect effect) { + super(effect); + } + + @Override + public KnightsChargeEffect copy() { + return new KnightsChargeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + return player != null && player.moveCards(new CardsImpl( + player.getGraveyard() + .getCards(game) + .stream() + .filter(Card::isCreature) + .filter(card -> card.hasSubtype(SubType.KNIGHT, game)) + .collect(Collectors.toSet()) + ), Zone.BATTLEFIELD, source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 8e9a0e7242..f5c92aee17 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -54,6 +54,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Golden Egg", 220, Rarity.COMMON, mage.cards.g.GoldenEgg.class)); cards.add(new SetCardInfo("Heraldic Banner", 222, Rarity.UNCOMMON, mage.cards.h.HeraldicBanner.class)); cards.add(new SetCardInfo("Inspiring Veteran", 194, Rarity.UNCOMMON, mage.cards.i.InspiringVeteran.class)); + cards.add(new SetCardInfo("Knights' Charge", 328, Rarity.RARE, mage.cards.k.KnightsCharge.class)); cards.add(new SetCardInfo("Lovestruck Beast", 165, Rarity.RARE, mage.cards.l.LovestruckBeast.class)); cards.add(new SetCardInfo("Mace of the Valiant", 314, Rarity.RARE, mage.cards.m.MaceOfTheValiant.class)); cards.add(new SetCardInfo("Maraleaf Pixie", 196, Rarity.UNCOMMON, mage.cards.m.MaraleafPixie.class));