Search in sources :

Example 36 with DamagedPlayerEvent

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

the class SakikoMotherOfSummerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedPlayerEvent) event).isCombatDamage()) {
        Permanent creature = game.getPermanent(event.getSourceId());
        if (creature != null && creature.isControlledBy(controllerId)) {
            this.getEffects().clear();
            Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
            effect.setTargetPointer(new FixedTarget(creature.getControllerId()));
            effect.setText("add that much {G}. Until end of turn, you don't lose this mana as steps and phases end");
            this.addEffect(effect);
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) Effect(mage.abilities.effects.Effect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 37 with DamagedPlayerEvent

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

the class SeshiroTheAnointedAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && p != null && p.hasSubtype(SubType.SNAKE, game) && p.isControlledBy(controllerId)) {
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 38 with DamagedPlayerEvent

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

the class SubiraTulzidiCaravannerAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
    if (!dEvent.isCombatDamage()) {
        return false;
    }
    Permanent permanent = game.getPermanent(event.getSourceId());
    return permanent != null && permanent.isControlledBy(getControllerId()) && permanent.isCreature(game) && permanent.getPower().getValue() <= 2;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 39 with DamagedPlayerEvent

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

the class CommanderInfoWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (checkCommanderDamage && event.getType() == GameEvent.EventType.DAMAGED_PLAYER && event instanceof DamagedPlayerEvent) {
        if (sourceId.equals(event.getSourceId())) {
            DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
            if (damageEvent.isCombatDamage()) {
                UUID playerUUID = event.getTargetId();
                Integer damage = damageToPlayer.getOrDefault(playerUUID, 0);
                damage += damageEvent.getAmount();
                damageToPlayer.put(playerUUID, damage);
                Player player = game.getPlayer(playerUUID);
                MageObject commander = game.getObject(sourceId);
                if (player != null && commander != null) {
                    if (!game.isSimulation()) {
                        game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getLogName() + " during the game.");
                    }
                    this.addCardInfoToCommander(game);
                }
            }
        }
    }
    // Add card info to the commander
    if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
        this.addCardInfoToCommander(game);
    }
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) UUID(java.util.UUID)

Example 40 with DamagedPlayerEvent

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

the class HammerOfRuinTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Permanent p = game.getPermanent(event.getSourceId());
    if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
        FilterPermanent filter = new FilterPermanent("Equipment that player controls");
        filter.add(SubType.EQUIPMENT.getPredicate());
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        filter.setMessage("creature controlled by " + game.getPlayer(event.getTargetId()).getLogName());
        this.getTargets().clear();
        this.addTarget(new TargetPermanent(filter));
        return true;
    }
    return false;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent) TargetPermanent(mage.target.TargetPermanent)

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