Search in sources :

Example 21 with ZoneChangeEvent

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

the class DiesCreatureTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent() || !filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
        return false;
    }
    getEffects().setValue("creatureDied", zEvent.getTarget());
    if (setTargetPointer) {
        this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game));
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent)

Example 22 with ZoneChangeEvent

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

the class BellBorcaSpectralSergeantWatcher method watch.

@Override
public void watch(GameEvent event, Game game) {
    if (event.getType() != GameEvent.EventType.ZONE_CHANGE || ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
        return;
    }
    Card card = game.getCard(event.getTargetId());
    if (card == null || card.isFaceDown(game)) {
        return;
    }
    int cmc = card.getManaValue();
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
        if (permanent == null || cmcMap.get(permanent.getId()) != null && cmcMap.get(permanent.getId()) >= cmc) {
            continue;
        }
        cmcMap.put(permanent.getId(), cmc);
    }
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) Card(mage.cards.Card)

Example 23 with ZoneChangeEvent

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

the class BurnAwayDelayedTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.isDiesEvent() && zEvent.getTarget() != null && zEvent.getTargetId().equals(getTargets().getFirstTarget())) {
        // else spell fizzles because target creature died
        this.getTargets().clear();
        Target target = new TargetPlayer();
        target.add(zEvent.getTarget().getControllerId(), game);
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Target(mage.target.Target) TargetPlayer(mage.target.TargetPlayer)

Example 24 with ZoneChangeEvent

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

the class DraugrNecromancerSpendAnyManaEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || permanent == null || !controller.hasOpponent(permanent.getControllerId(), game)) {
        return false;
    }
    return CardUtil.moveCardWithCounter(game, source, controller, permanent, Zone.EXILED, CounterType.ICE.createInstance());
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent)

Example 25 with ZoneChangeEvent

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

the class GutterGrimeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    UUID targetId = event.getTargetId();
    MageObject card = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
    if (card instanceof Permanent && !(card instanceof PermanentToken)) {
        Permanent permanent = (Permanent) card;
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        if (zEvent.isDiesEvent() && permanent.isControlledBy(this.controllerId) && (targetId.equals(this.getSourceId()) || (permanent.isCreature(game) && !(permanent instanceof PermanentToken)))) {
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) PermanentToken(mage.game.permanent.PermanentToken) UUID(java.util.UUID)

Aggregations

ZoneChangeEvent (mage.game.events.ZoneChangeEvent)94 Permanent (mage.game.permanent.Permanent)56 Player (mage.players.Player)27 FixedTarget (mage.target.targetpointer.FixedTarget)23 Card (mage.cards.Card)20 UUID (java.util.UUID)14 MageObject (mage.MageObject)11 MageObjectReference (mage.MageObjectReference)10 Effect (mage.abilities.effects.Effect)9 FilterCard (mage.filter.FilterCard)8 PermanentToken (mage.game.permanent.PermanentToken)8 FilterPermanent (mage.filter.FilterPermanent)7 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 Ability (mage.abilities.Ability)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)6 Spell (mage.game.stack.Spell)6 Zone (mage.constants.Zone)5 TargetPermanent (mage.target.TargetPermanent)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5