Search in sources :

Example 1 with CastFromGraveyardWatcher

use of mage.watchers.common.CastFromGraveyardWatcher in project mage by magefree.

the class BreathlessKnightTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event instanceof EntersTheBattlefieldEvent) {
        EntersTheBattlefieldEvent entersEvent = (EntersTheBattlefieldEvent) event;
        Permanent permanent = entersEvent.getTarget();
        if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.getControllerId())) {
            if (entersEvent.getFromZone() == Zone.GRAVEYARD) {
                return true;
            }
            CastFromGraveyardWatcher watcher = game.getState().getWatcher(CastFromGraveyardWatcher.class);
            int zcc = game.getState().getZoneChangeCounter(entersEvent.getSourceId());
            return watcher != null && watcher.spellWasCastFromGraveyard(entersEvent.getSourceId(), zcc - 1);
        }
    }
    return false;
}
Also used : EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) Permanent(mage.game.permanent.Permanent) CastFromGraveyardWatcher(mage.watchers.common.CastFromGraveyardWatcher)

Aggregations

EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)1 Permanent (mage.game.permanent.Permanent)1 CastFromGraveyardWatcher (mage.watchers.common.CastFromGraveyardWatcher)1