Search in sources :

Example 16 with DamagedEvent

use of mage.game.events.DamagedEvent in project mage by magefree.

the class SixthSenseTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedEvent) event).isCombatDamage()) {
        if (event.getSourceId().equals(getSourceId())) {
            this.getEffects().clear();
            this.addEffect(new DrawCardSourceControllerEffect(1));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 17 with DamagedEvent

use of mage.game.events.DamagedEvent in project mage by magefree.

the class FlashConscriptionTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        if (event.getSourceId().equals(this.sourceId)) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 18 with DamagedEvent

use of mage.game.events.DamagedEvent in project mage by magefree.

the class SunhomeEnforcerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        if (event.getSourceId().equals(this.sourceId)) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 19 with DamagedEvent

use of mage.game.events.DamagedEvent in project mage by magefree.

the class DealsCombatDamageToACreatureTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (permanent == null || !permanent.isCreature(game) || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    if (setTargetPointer) {
        for (Effect effect : this.getEffects()) {
            effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
            effect.setValue("damage", event.getAmount());
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedEvent(mage.game.events.DamagedEvent) Effect(mage.abilities.effects.Effect)

Example 20 with DamagedEvent

use of mage.game.events.DamagedEvent in project mage by magefree.

the class NoblePurposeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        Permanent permanent = game.getPermanent(event.getSourceId());
        if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.getControllerId())) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Aggregations

DamagedEvent (mage.game.events.DamagedEvent)30 Permanent (mage.game.permanent.Permanent)16 FilterPermanent (mage.filter.FilterPermanent)6 Player (mage.players.Player)6 UUID (java.util.UUID)5 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 HashSet (java.util.HashSet)3 MageObjectReference (mage.MageObjectReference)3 Effect (mage.abilities.effects.Effect)3 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)3 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 DamagedPlayerBatchEvent (mage.game.events.DamagedPlayerBatchEvent)3 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)2 FilterCard (mage.filter.FilterCard)2 DamagedPermanentBatchEvent (mage.game.events.DamagedPermanentBatchEvent)2 TargetPermanent (mage.target.TargetPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 java.util (java.util)1