mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
fixed implementation of Knight of the Mists
This commit is contained in:
parent
8c89772c3d
commit
b800585cc5
1 changed files with 13 additions and 50 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue