Search in sources :

Example 86 with ZoneChangeEvent

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

the class StormHeraldAttachableToPredicate method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ((ZoneChangeEvent) event).setToZone(Zone.EXILED);
    Permanent aura = ((ZoneChangeEvent) event).getTarget();
    MageObject sourceObject = source.getSourceObject(game);
    if (aura != null && sourceObject != null) {
        game.informPlayers(aura.getLogName() + "goes to exile instead (" + sourceObject.getLogName() + ")");
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObject(mage.MageObject)

Example 87 with ZoneChangeEvent

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

the class TheOzolithMoveCountersEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!super.checkTrigger(event, game)) {
        return false;
    }
    Permanent permanent = ((ZoneChangeEvent) event).getTarget();
    Counters counters = permanent.getCounters(game);
    if (counters.values().stream().mapToInt(Counter::getCount).noneMatch(x -> x > 0)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new TheOzolithLeaveEffect(counters));
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Counters(mage.counters.Counters)

Example 88 with ZoneChangeEvent

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

the class CommanderReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    String originToZone = zEvent.getToZone().toString().toLowerCase(Locale.ENGLISH);
    if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
        Permanent permanent = zEvent.getTarget();
        if (permanent != null) {
            Player player = game.getPlayer(permanent.getOwnerId());
            if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone instead " + originToZone + "?", source, game))) {
                zEvent.setToZone(Zone.COMMAND);
                if (!game.isSimulation()) {
                    game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone instead " + originToZone);
                }
            }
        }
    } else {
        Card card = null;
        if (zEvent.getFromZone() == Zone.STACK) {
            Spell spell = game.getStack().getSpell(event.getTargetId());
            if (spell != null) {
                card = game.getCard(spell.getSourceId());
            }
        }
        if (card == null) {
            card = game.getCard(event.getTargetId());
        }
        if (card != null) {
            Player player = game.getPlayer(card.getOwnerId());
            if (player != null && (forceToMove || player.chooseUse(Outcome.Benefit, "Move " + commanderTypeName + " to command zone instead " + originToZone + "?", source, game))) {
                ((ZoneChangeEvent) event).setToZone(Zone.COMMAND);
                if (!game.isSimulation()) {
                    game.informPlayers(player.getLogName() + " has moved their " + commanderTypeName + " to the command zone instead " + originToZone);
                }
            }
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) Spell(mage.game.stack.Spell) Card(mage.cards.Card)

Example 89 with ZoneChangeEvent

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

the class DauthiVoidwalkerPlayEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = ((ZoneChangeEvent) event).getTarget();
    if (card == null) {
        card = game.getCard(event.getTargetId());
    }
    if (controller == null || card == null) {
        return false;
    }
    CardUtil.moveCardWithCounter(game, source, controller, card, Zone.EXILED, CounterType.VOID.createInstance());
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 90 with ZoneChangeEvent

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

the class AthreosShroudVeiledEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    Permanent permanent = zEvent.getTarget();
    if (permanent == null || !permanent.isCreature(game) || !permanent.getCounters(game).containsKey(CounterType.COIN)) {
        return false;
    }
    this.getEffects().clear();
    this.addEffect(new AthreosShroudVeiledEffect(new MageObjectReference(zEvent.getTarget(), game)));
    return true;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) MageObjectReference(mage.MageObjectReference)

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