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 mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.DiesThisOrAnotherCreatureTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
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.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
*
* @author maurer.it_at_gmail.com
* @author maurer.it_at_gmail.com, TheElk801
*/
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) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}");
this.subtype.add("Vampire");
@ -59,7 +68,9 @@ public class KalastriaHighborn extends CardImpl {
this.power = 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) {
@ -72,52 +83,35 @@ public class KalastriaHighborn extends CardImpl {
}
}
class KalastriaHighbornTriggeredAbility extends TriggeredAbilityImpl {
KalastriaHighbornTriggeredAbility ( ) {
super(Zone.ALL, new LoseLifeTargetEffect(2), false);
this.addCost(new ManaCostsImpl("{B}"));
this.addTarget(new TargetPlayer());
this.getEffects().add(new GainLifeEffect(2));
class LoseGainEffect extends OneShotEffect {
LoseGainEffect() {
super(Outcome.Benefit);
this.staticText = "target player loses 2 life and you gain 2 life";
}
KalastriaHighbornTriggeredAbility ( KalastriaHighbornTriggeredAbility ability ) {
super(ability);
LoseGainEffect(final LoseGainEffect effect) {
super(effect);
}
@Override
public KalastriaHighbornTriggeredAbility copy() {
return new KalastriaHighbornTriggeredAbility(this);
public LoseGainEffect copy() {
return new LoseGainEffect(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.ZONE_CHANGE;
}
@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) {
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player them = game.getPlayer(source.getFirstTarget());
if (you == null && them == null) {
return false;
}
if (you != null) {
you.gainLife(2, game);
}
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
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()));
if (them != null) {
them.loseLife(2, game, false);
}
@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.";
return true;
}
}