From b800585cc542c16aef2dc71f5500358d1d1ba12f Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 25 Jan 2019 22:19:01 -0500 Subject: [PATCH] fixed implementation of Knight of the Mists --- .../src/mage/cards/k/KnightOfTheMists.java | 63 ++++--------------- 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/Mage.Sets/src/mage/cards/k/KnightOfTheMists.java b/Mage.Sets/src/mage/cards/k/KnightOfTheMists.java index f2eb1cd069..8cf5ac9bcf 100644 --- a/Mage.Sets/src/mage/cards/k/KnightOfTheMists.java +++ b/Mage.Sets/src/mage/cards/k/KnightOfTheMists.java @@ -1,37 +1,30 @@ package mage.cards.k; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.costs.Cost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; -import mage.constants.SubType; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.InfoEffect; import mage.abilities.keyword.FlankingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.players.Player; -import mage.target.common.TargetCreaturePermanent; +import mage.target.TargetPermanent; + +import java.util.UUID; /** - * * @author TheElk801 */ public final class KnightOfTheMists extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Knight"); - - static { - filter.add(new SubtypePredicate(SubType.KNIGHT)); - } + private static final FilterPermanent filter = new FilterCreaturePermanent(SubType.KNIGHT, "Knight"); public KnightOfTheMists(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}"); @@ -45,12 +38,14 @@ public final class KnightOfTheMists extends CardImpl { this.addAbility(new FlankingAbility()); // When Knight of the Mists enters the battlefield, you may pay {U}. If you don't, destroy target Knight and it can't be regenerated. - Ability ability = new EntersBattlefieldTriggeredAbility(new KnightOfTheMistsEffect()); - ability.addTarget(new TargetCreaturePermanent(filter)); + Ability ability = new EntersBattlefieldTriggeredAbility(new DoIfCostPaid( + new InfoEffect(""), new DestroyTargetEffect(), new ManaCostsImpl("{U}") + ).setText("you may pay {U}. If you don't, destroy target Knight and it can't be regenerated.")); + ability.addTarget(new TargetPermanent(filter)); addAbility(ability); } - public KnightOfTheMists(final KnightOfTheMists card) { + private KnightOfTheMists(final KnightOfTheMists card) { super(card); } @@ -59,35 +54,3 @@ public final class KnightOfTheMists extends CardImpl { return new KnightOfTheMists(this); } } - -class KnightOfTheMistsEffect extends OneShotEffect { - - KnightOfTheMistsEffect() { - super(Outcome.Neutral); - this.staticText = "When {this} enters the battlefield, you may pay {U}. If you don't, destroy target Knight and it can't be regenerated."; - } - - KnightOfTheMistsEffect(final KnightOfTheMistsEffect effect) { - super(effect); - } - - @Override - public KnightOfTheMistsEffect copy() { - return new KnightOfTheMistsEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getSourceId()); - if (player == null) { - return false; - } - Cost cost = new ManaCostsImpl("{U}"); - if (!(cost.canPay(source, source.getSourceId(), player.getId(), game) - && player.chooseUse(outcome, "Pay {U}?", source, game) - && cost.pay(source, game, source.getSourceId(), player.getId(), false))) { - return new DestroyTargetEffect(true).apply(game, source); - } - return true; - } -}