@Override
 public int getPointValue() {
   int pointValue = 0;
   for (Creature critter : getCreatures()) {
     pointValue += critter.getPointValue();
   }
   return pointValue;
 }
 /** Gets the first critter in this legion with the same creature type as the passed creature. */
 Creature getCritter(CreatureType creatureType) {
   for (Creature creature : getCreatures()) {
     if (creature.getType().equals(creatureType)) {
       return creature;
     }
   }
   return null;
 }
 /**
  * Do the cleanup associated with removing the critter from this legion. Do not actually remove
  * it, to prevent co-modification errors. Do not disband the legion if empty, since the critter
  * has not actually been removed.
  */
 void prepareToRemoveCritter(Creature critter, boolean returnToStacks, boolean updateHistory) {
   if (critter == null || !getCreatures().contains(critter)) {
     LOGGER.log(Level.SEVERE, "Called prepareToRemoveCritter with bad critter");
     return;
   }
   // Put even immortal creatures in the graveyard; they will be
   // pulled back out later.
   if (returnToStacks) {
     game.getCaretaker().putDeadOne(critter.getType());
   }
   if (updateHistory) {
     game.removeCreatureEvent(this, critter.getType(), Constants.reasonKilled);
   }
 }
  /**
   * Remove the creature in position i in the legion. Return the removed creature. Put immortal
   * creatures back on the stack and others to the Graveyard if returnImmortalToStack is true.
   */
  CreatureType removeCreature(int i, boolean returnToStack, boolean disbandIfEmpty) {
    Creature critter = getCreatures().remove(i);

    // If the creature is an immortal, put it back in the stacks.
    if (returnToStack) {
      if (critter.isImmortal()) {
        game.getCaretaker().putOneBack(critter.getType());
      } else {
        game.getCaretaker().putDeadOne(critter.getType());
      }
    }

    // If there are no critters left, disband the legion.
    if (disbandIfEmpty && getHeight() == 0) {
      remove(false, true);
    }
    // return a Creature, not a Critter
    return critter.getType();
  }
  /** List the lords eligible to teleport this legion to hexLabel. */
  List<CreatureType> listTeleportingLords(MasterHex hex) {
    // Needs to be a List not a Set so that it can be passed as
    // an imageList.
    List<CreatureType> lords = new ArrayList<CreatureType>();

    // Titan teleport
    if (game.getNumEnemyLegions(hex, getPlayer()) >= 1) {
      for (Creature creature : getCreatures()) {
        if (creature.isTitan()) {
          lords.add(creature.getType());
        }
      }
    }

    // Tower teleport
    else {
      for (Creature critter : getCreatures()) {
        if (critter.isLord()) {
          if (!lords.contains(critter)) {
            lords.add(critter.getType());
          }
        }
      }
    }

    return lords;
  }
  /**
   * Recombine this legion into another legion. Only remove this legion from the Player if remove is
   * true. If it's false, the caller is responsible for removing this legion, which can avoid
   * concurrent access problems. Someone needs to call MasterBoard.alignLegions() on the remaining
   * legion's hexLabel after the recombined legion is actually removed.
   */
  void recombine(Legion legion, boolean remove) {
    // Sanity check
    if (legion == this) {
      LOGGER.log(Level.WARNING, "Tried to recombine a legion with itself!");
      return;
    }
    for (Creature critter : getCreatures()) {
      ((LegionServerSide) legion).addCreature(critter.getType(), false);
    }

    if (remove) {
      remove(false, false);
    } else {
      prepareToRemove(false, false);
    }

    LOGGER.log(Level.INFO, "Legion " + this + " recombined into legion " + legion);

    sortCritters();

    // Let the clients know that the legions have recombined.
    game.getServer().undidSplit(this, legion, true, game.getTurnNumber());
  }