public boolean isRoundOver() { boolean roundIsOver = true; if (this.match != null) { if (!this.match.hasEnded()) { roundIsOver = false; } } return roundIsOver; } }
public void finishPlayersThatPlayedLastRound() { if (match != null && match.hasEnded()) { if (!player1.isEliminated()) { player1.setEliminated(); player1.setState(TournamentPlayerState.FINISHED); } if (!player2.isEliminated()) { player2.setEliminated(); player2.setState(TournamentPlayerState.FINISHED); } } }
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; }
} else { MatchPlayer matchPlayer = match.getPlayer(playerId); if (matchPlayer != null && !match.hasEnded() && !matchPlayer.hasQuit()) { Game game = match.getGame(); if (game != null && !game.hasEnded()) {
/** * Called by eliminate tournaments after each match */ public void eliminatePlayers() { if (match != null && match.hasEnded()) { MatchPlayer mPlayer1 = match.getPlayer(player1.getPlayer().getId()); MatchPlayer mPlayer2 = match.getPlayer(player2.getPlayer().getId()); if (mPlayer1.hasQuit() || !mPlayer1.isMatchWinner()) { player1.setEliminated(); } if (mPlayer2.hasQuit() || !mPlayer2.isMatchWinner()) { player2.setEliminated(); } } } public void finishPlayersThatPlayedLastRound() {
for (TournamentPairing pair : round.getPairs()) { Match match = pair.getMatch(); if (match != null && match.hasEnded()) { TournamentPlayer tp1 = pair.getPlayer1(); TournamentPlayer tp2 = pair.getPlayer2();
for (TournamentPairing pair : round.getPairs()) { Match match = pair.getMatch(); if (match != null && match.hasEnded()) { MatchProto.Builder matchBuilder = roundBuilder.addMatchesBuilder() .setName(match.getName())