Search in sources :

Example 6 with NumberOfTriggersEvent

use of mage.game.events.NumberOfTriggersEvent in project mage by magefree.

the class AncientGreenwardenEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (!(event instanceof NumberOfTriggersEvent)) {
        return false;
    }
    NumberOfTriggersEvent numberOfTriggersEvent = (NumberOfTriggersEvent) event;
    if (!source.isControlledBy(event.getPlayerId())) {
        return false;
    }
    GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
    if (sourceEvent == null || sourceEvent.getType() != GameEvent.EventType.ENTERS_THE_BATTLEFIELD || !(sourceEvent instanceof EntersTheBattlefieldEvent) || !((EntersTheBattlefieldEvent) sourceEvent).getTarget().isLand(game)) {
        return false;
    }
    return game.getPermanent(numberOfTriggersEvent.getSourceId()) != null;
}
Also used : NumberOfTriggersEvent(mage.game.events.NumberOfTriggersEvent) EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) GameEvent(mage.game.events.GameEvent)

Aggregations

NumberOfTriggersEvent (mage.game.events.NumberOfTriggersEvent)6 GameEvent (mage.game.events.GameEvent)5 Permanent (mage.game.permanent.Permanent)4 EntersTheBattlefieldEvent (mage.game.events.EntersTheBattlefieldEvent)2 Spell (mage.game.stack.Spell)2 MageObject (mage.MageObject)1