Fixed Kalastria Highborn

This commit is contained in:
Evan Kranzler 2017-09-06 10:23:37 -04:00
parent 30a569d271
commit b793367d4d

View file

@ -29,28 +29,37 @@ package mage.cards.k;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.Ability;
import mage.abilities.common.DiesThisOrAnotherCreatureTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.TargetController;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.players.Player;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
/** /**
* *
* @author maurer.it_at_gmail.com * @author maurer.it_at_gmail.com, TheElk801
*/ */
public class KalastriaHighborn extends CardImpl { public class KalastriaHighborn extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Vampire you control");
static {
filter.add(new SubtypePredicate(SubType.VAMPIRE));
filter.add(new ControllerPredicate(TargetController.YOU));
}
public KalastriaHighborn(UUID ownerId, CardSetInfo setInfo) { public KalastriaHighborn(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}");
this.subtype.add("Vampire"); this.subtype.add("Vampire");
@ -59,7 +68,9 @@ public class KalastriaHighborn extends CardImpl {
this.power = new MageInt(2); this.power = new MageInt(2);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
this.addAbility(new KalastriaHighbornTriggeredAbility()); Ability ability = new DiesThisOrAnotherCreatureTriggeredAbility(new DoIfCostPaid(new LoseGainEffect(), new ManaCostsImpl("{B}")), false, filter);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
} }
public KalastriaHighborn(final KalastriaHighborn card) { public KalastriaHighborn(final KalastriaHighborn card) {
@ -72,52 +83,35 @@ public class KalastriaHighborn extends CardImpl {
} }
} }
class KalastriaHighbornTriggeredAbility extends TriggeredAbilityImpl { class LoseGainEffect extends OneShotEffect {
KalastriaHighbornTriggeredAbility ( ) {
super(Zone.ALL, new LoseLifeTargetEffect(2), false); LoseGainEffect() {
this.addCost(new ManaCostsImpl("{B}")); super(Outcome.Benefit);
this.addTarget(new TargetPlayer()); this.staticText = "target player loses 2 life and you gain 2 life";
this.getEffects().add(new GainLifeEffect(2));
} }
KalastriaHighbornTriggeredAbility ( KalastriaHighbornTriggeredAbility ability ) { LoseGainEffect(final LoseGainEffect effect) {
super(ability); super(effect);
} }
@Override @Override
public KalastriaHighbornTriggeredAbility copy() { public LoseGainEffect copy() {
return new KalastriaHighbornTriggeredAbility(this); return new LoseGainEffect(this);
} }
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean apply(Game game, Ability source) {
return event.getType() == EventType.ZONE_CHANGE; Player you = game.getPlayer(source.getControllerId());
} Player them = game.getPlayer(source.getFirstTarget());
if (you == null && them == null) {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
// ayrat: make sure Kalastria Highborn is on battlefield
if (game.getPermanent(this.getSourceId()) == null) {
// or it is being removed
if (game.getLastKnownInformation(this.getSourceId(), Zone.BATTLEFIELD) == null) {
return false; return false;
} }
if (you != null) {
you.gainLife(2, game);
} }
if (them != null) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event; them.loseLife(2, game, false);
Permanent permanent = zEvent.getTarget();
return permanent != null &&
zEvent.getToZone() == Zone.GRAVEYARD &&
zEvent.getFromZone() == Zone.BATTLEFIELD &&
(permanent.getControllerId().equals(this.getControllerId()) &&
permanent.hasSubtype(SubType.VAMPIRE, game) || permanent.getId().equals(this.getSourceId()));
} }
return true;
@Override
public String getRule() {
return "Whenever {this} or another Vampire you control is put"
+ " into a graveyard from the battlefield, you may pay {B}. If you"
+ " do, target player loses 2 life and you gain 2 life.";
} }
} }