Package mage.game.events

Examples of mage.game.events.ZoneChangeEvent


  }

  @Override
  public boolean applies(GameEvent event, Ability source, Game game) {
    if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
      ZoneChangeEvent zcEvent = (ZoneChangeEvent) event;
      if (zcEvent.getFromZone() == Zone.HAND && zcEvent.getToZone() == Zone.GRAVEYARD) {
        StackObject spell = game.getStack().getStackObject(event.getSourceId());
        if (spell != null && game.getOpponents(source.getControllerId()).contains(spell.getControllerId())) {
          return true;
        }
      }
View Full Code Here


    if (event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
      trigger(game, this.controllerId);
      return true;
    }
    if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId()) ) {
      ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
      if (zEvent.getToZone() == Zone.BATTLEFIELD) {
        trigger(game, this.controllerId);
        return true;
      }
    }
    return false;
View Full Code Here

  public void handleEvent(GameEvent event, Game game) {
    watchers.watch(event, game);
    if (!replaceEvent(event, game)) {
      //TODO: this is awkward - improve
      if (event.getType() == EventType.ZONE_CHANGE) {
        ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
        if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
          if (zEvent.getTarget() instanceof PermanentCard) {
            ((PermanentCard)zEvent.getTarget()).checkPermanentOnlyTriggers(zEvent, game);
          }
          else {
            zEvent.getTarget().checkTriggers(zEvent.getFromZone(), event, game);
            zEvent.getTarget().checkTriggers(zEvent.getToZone(), event, game);
          }
        }
      }
      for (Player player: players.values()) {
        player.checkTriggers(event, game);
View Full Code Here

  }

  @Override
  public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
      ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
      if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

    }

    @Override
    public boolean checkTrigger(GameEvent event, Game game) {
        if (super.checkTrigger(event, game)) {
            ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
            if (zEvent.getTarget().getCounters().getCount(CounterType.P1P1) > 0) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        this.subtype = token.getSubtype();
    }

    @Override
    public boolean moveToZone(Zone zone, UUID sourceId, Game game, boolean flag) {
        if (!game.replaceEvent(new ZoneChangeEvent(this, this.getControllerId(), Zone.BATTLEFIELD, zone))) {
            game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
            if (game.getPlayer(controllerId).removeFromBattlefield(this, game)) {
                game.fireEvent(new ZoneChangeEvent(this, this.getControllerId(), Zone.BATTLEFIELD, zone));
                return true;
            }
        }
        return false;
    }
View Full Code Here

        return false;
    }

    @Override
    public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) {
        if (!game.replaceEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED))) {
            game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
            if (game.getPlayer(controllerId).removeFromBattlefield(this, game)) {
                game.fireEvent(new ZoneChangeEvent(this, sourceId, this.getControllerId(), Zone.BATTLEFIELD, Zone.EXILED));
                return true;
            }
        }
        return false;
    }
View Full Code Here

        if (controller != null && controller.removeFromBattlefield(this, game)) {
            if (isFaceDown() && isMorphCard()) {
                setFaceDown(false);
                game.getCard(this.getId()).setFaceDown(false); //TODO: Do this in a better way
            }
            ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
            if (!game.replaceEvent(event)) {
                Player owner = game.getPlayer(ownerId);
                game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
                if (owner != null) {
                    this.setControllerId(ownerId); // neccessary for e.g. abilities in graveyard or hand to not have a controller != owner
                    switch (event.getToZone()) {
                        case GRAVEYARD:
                            owner.putInGraveyard(card, game, !flag);
                            break;
                        case HAND:
                            owner.getHand().add(card);
                            break;
                        case EXILED:
                            game.getExile().getPermanentExile().add(card);
                            break;
                        case COMMAND:
                            game.addCommander(new Commander(card));
                            break;
                        case LIBRARY:
                            if (flag) {
                                owner.getLibrary().putOnTop(card, game);
                            } else {
                                owner.getLibrary().putOnBottom(card, game);
                            }
                            break;
                        case BATTLEFIELD:
                            //should never happen
                            break;
                    }
                    game.setZone(objectId, event.getToZone());
                    game.addSimultaneousEvent(event);
                    return game.getState().getZone(objectId) == toZone;
                }
            }
        }
View Full Code Here

            setFaceDown(false);
            game.getCard(this.getId()).setFaceDown(false); //TODO: Do this in a better way
        }
        Player controller = game.getPlayer(controllerId);
        if (controller != null && controller.removeFromBattlefield(this, game)) {
            ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects);
            if (!game.replaceEvent(event)) {
                game.rememberLKI(objectId, Zone.BATTLEFIELD, this);
                if (exileId == null) {
                    game.getExile().getPermanentExile().add(card);
                } else {
                    game.getExile().createZone(exileId, name).add(card);
                }
                game.setZone(objectId, event.getToZone());
                game.addSimultaneousEvent(event);
                return true;
            }
        }
        return false;
View Full Code Here

                game.setScopeRelevant(true);
                game.applyEffects();
                newToken.entersBattlefield(sourceId, game, Zone.OUTSIDE, true);
                game.setScopeRelevant(false);
                game.applyEffects();
                game.fireEvent(new ZoneChangeEvent(newToken, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));
                if (attacking && game.getCombat() != null) {
                    game.getCombat().addAttackingCreature(newToken.getId(), game);
                }
            }
            game.informPlayers(new StringBuilder(controller.getName()).append(" puts ")
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.