Search in sources :

Example 21 with DamagedEvent

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

the class QuestingBeastTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player opponent = game.getPlayer(event.getPlayerId());
    if (opponent == null || !event.getSourceId().equals(this.getSourceId()) || !opponent.hasOpponent(this.getControllerId(), game) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DamageTargetEffect(event.getAmount()));
    FilterPermanent filter = new FilterPlaneswalkerPermanent("planeswalker " + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    this.getTargets().clear();
    this.addTarget(new TargetPermanent(filter));
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) FilterPlaneswalkerPermanent(mage.filter.common.FilterPlaneswalkerPermanent)

Example 22 with DamagedEvent

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

the class VigorousChargeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        if (event.getSourceId().equals(this.sourceId)) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(damageEvent.getAmount()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 23 with DamagedEvent

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

the class BlindZealotTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player opponent = game.getPlayer(event.getPlayerId());
    if (opponent == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker" + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DestroyTargetEffect(), false, "destroy target creature or planeswalker that player controls");
    this.getEffects().clear();
    this.addEffect(new DoWhenCostPaid(ability, new DiscardTargetCost(new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE)), "Discard a creature card?"));
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) DoWhenCostPaid(mage.abilities.effects.common.DoWhenCostPaid) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) TargetCardInHand(mage.target.common.TargetCardInHand) DiscardTargetCost(mage.abilities.costs.common.DiscardTargetCost) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent)

Example 24 with DamagedEvent

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

the class IkraShidiqiTheUsurperTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedEvent damageEvent = (DamagedEvent) event;
    if (damageEvent.isCombatDamage()) {
        Permanent permanent = game.getPermanent(event.getSourceId());
        if (permanent != null && permanent.isCreature(game) && permanent.isControlledBy(this.getControllerId())) {
            this.getEffects().clear();
            this.getEffects().add(new GainLifeEffect(permanent.getToughness().getValue()));
            return true;
        }
    }
    return false;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect)

Example 25 with DamagedEvent

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

the class VenerableWarsingerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(event.getPlayerId());
    if (player == null || !event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterCard filter = new FilterCreatureCard("creature card with mana value " + event.getAmount() + " less from your graveyard");
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, event.getAmount() + 1));
    this.getTargets().clear();
    this.addTarget(new TargetCardInYourGraveyard(filter));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) DamagedEvent(mage.game.events.DamagedEvent) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard)

Aggregations

DamagedEvent (mage.game.events.DamagedEvent)30 Permanent (mage.game.permanent.Permanent)16 FilterPermanent (mage.filter.FilterPermanent)6 Player (mage.players.Player)6 UUID (java.util.UUID)5 GainLifeEffect (mage.abilities.effects.common.GainLifeEffect)5 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 HashSet (java.util.HashSet)3 MageObjectReference (mage.MageObjectReference)3 Effect (mage.abilities.effects.Effect)3 DrawCardSourceControllerEffect (mage.abilities.effects.common.DrawCardSourceControllerEffect)3 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 DamagedPlayerBatchEvent (mage.game.events.DamagedPlayerBatchEvent)3 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)2 FilterCard (mage.filter.FilterCard)2 DamagedPermanentBatchEvent (mage.game.events.DamagedPermanentBatchEvent)2 TargetPermanent (mage.target.TargetPermanent)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 java.util (java.util)1