Search in sources :

Example 1 with CastSpellYourLastTurnWatcher

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

the class ArboriaEffect method canAttack.

@Override
public boolean canAttack(Permanent attacker, UUID defenderId, Ability source, Game game, boolean canUseChooseDialogs) {
    if (defenderId == null) {
        return true;
    }
    CastSpellYourLastTurnWatcher watcher = game.getState().getWatcher(CastSpellYourLastTurnWatcher.class);
    if (watcher != null && watcher.getAmountOfSpellsCastOnPlayersTurn(defenderId) > 0) {
        return true;
    }
    PermanentsEnteredBattlefieldYourLastTurnWatcher watcher2 = game.getState().getWatcher(PermanentsEnteredBattlefieldYourLastTurnWatcher.class);
    if (watcher2 != null && watcher2.getPermanentsEnteringOnPlayersLastTurn(game, defenderId) != null) {
        for (Permanent permanent : watcher2.getPermanentsEnteringOnPlayersLastTurn(game, defenderId)) {
            if (permanent != null && !(permanent instanceof PermanentToken)) {
                return true;
            }
        }
    }
    return false;
}
Also used : CastSpellYourLastTurnWatcher(mage.watchers.common.CastSpellYourLastTurnWatcher) PermanentsEnteredBattlefieldYourLastTurnWatcher(mage.watchers.common.PermanentsEnteredBattlefieldYourLastTurnWatcher) Permanent(mage.game.permanent.Permanent) PermanentToken(mage.game.permanent.PermanentToken)

Aggregations

Permanent (mage.game.permanent.Permanent)1 PermanentToken (mage.game.permanent.PermanentToken)1 CastSpellYourLastTurnWatcher (mage.watchers.common.CastSpellYourLastTurnWatcher)1 PermanentsEnteredBattlefieldYourLastTurnWatcher (mage.watchers.common.PermanentsEnteredBattlefieldYourLastTurnWatcher)1