private static String addRoundResult(int round, TournamentPairing pair, TournamentPlayer tournamentPlayer, TournamentPlayer opponentPlayer) { StringBuilder playerResult = new StringBuilder(tournamentPlayer.getResults()); playerResult.append('R').append(round).append(' '); playerResult.append(getMatchResultString(tournamentPlayer, opponentPlayer, pair.getMatch())); return playerResult.toString(); }
public RoundView(Round round) { try { for (TournamentPairing pair : round.getPairs()) { // get info of finished games from match if (pair.getMatch() != null) { for (GameInfo gameInfo : pair.getMatch().getGamesInfo()) { games.add(new TournamentGameView(round.getRoundNumber(), gameInfo.getMatchId(), gameInfo.getGameId(), gameInfo.getState(), gameInfo.getResult(), gameInfo.getPlayers(), gameInfo.getTableId())); } if (!pair.getMatch().hasEnded()) { int numberSavedGames = pair.getMatch().getGamesInfo().size(); if (pair.getMatch() != null) { int gameCount = 0; for (Game game : pair.getMatch().getGames()) { gameCount++; if (gameCount > numberSavedGames) { // only unfinished game info directly from game games.add(new TournamentGameView(round.getRoundNumber(), pair, game)); } } } } } } } catch (Exception ex) { ex.printStackTrace(); } }
public boolean isRoundOver() { boolean roundIsOver = true; for (TournamentPairing pair: pairs) { if (pair.getMatch() != null) { if (!pair.getMatch().hasEnded()) { roundIsOver = false; } else { if (!pair.isAlreadyPublished()) { tournament.updateResults(); pair.setAlreadyPublished(true); if (tournament instanceof TournamentSingleElimination) { pair.eliminatePlayers(); } // if it's the last round, finish all players for the tournament if their match is finished if (getRoundNumber() == tournament.getNumberRounds()) { pair.finishPlayersThatPlayedLastRound(); } } } } } return roundIsOver; }
TournamentGameView(int roundNum, TournamentPairing pair, Game game) { this.roundNum = roundNum; this.matchId = pair.getMatch().getId(); this.gameId = game.getId(); this.players = pair.getPlayer1().getPlayer().getName() + " - " + pair.getPlayer2().getPlayer().getName(); String duelingTime = ""; if (game.hasEnded()) { if (game.getEndTime() != null && game.getStartTime() != null) { duelingTime = " (" + DateFormat.getDuration((game.getEndTime().getTime() - game.getStartTime().getTime())/1000) + ')'; } this.state = "Finished" + duelingTime; this.result = game.getWinner(); } else { if (game.getStartTime() != null) { duelingTime = " (" + DateFormat.getDuration((new Date().getTime() - game.getStartTime().getTime())/1000) + ')'; } this.state = "Dueling" + duelingTime; this.result = ""; } this.tableId = pair.getTableId(); }
Match match = pair.getMatch(); if (match != null && match.hasEnded()) { TournamentPlayer tp1 = pair.getPlayer1();
.setRound(round.getRoundNumber()); for (TournamentPairing pair : round.getPairs()) { Match match = pair.getMatch(); if (match != null && match.hasEnded()) { MatchProto.Builder matchBuilder = roundBuilder.addMatchesBuilder()