Search in sources :

Example 41 with DamagedPlayerEvent

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

the class NecropolisRegentTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedPlayerEvent) event).isCombatDamage()) {
        Permanent creature = game.getPermanent(event.getSourceId());
        if (creature != null && creature.isControlledBy(controllerId)) {
            this.getEffects().clear();
            Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(event.getAmount()));
            effect.setTargetPointer(new FixedTarget(creature.getId(), game));
            this.addEffect(effect);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 42 with DamagedPlayerEvent

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

the class QuartzwoodCrasherWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
        damageMap.clear();
        return;
    }
    if (event.getType() != GameEvent.EventType.DAMAGED_PLAYER || !((DamagedPlayerEvent) event).isCombatDamage()) {
        return;
    }
    Permanent creature = game.getPermanent(event.getSourceId());
    if (creature == null || !creature.hasAbility(TrampleAbility.getInstance(), game)) {
        return;
    }
    damageMap.computeIfAbsent(event.getTargetId(), x -> new HashMap<>()).compute(creature.getControllerId(), (uuid, i) -> i == null ? event.getAmount() : event.getAmount() + i);
}
Also used : java.util(java.util) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) OneShotEffect(mage.abilities.effects.OneShotEffect) MageInt(mage.MageInt) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) TriggeredAbilityImpl(mage.abilities.TriggeredAbilityImpl) Game(mage.game.Game) Watcher(mage.watchers.Watcher) GameEvent(mage.game.events.GameEvent) DinosaurBeastToken(mage.game.permanent.token.DinosaurBeastToken) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) TrampleAbility(mage.abilities.keyword.TrampleAbility) mage.constants(mage.constants) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 43 with DamagedPlayerEvent

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

the class StensiaMasqueradeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent permanent = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) {
        this.getEffects().clear();
        AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
        effect.setTargetPointer(new FixedTarget(permanent, game));
        this.addEffect(effect);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 44 with DamagedPlayerEvent

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

the class SwordOfBodyAndMindAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
        this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 45 with DamagedPlayerEvent

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

the class SwordOfFeastAndFamineAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
        this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Aggregations

DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)52 Permanent (mage.game.permanent.Permanent)37 FixedTarget (mage.target.targetpointer.FixedTarget)21 Player (mage.players.Player)14 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)13 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)11 TargetPermanent (mage.target.TargetPermanent)10 Effect (mage.abilities.effects.Effect)9 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)8 OneShotEffect (mage.abilities.effects.OneShotEffect)7 FilterCard (mage.filter.FilterCard)4 FilterPermanent (mage.filter.FilterPermanent)4 OwnerIdPredicate (mage.filter.predicate.card.OwnerIdPredicate)4 java.util (java.util)3 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)3 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 Game (mage.game.Game)3 TargetCardInGraveyard (mage.target.common.TargetCardInGraveyard)3 MageInt (mage.MageInt)2