@Override public boolean applies(Ability abilityToModify, Ability source, Game game) { if (onlyControlled && !abilityToModify.isControlledBy(source.getControllerId())) { return false; } if (controllerId != null && !abilityToModify.isControlledBy(controllerId)) { return false; } if (abilityToModify instanceof SpellAbility) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); if (spell != null) { return this.filter.match(spell, game) && selectedByRuntimeData(spell, source, game); } else { // used at least for flashback ability because Flashback ability doesn't use stack Card sourceCard = game.getCard(abilityToModify.getSourceId()); return sourceCard != null && this.filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game); } } return false; }