// Add turns for protomechs weapons declaration.
if (protosMoveByPoint) {
// How many Protomechs does the player have?
Enumeration<Entity> playerProtos = game.getSelectedEntities(new EntitySelector() {
private final int ownerId = player.getId();
public boolean accept(Entity entity) {
if ((entity instanceof Protomech) && (ownerId == entity.getOwnerId()) && entity.isSelectableThisTurn()) {
return true;
}
return false;
}
});
HashSet<Integer> points = new HashSet<Integer>();
int numPlayerProtos = 0;
for (; playerProtos.hasMoreElements();) {
Entity proto = playerProtos.nextElement();
numPlayerProtos++;
points.add(new Integer(proto.getUnitNumber()));
}
int numProtoUnits = (int) Math.ceil(numPlayerProtos / 5.0);
if (!protosMoveEven) {
numProtoUnits = points.size();
}
for (int unit = 0; unit < numProtoUnits; unit++) {
if (protosMoveEven) {
player.incrementEvenTurns();
} else {
player.incrementOtherTurns();
}
}
} // End handle-proto-firing-turns
} // Handle the next player
// Go through all entities, and update the turn categories of the
// entity's player. The teams get their totals from their players.
// N.B. protomechs declare weapons fire based on their point.
for (Enumeration<Entity> loop = game.getEntities(); loop.hasMoreElements();) {
final Entity entity = loop.nextElement();
if (entity.isSelectableThisTurn()) {
final Player player = entity.getOwner();
if ((entity instanceof Infantry)) {
if (infMoveEven) {
player.incrementEvenTurns();
} else if (infMoveMulti) {
player.incrementMultiTurns();
} else {
player.incrementOtherTurns();
}
} else if (entity instanceof Protomech) {
if (!protosMoveByPoint) {
if (protosMoveEven) {
player.incrementEvenTurns();
} else if (protosMoveMulti) {
player.incrementMultiTurns();
} else {
player.incrementOtherTurns();
}
}
} else if ((entity instanceof Tank) && tankMoveByLance) {
player.incrementMultiTurns();
} else if ((entity instanceof SpaceStation) && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
player.incrementSpaceStationTurns();
} else if ((entity instanceof Warship) && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
player.incrementWarshipTurns();
} else if ((entity instanceof Jumpship) && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
player.incrementJumpshipTurns();
} else if ((entity instanceof Dropship) && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
player.incrementDropshipTurns();
} else if ((entity instanceof SmallCraft) && (game.getPhase() == IGame.Phase.PHASE_MOVEMENT)) {
player.incrementSmallCraftTurns();
} else {
player.incrementOtherTurns();
}
}
}
// Generate the turn order for the Players *within*
// each Team. Map the teams to their turn orders.
// Count the number of teams moving this turn.
int nTeams = game.getNoOfTeams();
Hashtable<Team, TurnVectors> allTeamTurns = new Hashtable<Team, TurnVectors>(nTeams);
Hashtable<Team, int[]> evenTrackers = new Hashtable<Team, int[]>(nTeams);
int numTeamsMoving = 0;
for (Enumeration<Team> loop = game.getTeams(); loop.hasMoreElements();) {
final Team team = loop.nextElement();
allTeamTurns.put(team, team.determineTeamOrder(game));
// Track both the number of times we've checked the team for
// "leftover" turns, and the number of "leftover" turns placed.
int[] evenTracker = new int[2];
evenTracker[0] = 0;
evenTracker[1] = 0;
evenTrackers.put(team, evenTracker);
// Count this team if it has any "normal" moves.
if (team.getNormalTurns(game) > 0) {
numTeamsMoving++;
}
}
// Now, generate the global order of all teams' turns.
TurnVectors team_order = TurnOrdered.generateTurnOrder(game.getTeamsVector(), game);
// See if there are any loaded units stranded on immobile transports.
Enumeration<Entity> strandedUnits = game.getSelectedEntities(new EntitySelector() {
public boolean accept(Entity entity) {
if (game.isEntityStranded(entity)) {
return true;
}
return false;