/** * 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()); }
/** Eliminate this legion. */ void remove(boolean returnCrittersToStacks, boolean updateHistory) { prepareToRemove(returnCrittersToStacks, updateHistory); if (getPlayer() != null) { getPlayer().removeLegion(this); } }