Search in sources :

Example 26 with DamagedPlayerEvent

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

the class DealsDamageToAPlayerAllTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (onlyCombat && !((DamagedPlayerEvent) event).isCombatDamage()) {
        return false;
    }
    if (targetController == TargetController.OPPONENT && !game.getOpponents(getControllerId()).contains(event.getTargetId())) {
        return false;
    }
    Permanent permanent = game.getPermanent(event.getSourceId());
    if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
        return false;
    }
    this.getEffects().setValue("damage", event.getAmount());
    this.getEffects().setValue("sourceId", event.getSourceId());
    if (affectsDefendingPlayer) {
        this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
    } else {
        switch(setTargetPointer) {
            case PLAYER:
                this.getEffects().setTargetPointer(new FixedTarget(permanent.getControllerId()));
                break;
            case PERMANENT:
                this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
                break;
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) FilterPermanent(mage.filter.FilterPermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 27 with DamagedPlayerEvent

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

the class DealsDamageToAPlayerAttachedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (targetController == TargetController.OPPONENT) {
        Player controller = game.getPlayer(this.getControllerId());
        if (controller == null || !game.isOpponent(controller, event.getPlayerId())) {
            return false;
        }
    }
    if (targetController == TargetController.YOU) {
        if (!this.isControlledBy(event.getPlayerId())) {
            return false;
        }
    }
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    if ((onlyCombat && !damageEvent.isCombatDamage()) || p == null || !p.getAttachments().contains(this.getSourceId())) {
        return false;
    }
    getEffects().setValue("damage", event.getAmount());
    if (setFixedTargetPointer) {
        getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 28 with DamagedPlayerEvent

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

the class HixusPrisonWardenExileEffect method checkTrigger.

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

Example 29 with DamagedPlayerEvent

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

the class RaidersSpoilsTriggeredAbility 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.WARRIOR, game) && permanent.isControlledBy(controllerId)) {
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 30 with DamagedPlayerEvent

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

the class StrixhavenStadiumEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent sourcePermanent = game.getPermanent(event.getSourceId());
    return isControlledBy(damageEvent.getTargetId()) && damageEvent.isCombatDamage() && sourcePermanent != null && sourcePermanent.isCreature(game);
}
Also used : 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