use of mage.filter.FilterInPlay in project mage by magefree.
the class PreventAllDamageByAllObjectsEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!super.applies(event, source, game) || !(event instanceof DamageEvent) || event.getAmount() <= 0) {
return false;
}
DamageEvent damageEvent = (DamageEvent) event;
if (!damageEvent.isCombatDamage() && onlyCombat) {
return false;
}
if (filter == null) {
return true;
}
MageObject damageSource = game.getObject(damageEvent.getSourceId());
if (damageSource == null) {
return false;
}
if (filter instanceof FilterInPlay) {
return ((FilterInPlay) filter).match(damageSource, source.getSourceId(), source.getControllerId(), game);
}
return filter.match(damageSource, game);
}
Aggregations