Search in sources :

Example 1 with DamagedPermanentBatchEvent

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

the class FiendlashEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent equipment = game.getPermanent(this.getSourceId());
    if (equipment == null) {
        return false;
    }
    UUID attachedCreature = equipment.getAttachedTo();
    if (attachedCreature == null) {
        return false;
    }
    game.getState().setValue("Fiendlash" + equipment.getId(), attachedCreature);
    DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        UUID targetID = damagedEvent.getTargetId();
        if (targetID == null) {
            continue;
        }
        if (targetID == attachedCreature) {
            return true;
        }
    }
    return false;
}
Also used : DamagedPermanentBatchEvent(mage.game.events.DamagedPermanentBatchEvent) Permanent(mage.game.permanent.Permanent) DamagedEvent(mage.game.events.DamagedEvent) UUID(java.util.UUID)

Example 2 with DamagedPermanentBatchEvent

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

the class DealtDamageToSourceTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
    int damage = dEvent.getEvents().stream().filter(damagedEvent -> getSourceId().equals(damagedEvent.getTargetId())).mapToInt(GameEvent::getAmount).sum();
    if (damage < 1) {
        return false;
    }
    this.getEffects().setValue("damage", damage);
    return true;
}
Also used : DamagedPermanentBatchEvent(mage.game.events.DamagedPermanentBatchEvent)

Example 3 with DamagedPermanentBatchEvent

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

the class HowlpackAvengerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
    int damage = dEvent.getEvents().stream().filter(damagedEvent -> isControlledBy(game.getControllerId(damagedEvent.getTargetId()))).mapToInt(GameEvent::getAmount).sum();
    if (damage < 1) {
        return false;
    }
    this.getEffects().setValue("damage", damage);
    return false;
}
Also used : DamagedPermanentBatchEvent(mage.game.events.DamagedPermanentBatchEvent)

Example 4 with DamagedPermanentBatchEvent

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

the class BlazingSunsteelEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent equipment = game.getPermanent(this.getSourceId());
    if (equipment == null) {
        return false;
    }
    UUID attachedCreature = equipment.getAttachedTo();
    if (attachedCreature == null) {
        return false;
    }
    int damage = 0;
    DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        UUID targetID = damagedEvent.getTargetId();
        if (targetID == null) {
            continue;
        }
        if (targetID == attachedCreature) {
            damage += damagedEvent.getAmount();
        }
    }
    if (damage > 0) {
        this.getEffects().setValue("equipped", attachedCreature);
        this.getEffects().setValue("damage", damage);
        return true;
    }
    return false;
}
Also used : DamagedPermanentBatchEvent(mage.game.events.DamagedPermanentBatchEvent) Permanent(mage.game.permanent.Permanent) DamagedEvent(mage.game.events.DamagedEvent) UUID(java.util.UUID)

Aggregations

DamagedPermanentBatchEvent (mage.game.events.DamagedPermanentBatchEvent)4 UUID (java.util.UUID)2 DamagedEvent (mage.game.events.DamagedEvent)2 Permanent (mage.game.permanent.Permanent)2