Package mage.game.permanent

Examples of mage.game.permanent.Permanent


  public boolean isAttacked(UUID defenderId, Game game) {
    for (CombatGroup group: groups) {
      if (group.getDefenderId().equals(defenderId))
        return true;
      if (group.defenderIsPlaneswalker) {
        Permanent permanent = game.getPermanent(group.getDefenderId());
        if (permanent.getControllerId().equals(defenderId))
          return true;
      }
    }
    return false;
  }
View Full Code Here


  private Set<UUID> getPlayerDefenders(Game game) {
    Set<UUID> playerDefenders = new HashSet<UUID>();
    for (CombatGroup group: groups) {
      if (group.defenderIsPlaneswalker) {
        Permanent permanent = game.getPermanent(group.getDefenderId());
        if (permanent != null)
          playerDefenders.add(permanent.getControllerId());
      }
      else {
        playerDefenders.add(group.getDefenderId());
      }
    }
View Full Code Here

    return new DestroyTargetEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
      permanent.destroy(source.getId(), game, noRegen);
      return true;
    }
    return false;
  }
View Full Code Here

    }
    return sb.toString();
  }

  private void getPermanentValue(UUID permId, StringBuilder sb, Game game) {
    Permanent perm = game.getPermanent(permId);
    sb.append(perm.getValue());
  }
View Full Code Here

    return (first && hasFirstOrDoubleStrike(perm)) || (!first && !hasFirstStrike(perm));
  }

  private void unblockedDamage(boolean first, Game game) {
    for (UUID attackerId: attackers) {
      Permanent attacker = game.getPermanent(attackerId);
      if (canDamage(attacker, first)) {
        //20091005 - 510.1c, 702.17c
        if (!blocked || hasTrample(attacker))
          defenderDamage(attacker, attacker.getPower().getValue(), game);
      }
    }
  }
View Full Code Here

    }
  }

  private void singleBlockerDamage(boolean first, Game game) {
    //TODO:  handle banding
    Permanent blocker = game.getPermanent(blockers.get(0));
    Permanent attacker = game.getPermanent(attackers.get(0));
    if (blocker != null && attacker != null) {
      if (canDamage(attacker, first)) {
        int damage = attacker.getPower().getValue();
        if (hasTrample(attacker)) {
          int lethalDamage = blocker.getToughness().getValue() - blocker.getDamage();
          if (lethalDamage >= damage) {
            blocker.damage(damage, attacker.getId(), game, true, true);
          }
          else {
            Player player = game.getPlayer(attacker.getControllerId());
            int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game);
            blocker.damage(damageAssigned, attacker.getId(), game, true, true);
            damage -= damageAssigned;
            if (damage > 0)
              defenderDamage(attacker, damage, game);
          }
        }
        else {
          blocker.damage(damage, attacker.getId(), game, true, true);
        }
      }
      if (canDamage(blocker, first)) {
        attacker.damage(blocker.getPower().getValue(), blocker.getId(), game, true, true);
      }
    }
  }
View Full Code Here

    return new ExileTargetEffect(this);
  }

  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
      return permanent.moveToExile(exileId, exileZone, source.getId(), game);
    }
    return false;
  }
View Full Code Here

    }
  }

  private void multiBlockerDamage(boolean first, Game game) {
    //TODO:  handle banding
    Permanent attacker = game.getPermanent(attackers.get(0));
    Player player = game.getPlayer(attacker.getControllerId());
    int damage = attacker.getPower().getValue();
    if (attacker != null && canDamage(attacker, first)) {
      for (UUID blockerId: blockerOrder) {
        Permanent blocker = game.getPermanent(blockerId);
        int lethalDamage = blocker.getToughness().getValue() - blocker.getDamage();
        if (lethalDamage >= damage) {
          blocker.damage(damage, attacker.getId(), game, true, true);
          damage = 0;
          break;
        }
        int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game);
        blocker.damage(damageAssigned, attacker.getId(), game, true, true);
        damage -= damageAssigned;
      }
      if (damage > 0 && hasTrample(attacker)) {
        defenderDamage(attacker, damage, game);
      }
      for (UUID blockerId: blockerOrder) {
        Permanent blocker = game.getPermanent(blockerId);
        if (canDamage(blocker, first)) {
          attacker.damage(blocker.getPower().getValue(), blocker.getId(), game, true, true);
        }
      }
    }
  }
View Full Code Here

    }
  }

  private void defenderDamage(Permanent attacker, int amount, Game game) {
    if (this.defenderIsPlaneswalker) {
      Permanent defender = game.getPermanent(defenderId);
      if (defender != null) {
        defender.damage(amount, attacker.getId(), game, true, true);
      }
    }
    else {
      Player defender = game.getPlayer(defenderId);
      defender.damage(amount, attacker.getId(), game, true, true);
    }
  }
View Full Code Here

    for (UUID attackerId: attackers) {
      if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKER, attackerId, blockerId, playerId))) {
        return;
      }
    }
    Permanent blocker = game.getPermanent(blockerId);
    if (blockerId != null) {
      blocker.setBlocking(blocker.getBlocking() + 1);
      blockers.add(blockerId);
      blockerOrder.add(blockerId);
      this.blocked = true;
      for (UUID attackerId: attackers) {
        game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BLOCKER_DECLARED, attackerId, blockerId, playerId));
View Full Code Here

TOP

Related Classes of mage.game.permanent.Permanent

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.