robotPeer.println("SYSTEM: game aborted.");
}
}
} else if (oneTeamRemaining()) {
boolean leaderFirsts = false;
TeamPeer winningTeam = null;
robocode.RoundEndedEvent roundEndedEvent = new robocode.RoundEndedEvent(getRoundNum(), currentTime,
totalTurns);
for (RobotPeer robotPeer : getRobotsAtRandom()) {
robotPeer.addEvent(roundEndedEvent);
if (robotPeer.isAlive() && !robotPeer.isWinner() && !robotPeer.isSentryRobot()) {
robotPeer.getRobotStatistics().scoreLastSurvivor();
robotPeer.setWinner(true);
robotPeer.println("SYSTEM: " + robotPeer.getNameForEvent(robotPeer) + " wins the round.");
robotPeer.addEvent(new WinEvent());
if (robotPeer.getTeamPeer() != null) {
if (robotPeer.isTeamLeader()) {
leaderFirsts = true;
} else {
winningTeam = robotPeer.getTeamPeer();
}
}
}
// Generate totals as round has ended, but first when the last scores has been calculated
robotPeer.getRobotStatistics().generateTotals();
}
if (!leaderFirsts && winningTeam != null) {
winningTeam.getTeamLeader().getRobotStatistics().scoreFirsts();
}
}
if (isAborted() || isLastRound()) {
List<RobotPeer> orderedRobots = new ArrayList<RobotPeer>(robots);
Collections.sort(orderedRobots);