private void printEnd() { gameOutputController.writeMessageEnd(); for (int i = 0; i < playersCount; ++i) { gameOutputController.writePlayerPoints(players[i]); } Set<Player> winners = new HashSet<Player>(); winners.add(players[0]); int winnerScore = players[0].getScore(); for (int i = 1; i < playersCount; ++i) { int newScore = players[i].getScore(); if (newScore > winnerScore) { winners.clear(); winners.add(players[i]); winnerScore = newScore; } else if (newScore == winnerScore) { winners.add(players[i]); } } gameOutputController.writeWinners(winners); printTables(); }
private void printTables() { Table[] tables = new Table[playersCount]; for (int i = 0; i < playersCount; ++i) { tables[i] = players[i].getTable(); } gameOutputController.writeTables(tables); }
public boolean stop() { boolean ret = running; if (running) { running = false; gameOutputController.writeMessageStop(); unregisterAllPlayers(); } return ret; }
private void doPlay() { int rounds = getTable().getSize(); gameOutputController.writeMessageBegin(); for (int r = 0; (r < rounds) && running; ++r) { for (int p = 0; (p < playersCount) && running; ++p) { if (!(players[p] instanceof Bot)) printTables(); players[p].play(); } } if (running) { printEnd(); } }