Some changes to user / session / chat / tournament handling (not all tested yet).

This commit is contained in:
LevelX2 2014-08-28 17:18:36 +02:00
parent e8cfb2231c
commit d3a2ba683c
13 changed files with 105 additions and 86 deletions

View file

@ -455,6 +455,12 @@ public abstract class GameImpl implements Game, Serializable {
}
if (remainingPlayers <= 1 || numLosers >= state.getPlayers().size() - 1) {
end();
if (remainingPlayers == 0 && logger.isDebugEnabled()) {
logger.debug("DRAW for gameId: " + getId());
for (Player player: state.getPlayers().values()) {
logger.debug("-- " + player.getName() + " left: " + (player.hasLeft() ? "Y":"N") + " lost: " + (player.hasLost()? "Y":"N"));
}
}
for (Player player: state.getPlayers().values()) {
if (!player.hasLeft() && !player.hasLost()) {
logger.debug(new StringBuilder("Player ").append(player.getName()).append(" has won gameId: ").append(this.getId()));

View file

@ -444,7 +444,7 @@ public abstract class TournamentImpl implements Tournament {
protected void winners() {
List<TournamentPlayer> winners = new ArrayList<>();
int pointsWinner = Integer.MIN_VALUE;
int pointsWinner = 1; // with less than 1 point you can't win
for(TournamentPlayer tournamentPlayer: this.getPlayers()) {
if (pointsWinner < tournamentPlayer.getPoints()) {
winners.clear();
@ -454,7 +454,7 @@ public abstract class TournamentImpl implements Tournament {
winners.add(tournamentPlayer);
}
}
// set winner state for the players with the most points
// set winner state for the players with the most points > 0
for (TournamentPlayer tournamentPlayer: winners) {
tournamentPlayer.setStateInfo("Winner");
}

View file

@ -88,6 +88,7 @@ public class TournamentPlayer {
}
public void setEliminated() {
this.setDisconnectInfo("");
this.setState(TournamentPlayerState.ELIMINATED);
this.eliminated = true;
}