Search in sources :

Example 66 with ZoneChangeEvent

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

the class KunorosHoundOfAthreosCastEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.getToZone() != Zone.BATTLEFIELD || zEvent.getFromZone() != Zone.GRAVEYARD) {
        return false;
    }
    Card card = game.getCard(zEvent.getTargetId());
    return card != null && card.isCreature(game);
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Card(mage.cards.Card)

Example 67 with ZoneChangeEvent

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

the class SludgeStriderEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) {
        Permanent permanent = game.getPermanent(event.getTargetId());
        if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
            return true;
        }
    }
    if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
        ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
        if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
            UUID targetId = event.getTargetId();
            Permanent permanent = game.getPermanent(targetId);
            if (permanent == null) {
                permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD);
            }
            return permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game);
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) UUID(java.util.UUID)

Example 68 with ZoneChangeEvent

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

the class SpiritSistersCallPredicate method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    UUID targetId = zEvent.getTargetId();
    return targetId != null && targetId.equals(source.getSourceId()) && zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() != Zone.EXILED;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) UUID(java.util.UUID)

Example 69 with ZoneChangeEvent

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

the class SyrKonradTheGrimTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    // Whenever another creature dies
    if (zEvent.isDiesEvent() && zEvent.getTarget() != null && !zEvent.getTargetId().equals(this.getSourceId()) && zEvent.getTarget().isCreature(game)) {
        return true;
    }
    Card card = game.getCard(zEvent.getTargetId());
    // Or a creature card is put into a graveyard from anywhere other than the battlefield
    if (card == null || !card.isCreature(game)) {
        return false;
    }
    if (zEvent.getToZone() == Zone.GRAVEYARD && zEvent.getFromZone() != Zone.BATTLEFIELD) {
        return true;
    }
    // Or a creature card leaves your graveyard
    return zEvent.getFromZone() == Zone.GRAVEYARD && zEvent.getPlayerId() == this.getControllerId();
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Card(mage.cards.Card)

Example 70 with ZoneChangeEvent

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

the class UginsNexusExileEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    if (permanent != null) {
        permanent.moveToExile(null, "", source, game);
        new AddExtraTurnControllerEffect().apply(game, source);
        return true;
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) AddExtraTurnControllerEffect(mage.abilities.effects.common.turn.AddExtraTurnControllerEffect)

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