Search in sources :

Example 1 with FirstSpellCastThisTurnWatcher

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

the class MaelstromNexusGainCascadeFirstSpellEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (StackObject stackObject : game.getStack()) {
            // only spells cast, so no copies of spells
            if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
                Spell spell = (Spell) stackObject;
                FirstSpellCastThisTurnWatcher watcher = game.getState().getWatcher(FirstSpellCastThisTurnWatcher.class);
                if (watcher != null && spell.getId().equals(watcher.getIdOfFirstCastSpell(source.getControllerId()))) {
                    game.getState().addOtherAbility(spell.getCard(), cascadeAbility);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FirstSpellCastThisTurnWatcher(mage.watchers.common.FirstSpellCastThisTurnWatcher) Player(mage.players.Player) StackObject(mage.game.stack.StackObject) Spell(mage.game.stack.Spell)

Aggregations

Spell (mage.game.stack.Spell)1 StackObject (mage.game.stack.StackObject)1 Player (mage.players.Player)1 FirstSpellCastThisTurnWatcher (mage.watchers.common.FirstSpellCastThisTurnWatcher)1