Search in sources :

Example 1 with FilterCreaturePlayerOrPlaneswalker

use of mage.filter.common.FilterCreaturePlayerOrPlaneswalker in project mage by magefree.

the class ToralfsHammerEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent dEvent = (DamagedEvent) event;
    if (dEvent.getExcess() < 1 || dEvent.isCombatDamage() || !game.getOpponents(getControllerId()).contains(game.getControllerId(event.getTargetId()))) {
        return false;
    }
    this.getEffects().clear();
    this.getTargets().clear();
    this.addEffect(new DamageTargetEffect(dEvent.getExcess()));
    FilterCreaturePlayerOrPlaneswalker filter = new FilterCreaturePlayerOrPlaneswalker();
    filter.getPermanentFilter().add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(event.getTargetId(), game))));
    this.addTarget(new TargetAnyTarget(filter));
    return true;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) FilterCreaturePlayerOrPlaneswalker(mage.filter.common.FilterCreaturePlayerOrPlaneswalker) MageObjectReferencePredicate(mage.filter.predicate.mageobject.MageObjectReferencePredicate) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) MageObjectReference(mage.MageObjectReference) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Aggregations

MageObjectReference (mage.MageObjectReference)1 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)1 FilterCreaturePlayerOrPlaneswalker (mage.filter.common.FilterCreaturePlayerOrPlaneswalker)1 MageObjectReferencePredicate (mage.filter.predicate.mageobject.MageObjectReferencePredicate)1 DamagedEvent (mage.game.events.DamagedEvent)1 TargetAnyTarget (mage.target.common.TargetAnyTarget)1