Search in sources :

Example 1 with DamageEvent

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

the class DelayingShieldUpkeepEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    new AddCountersSourceEffect(CounterType.DELAY.createInstance(damageEvent.getAmount()), true).apply(game, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) DamageEvent(mage.game.events.DamageEvent)

Example 2 with DamageEvent

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

the class WallOfVaporEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) {
        DamageEvent damageEvent = (DamageEvent) event;
        if (event.getTargetId().equals(source.getSourceId())) {
            Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new BlockedByIdPredicate(source.getSourceId()));
            if (permanent != null && filter.match(permanent, game)) {
                return true;
            }
        }
    }
    return false;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamageEvent(mage.game.events.DamageEvent) BlockedByIdPredicate(mage.filter.predicate.permanent.BlockedByIdPredicate)

Example 3 with DamageEvent

use of mage.game.events.DamageEvent 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);
}
Also used : FilterInPlay(mage.filter.FilterInPlay) MageObject(mage.MageObject) DamageEvent(mage.game.events.DamageEvent)

Example 4 with DamageEvent

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

the class EqualTreatmentEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    damageEvent.setAmount(2);
    return false;
}
Also used : DamageEvent(mage.game.events.DamageEvent)

Example 5 with DamageEvent

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

the class ForceBubbleStateTriggeredAbility method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    new AddCountersSourceEffect(CounterType.DEPLETION.createInstance(damageEvent.getAmount()), true).apply(game, source);
    return true;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) DamageEvent(mage.game.events.DamageEvent)

Aggregations

DamageEvent (mage.game.events.DamageEvent)41 Player (mage.players.Player)25 Permanent (mage.game.permanent.Permanent)22 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)8 TargetPermanent (mage.target.TargetPermanent)7 MageObject (mage.MageObject)6 FilterPermanent (mage.filter.FilterPermanent)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)4 UUID (java.util.UUID)3 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)2 FilterSpell (mage.filter.FilterSpell)2 BlockedByIdPredicate (mage.filter.predicate.permanent.BlockedByIdPredicate)2 Spell (mage.game.stack.Spell)2 TargetSpell (mage.target.TargetSpell)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 PreventionEffectData (mage.abilities.effects.PreventionEffectData)1 SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)1 CardsImpl (mage.cards.CardsImpl)1 FilterInPlay (mage.filter.FilterInPlay)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1