Package mage.game.events

Examples of mage.game.events.ZoneChangeEvent


  public boolean putOntoBattlefield(Game game, UUID sourceId, UUID controllerId) {
    PermanentToken permanent = new PermanentToken(this, controllerId);
    game.getBattlefield().addPermanent(permanent);
    permanent.entersBattlefield(sourceId, game);
    game.applyEffects();
    game.fireEvent(new ZoneChangeEvent(permanent, controllerId, Zone.OUTSIDE, Zone.BATTLEFIELD));
    return true;
  }
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))) {
      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))) {
      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

  @Override
  public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
    Zone fromZone = game.getZone(objectId);
    Player controller = game.getPlayer(controllerId);
    if (controller != null && controller.removeFromBattlefield(this, game)) {
      ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone);
      if (!game.replaceEvent(event)) {
        Card card = game.getCard(objectId);
        Player owner = game.getPlayer(ownerId);
        if (owner != null) {
          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 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.fireEvent(event);
          return game.getZone(objectId) == toZone;
        }
      }
    }
View Full Code Here

  @Override
  public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) {
    Zone fromZone = game.getZone(objectId);
    Player controller = game.getPlayer(controllerId);
    if (controller != null && controller.removeFromBattlefield(this, game)) {
      ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED);
      if (!game.replaceEvent(event)) {
        Card card = game.getCard(this.objectId);
        if (exileId == null) {
          game.getExile().getPermanentExile().add(card);
        }
        else {
          game.getExile().createZone(exileId, name).add(card);
        }
        game.setZone(objectId, event.getToZone());
        game.fireEvent(event);
        return true;
      }
    }
    return false;
View Full Code Here

  }

  @Override
  public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag) {
    Zone fromZone = game.getZone(objectId);
    ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, ownerId, fromZone, toZone);
    if (!game.replaceEvent(event)) {
      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));
          break;
        case EXILED:
          game.getExile().getPermanentExile().add(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.getBattlefield().addPermanent(permanent);
          permanent.entersBattlefield(sourceId, game);
          game.applyEffects();
          if (flag)
            permanent.setTapped(true);
          break;
      }
      game.setZone(objectId, event.getToZone());
      game.fireEvent(event);
      return game.getZone(objectId) == toZone;
    }
    return false;
  }
View Full Code Here

  }

  @Override
  public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game) {
    Zone fromZone = game.getZone(objectId);
    ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, ownerId, fromZone, Zone.EXILED);
    if (!game.replaceEvent(event)) {
      if (exileId == null) {
        game.getExile().getPermanentExile().add(this);
      }
      else {
        game.getExile().createZone(exileId, name).add(this);
      }
      game.setZone(objectId, event.getToZone());
      game.fireEvent(event);
      return true;
    }
    return false;
  }
View Full Code Here

    PermanentCard permanent = new PermanentCard(this, controllerId);
    game.getBattlefield().addPermanent(permanent);
    game.setZone(objectId, Zone.BATTLEFIELD);
    game.applyEffects();
    permanent.entersBattlefield(sourceId, game);
    game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
    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

  public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getType() == EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
      return true;
    }
    if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId()) ) {
      ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
      if (zEvent.getToZone() == Zone.BATTLEFIELD) {
        return true;
      }
    }
    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.