Search in sources :

Example 6 with LoyaltyAbility

use of mage.abilities.LoyaltyAbility in project mage by magefree.

the class ActivatePlaneswalkerLoyaltyAbilityTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getPlayerId().equals(getControllerId())) {
        return false;
    }
    StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
    if (stackAbility == null || !(stackAbility.getStackAbility() instanceof LoyaltyAbility)) {
        return false;
    }
    Permanent permanent = stackAbility.getSourcePermanentOrLKI(game);
    if (permanent == null || !permanent.isPlaneswalker(game) || !permanent.hasSubtype(planeswalkerSubType, game)) {
        return false;
    }
    this.getEffects().setValue("stackAbility", stackAbility);
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) LoyaltyAbility(mage.abilities.LoyaltyAbility) StackAbility(mage.game.stack.StackAbility)

Aggregations

LoyaltyAbility (mage.abilities.LoyaltyAbility)6 Permanent (mage.game.permanent.Permanent)5 StackAbility (mage.game.stack.StackAbility)3 Cost (mage.abilities.costs.Cost)2 Ability (mage.abilities.Ability)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 PayVariableLoyaltyCost (mage.abilities.costs.common.PayVariableLoyaltyCost)1 CopyTargetSpellEffect (mage.abilities.effects.common.CopyTargetSpellEffect)1 PhaseStep (mage.constants.PhaseStep)1 Zone (mage.constants.Zone)1 CounterType (mage.counters.CounterType)1 Spell (mage.game.stack.Spell)1 FixedTarget (mage.target.targetpointer.FixedTarget)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1 CardTestPlayerBase (org.mage.test.serverside.base.CardTestPlayerBase)1