Search in sources :

Example 31 with DamagedPlayerEvent

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

the class TeysaEnvoyOfGhostsTriggeredAbility 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)) {
        game.getState().setValue(sourceId.toString(), sourcePermanent.getControllerId());
        getEffects().get(0).setTargetPointer(new FixedTarget(event.getSourceId()));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 32 with DamagedPlayerEvent

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

the class UndercityReachesTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Plane cPlane = game.getState().getCurrentPlane();
    if (cPlane == null) {
        return false;
    }
    if (!cPlane.getPlaneType().equals(Planes.PLANE_UNDERCITY_REACHES)) {
        return false;
    }
    if (((DamagedPlayerEvent) event).isCombatDamage()) {
        Permanent creature = game.getPermanent(event.getSourceId());
        if (creature != null) {
            Effect effect = new DrawCardTargetEffect(StaticValue.get(1), true, false);
            effect.setTargetPointer(new FixedTarget(creature.getControllerId()));
            effect.apply(game, this);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) Plane(mage.game.command.Plane) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) RollPlanarDieEffect(mage.abilities.effects.common.RollPlanarDieEffect) MaximumHandSizeControllerEffect(mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) PlanarDieRollCostIncreasingEffect(mage.abilities.effects.common.cost.PlanarDieRollCostIncreasingEffect) Effect(mage.abilities.effects.Effect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 33 with DamagedPlayerEvent

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

the class InkEyesServantOfOniTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(this.sourceId) || !((DamagedPlayerEvent) event).isCombatDamage()) {
        return false;
    }
    Player damagedPlayer = game.getPlayer(event.getTargetId());
    if (damagedPlayer == null) {
        return false;
    }
    FilterCard filter = new FilterCard("creature in " + damagedPlayer.getName() + "'s graveyard");
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
    TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
    this.getTargets().clear();
    this.addTarget(target);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 34 with DamagedPlayerEvent

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

the class MordantDragonEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Player opponent = game.getPlayer(event.getPlayerId());
    if (!damageEvent.isCombatDamage() || !event.getSourceId().equals(this.getSourceId()) || opponent == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    this.getTargets().clear();
    this.addTarget(new TargetCreaturePermanent(filter));
    for (Effect effect : this.getAllEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        effect.setValue("damage", event.getAmount());
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 35 with DamagedPlayerEvent

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

the class MortalObstinacyAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent damageMakingCreature = game.getPermanent(event.getSourceId());
    return damageEvent.isCombatDamage() && damageMakingCreature != null && damageMakingCreature.getAttachments().contains(this.getSourceId());
}
Also used : TargetEnchantmentPermanent(mage.target.common.TargetEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) 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