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;
}
Aggregations