Search in sources :

Example 1 with DamagedPlayerBatchEvent

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

the class HordewingSkaabTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        if (!damagedEvent.isCombatDamage()) {
            continue;
        }
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.ZOMBIE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DrawDiscardControllerEffect(opponents.size(), opponents.size()));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DrawDiscardControllerEffect(mage.abilities.effects.common.DrawDiscardControllerEffect) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 2 with DamagedPlayerBatchEvent

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

the class MalcolmKeenEyedNavigatorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new CreateTokenEffect(new TreasureToken(), opponents.size()));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) HashSet(java.util.HashSet)

Example 3 with DamagedPlayerBatchEvent

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

the class BreechesBrazenPlundererEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
    Set<UUID> opponents = new HashSet<>();
    for (DamagedEvent damagedEvent : dEvent.getEvents()) {
        Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
        if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
            continue;
        }
        opponents.add(damagedEvent.getTargetId());
    }
    if (opponents.size() < 1) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new BreechesBrazenPlundererEffect(opponents));
    return true;
}
Also used : DamagedPlayerBatchEvent(mage.game.events.DamagedPlayerBatchEvent) DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)3 UUID (java.util.UUID)3 DamagedEvent (mage.game.events.DamagedEvent)3 DamagedPlayerBatchEvent (mage.game.events.DamagedPlayerBatchEvent)3 Permanent (mage.game.permanent.Permanent)3 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1 DrawDiscardControllerEffect (mage.abilities.effects.common.DrawDiscardControllerEffect)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 TreasureToken (mage.game.permanent.token.TreasureToken)1