diff --git a/Mage.Sets/src/mage/cards/k/KalastriaHighborn.java b/Mage.Sets/src/mage/cards/k/KalastriaHighborn.java index b1f72d5731..34bef1325d 100644 --- a/Mage.Sets/src/mage/cards/k/KalastriaHighborn.java +++ b/Mage.Sets/src/mage/cards/k/KalastriaHighborn.java @@ -29,37 +29,48 @@ 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}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}"); this.subtype.add("Vampire"); this.subtype.add("Shaman"); 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) { - return false; - } - } - - 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())); - } - - @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."; + 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); + } + if (them != null) { + them.loseLife(2, game, false); + } + return true; } }