Search in sources :

Example 11 with DamagedEvent

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

the class HuntersInsightTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!mor.refersTo(event.getSourceId(), game) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    Permanent permanent = game.getPermanent(event.getTargetId());
    if (permanent != null && !permanent.isPlaneswalker(game)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
    return true;
}
Also used : DamagedEvent(mage.game.events.DamagedEvent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect)

Example 12 with DamagedEvent

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

the class MarkOfSakikoTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (((DamagedEvent) event).isCombatDamage()) {
        if (event.getSourceId().equals(getSourceId())) {
            this.getEffects().clear();
            Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
            effect.setTargetPointer(new FixedTarget(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) DamagedEvent(mage.game.events.DamagedEvent) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) AddManaToManaPoolTargetControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolTargetControllerEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) GainAbilityAttachedEffect(mage.abilities.effects.common.continuous.GainAbilityAttachedEffect)

Example 13 with DamagedEvent

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

the class AegarTheFreezingFlameWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) {
        return;
    }
    DamagedEvent dEvent = (DamagedEvent) event;
    MageObject sourceObject = game.getObject(event.getSourceId());
    if (sourceObject == null) {
        return;
    }
    if (game.getSpellOrLKIStack(event.getSourceId()) == null && !sourceObject.hasSubtype(SubType.GIANT, game) && !sourceObject.hasSubtype(SubType.WIZARD, game)) {
        return;
    }
    playerMap.computeIfAbsent(game.getControllerId(event.getSourceId()), x -> new HashSet<>()).add(new MageObjectReference(event.getTargetId(), game));
}
Also used : java.util(java.util) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) MageObjectReference(mage.MageObjectReference) MageInt(mage.MageInt) 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) DamagedEvent(mage.game.events.DamagedEvent) MageObject(mage.MageObject) mage.constants(mage.constants) DamagedEvent(mage.game.events.DamagedEvent) MageObject(mage.MageObject) MageObjectReference(mage.MageObjectReference)

Example 14 with DamagedEvent

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

the class BladegriffPrototypeAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(getControllerId());
    if (player == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by an opponent of " + player.getName());
    filter.add(Predicates.or(game.getOpponents(getControllerId()).stream().map(ControllerIdPredicate::new).collect(Collectors.toSet())));
    TargetPermanent target = new TargetPermanent(filter);
    target.setTargetController(event.getPlayerId());
    this.getTargets().clear();
    this.addTarget(target);
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) DamagedEvent(mage.game.events.DamagedEvent) TargetPermanent(mage.target.TargetPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent)

Example 15 with DamagedEvent

use of mage.game.events.DamagedEvent 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)

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