Search in sources :

Example 11 with DamagedPlayerEvent

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

the class AnowonTheRuinThiefWatcher 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.hasSubtype(SubType.ROGUE, game)) {
        return;
    }
    damageMap.computeIfAbsent(event.getTargetId(), x -> new HashMap<>()).compute(creature.getControllerId(), (uuid, i) -> i == null ? event.getAmount() : event.getAmount() + i);
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) StaticFilters(mage.filter.StaticFilters) java.util(java.util) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) OneShotEffect(mage.abilities.effects.OneShotEffect) MageInt(mage.MageInt) Player(mage.players.Player) 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) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect) mage.constants(mage.constants) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 12 with DamagedPlayerEvent

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

the class AshlingTheExtinguisherTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
        Player opponent = game.getPlayer(event.getPlayerId());
        if (opponent != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
            filter.add(new ControllerIdPredicate(opponent.getId()));
            this.getTargets().clear();
            this.addTarget(new TargetCreaturePermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 13 with DamagedPlayerEvent

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

the class HarshJusticeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player controller = game.getPlayer(this.getControllerId());
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent damagePermanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
    if (controller != null && damagePermanent != null) {
        if (damageEvent.isCombatDamage() && controller.getId().equals(damageEvent.getTargetId()) && filter.match(damagePermanent, game)) {
            for (Effect effect : this.getEffects()) {
                effect.setValue("damage", damageEvent.getAmount());
                effect.setValue("sourceId", damageEvent.getSourceId());
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 14 with DamagedPlayerEvent

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

the class WrexialReplacementEffect 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("target instant or sorcery card from " + damagedPlayer.getName() + "'s graveyard");
    filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
    filter.add(Predicates.or(CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
    Target 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) Target(mage.target.Target) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 15 with DamagedPlayerEvent

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

the class BloodforgedBattleAxeAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    return damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId());
}
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