Package mage.game.events

Examples of mage.game.events.ZoneChangeEvent


    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == EventType.ZONE_CHANGE) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            if (zEvent.getFromZone() == Zone.BATTLEFIELD
                    && zEvent.getToZone() == Zone.GRAVEYARD) {
                Permanent permanent = game.getPermanent(event.getTargetId());
                if (filter.match(permanent, this.getSourceId(), this.getControllerId(), game)) {
                    if (setTargetPointer) {
                        for (Effect effect :this.getEffects()) {
                            effect.setTargetPointer(new FixedTarget(event.getSourceId()));
View Full Code Here


    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == EventType.ZONE_CHANGE) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) {
                Permanent perm;
                if (zEvent.getTarget() != null) {
                    perm = zEvent.getTarget();
                } else {
                    perm = game.getPermanent(event.getTargetId()); // LevelX2: maybe this part is not neccessary
                }
                if (perm != null && filter.match(perm, sourceId, controllerId, game)) {
                    return true;
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            if (zEvent.getTarget().getCardType().contains(CardType.CREATURE) &&
                    zEvent.getTarget().getDealtDamageByThisTurn().contains(this.sourceId)) {
                for (Effect effect : getEffects()) {
                    effect.setTargetPointer(new FixedTarget(event.getTargetId()));
                }
                return true;
            }
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType().equals(GameEvent.EventType.ZONE_CHANGE)) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            // why is this check neccessary?
//            if (game.getPermanentOrLKIBattlefield(sourceId) == null) {
//                return false;
//            }
            if (zEvent.getFromZone().equals(Zone.BATTLEFIELD) && zEvent.getToZone().equals(Zone.GRAVEYARD)) {
                Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
                if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) {
                    if (setTargetPointer) {
                        for (Effect effect : this.getEffects()) {
                            effect.setTargetPointer(new FixedTarget(event.getTargetId()));
View Full Code Here

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if ( event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId()) )
        {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if ( zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD ) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

    }

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType().equals(EventType.ZONE_CHANGE)) {
            ZoneChangeEvent  zce = (ZoneChangeEvent) event;
            if (zce.isDiesEvent()) {
                DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
                if (watcher != null) {
                    return watcher.wasDamaged(zce.getTarget());
                }
            }
        }
        return false;
    }
View Full Code Here

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {

            ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
            Permanent permanent = zEvent.getTarget();

            if (permanent != null &&
                    zEvent.getToZone() == Zone.GRAVEYARD &&
                    zEvent.getFromZone() == Zone.BATTLEFIELD &&
                    permanent.getId().equals(this.getSourceId())) {
                return true;
            }
        }
        return false;
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if ( event.getType() == EventType.ZONE_CHANGE ) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if ( zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD ) {
                Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
                if (p != null && p.getCardType().contains(CardType.CREATURE)) {
                    Permanent enchantment = game.getPermanent(getSourceId());
                    if (enchantment != null && enchantment.getAttachedTo() != null) {
                        return true;
View Full Code Here

    }

    @Override
    public boolean applies(GameEvent event, Ability source, Game game) {
        if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() != Zone.EXILED) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

    }

    @Override
    public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
        Zone fromZone = game.getState().getZone(objectId);
        ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, ownerId, fromZone, toZone, appliedEffects);
        if (!game.replaceEvent(event)) {
            if (event.getFromZone() != null) {
                switch (event.getFromZone()) {
                    case GRAVEYARD:
                        game.getPlayer(ownerId).removeFromGraveyard(this, game);
                        break;
                    case HAND:
                        game.getPlayer(ownerId).removeFromHand(this, game);
                        break;
                    case LIBRARY:
                        game.getPlayer(ownerId).removeFromLibrary(this, game);
                        break;
                    case EXILED:
                        game.getExile().removeCard(this, game);
                        break;
                    case OUTSIDE:
                        game.getPlayer(ownerId).getSideboard().remove(this);
                        break;
                    case COMMAND:
                        game.getState().getCommand().remove((Commander)game.getObject(objectId));
                        break;
                    case STACK:
                        StackObject stackObject = game.getStack().getSpell(getId());
                        if (stackObject != null) {
                            game.getStack().remove(stackObject);
                        }
                        break;
                    case PICK:
                    case BATTLEFIELD: // for sacrificing permanents or putting to library
                        break;
                    default:
                        Card sourceCard = game.getCard(sourceId);
                        logger.fatal(new StringBuilder("Invalid from zone [").append(fromZone)
                                .append("] for card [").append(this.getName())
                                .append("] to zone [").append(toZone)
                                .append("] source [").append(sourceCard != null ? sourceCard.getName():"null").append("]").toString());
                        break;
                }
                game.rememberLKI(objectId, event.getFromZone(), this);
            }
           
            if (isFaceDown() && !event.getToZone().equals(Zone.BATTLEFIELD)) { // to battlefield is possible because of Morph
                setFaceDown(false);
                game.getCard(this.getId()).setFaceDown(false);
            }
            updateZoneChangeCounter();
            switch (event.getToZone()) {
                case GRAVEYARD:
                    game.getPlayer(ownerId).putInGraveyard(this, game, !flag);
                    break;
                case HAND:
                    game.getPlayer(ownerId).getHand().add(this);
                    break;
                case STACK:
                    game.getStack().push(new Spell(this, this.getSpellAbility().copy(), ownerId, event.getFromZone()));
                    break;
                case EXILED:
                    game.getExile().getPermanentExile().add(this);
                    break;
                case COMMAND:
                    game.addCommander(new Commander(this));
                    break;
                case LIBRARY:
                    if (flag) {
                        game.getPlayer(ownerId).getLibrary().putOnTop(this, game);
                    }
                    else {
                        game.getPlayer(ownerId).getLibrary().putOnBottom(this, game);
                    }
                    break;
                case BATTLEFIELD:
                    PermanentCard permanent = new PermanentCard(this, ownerId);
                    game.resetForSourceId(permanent.getId());
                    game.addPermanent(permanent);
                    game.setZone(objectId, Zone.BATTLEFIELD);
                    game.setScopeRelevant(true);
                    game.applyEffects();
                    permanent.entersBattlefield(sourceId, game, event.getFromZone(), true);
                    game.setScopeRelevant(false);
                    game.applyEffects();
                    if (flag) {
                        permanent.setTapped(true);
                    }
                    event.setTarget(permanent);
                    break;
                default:
                    Card sourceCard = game.getCard(sourceId);
                    logger.fatal(new StringBuilder("Invalid to zone [").append(toZone)
                                .append("] for card [").append(this.getName())
                                .append("] to zone [").append(toZone)
                                .append("] source [").append(sourceCard != null ? sourceCard.getName():"null").append("]").toString());
                    return false;
            }
            setControllerId(ownerId);
            game.setZone(objectId, event.getToZone());
            game.addSimultaneousEvent(event);
            return game.getState().getZone(objectId) == toZone;
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of mage.game.events.ZoneChangeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.