Package mage.game.events

Examples of mage.game.events.GameEvent


  }

  @Override
  public boolean addAttachment(UUID permanentId, Game game) {
    if (!this.attachments.contains(permanentId)) {
      if (!game.replaceEvent(new GameEvent(GameEvent.EventType.ATTACH, objectId, permanentId, controllerId))) {
        this.attachments.add(permanentId);
        Permanent attachment = game.getPermanent(permanentId);
        if (attachment != null) {
          attachment.attachTo(objectId);
          game.fireEvent(new GameEvent(GameEvent.EventType.ATTACHED, objectId, permanentId, controllerId));
          return true;
        }
      }
    }
    return false;
View Full Code Here


  }

  @Override
  public boolean removeAttachment(UUID permanentId, Game game) {
    if (this.attachments.contains(permanentId)) {
      if (!game.replaceEvent(new GameEvent(GameEvent.EventType.UNATTACH, objectId, permanentId, controllerId))) {
        this.attachments.remove(permanentId);
        Permanent attachment = game.getPermanent(permanentId);
        if (attachment != null) {
          attachment.attachTo(null);
        }
        game.fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, objectId, permanentId, controllerId));
        return true;
      }
    }
    return false;
  }
View Full Code Here

  public void removeAllDamage(Game game) {
    damage = 0;
  }

  protected int damagePlaneswalker(int damage, UUID sourceId, Game game, boolean preventable, boolean combat) {
    GameEvent event = new DamagePlaneswalkerEvent(objectId, sourceId, controllerId, damage, preventable, combat);
    if (!game.replaceEvent(event)) {
      int actualDamage = event.getAmount();
      if (actualDamage > 0) {
        if (event.getAmount() > this.loyalty.getValue()) {
          actualDamage = this.loyalty.getValue();
        }
        this.loyalty.boostValue(-actualDamage);
        game.fireEvent(new DamagedPlaneswalkerEvent(objectId, sourceId, controllerId, actualDamage, combat));
        return actualDamage;
View Full Code Here

    }
    return 0;
  }

  protected int damageCreature(int damage, UUID sourceId, Game game, boolean preventable, boolean combat) {
    GameEvent event = new DamageCreatureEvent(objectId, sourceId, controllerId, damage, preventable, combat);
    if (!game.replaceEvent(event)) {
      int actualDamage = event.getAmount();
      if (actualDamage > 0) {
        if (this.damage + event.getAmount() > this.toughness.getValue()) {
          actualDamage = this.toughness.getValue() - this.damage;
        }
        this.damage += actualDamage;
        game.fireEvent(new DamagedCreatureEvent(objectId, sourceId, controllerId, actualDamage, combat));
        return actualDamage;
View Full Code Here

    return true;
  }

  @Override
  public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), event.getAmount(), false);
    if (!game.replaceEvent(preventEvent)) {
      int damage = event.getAmount();
      event.setAmount(0);
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), damage));
    }
View Full Code Here

    }
    return false;
  }

  public boolean beginPhase(Game game, UUID activePlayerId) {
    if (!game.replaceEvent(new GameEvent(event, null, null, activePlayerId))) {
      game.fireEvent(new GameEvent(preEvent, null, null, activePlayerId));
      return true;
    }
    return false;
  }
View Full Code Here

    }
    return false;
  }

  public void endPhase(Game game, UUID activePlayerId) {
    game.fireEvent(new GameEvent(postEvent, null, null, activePlayerId));
  }
View Full Code Here

    return true;
  }

  @Override
  public void emptyManaPools() {
    if (!replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOLS, null, null, null))) {
      for (Player player: getPlayers().values()) {
        player.getManaPool().emptyPool();
      }
    }
  }
View Full Code Here

    return true;
  }

  @Override
  public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), event.getAmount(), false);
    if (!game.replaceEvent(preventEvent)) {
      int damage = event.getAmount();
      event.setAmount(0);
      game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), damage));
    }
View Full Code Here

    return true;
  }

  @Override
  public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), event.getAmount(), false);
    if (!game.replaceEvent(preventEvent)) {
      Player player = game.getPlayer(source.getFirstTarget());
      if (player != null) {
        if (event.getAmount() >= this.amount) {
          int damage = event.getAmount();
View Full Code Here

TOP

Related Classes of mage.game.events.GameEvent

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.