Search in sources :

Example 46 with DamagedPlayerEvent

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

the class TheRavensWarningTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
        DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
        Permanent p = game.getPermanent(event.getSourceId());
        if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) && !damagedPlayerIds.contains(event.getPlayerId()) && p.hasAbility(FlyingAbility.getInstance(), game)) {
            damagedPlayerIds.add(event.getPlayerId());
            this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
            return true;
        }
    }
    if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY || (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
        damagedPlayerIds.clear();
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 47 with DamagedPlayerEvent

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

the class DawningPuristTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
        FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("enchantment that player controls");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        filter.setMessage("enchantment controlled by " + game.getPlayer(event.getTargetId()).getLogName());
        this.getTargets().clear();
        this.addTarget(new TargetPermanent(filter));
        return true;
    }
    return false;
}
Also used : ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) TargetPermanent(mage.target.TargetPermanent) FilterEnchantmentPermanent(mage.filter.common.FilterEnchantmentPermanent)

Example 48 with DamagedPlayerEvent

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

the class ControllerDealtDamageByPiratesPredicate method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
        if (((DamagedPlayerEvent) event).isCombatDamage()) {
            Permanent creature = game.getPermanentOrLKIBattlefield(event.getSourceId());
            if (creature != null && creature.hasSubtype(SubType.PIRATE, game)) {
                if (damageSourceIds.containsKey(event.getTargetId())) {
                    damageSourceIds.get(event.getTargetId()).add(creature.getId());
                } else {
                    Set<UUID> creatureSet = new HashSet<>();
                    creatureSet.add(creature.getId());
                    damageSourceIds.put(event.getTargetId(), creatureSet);
                }
            }
        }
    }
}
Also used : FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) Permanent(mage.game.permanent.Permanent) TargetNonlandPermanent(mage.target.common.TargetNonlandPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 49 with DamagedPlayerEvent

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

the class BreathOfFuryEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent enchantment = game.getPermanent(getSourceId());
    if (damageEvent.isCombatDamage() && enchantment != null && enchantment.isAttachedTo(event.getSourceId())) {
        Permanent creature = game.getPermanent(enchantment.getAttachedTo());
        if (creature != null) {
            for (Effect effect : getEffects()) {
                effect.setValue("TriggeringCreatureId", creature.getId());
            }
            return true;
        }
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 50 with DamagedPlayerEvent

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

the class ChandrasIncineratorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
    if (dEvent.isCombatDamage() || !game.getOpponents(event.getTargetId()).contains(getControllerId()) || !game.getControllerId(event.getSourceId()).equals(getControllerId())) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DamageTargetEffect(event.getAmount()));
    FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker");
    filter.add(new ControllerIdPredicate(event.getTargetId()));
    this.getTargets().clear();
    this.addTarget(new TargetPermanent(filter));
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) TargetPermanent(mage.target.TargetPermanent) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

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