From dd3fa83b18bdfa2010dbaa372682bd11bdb3e9bb Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 9 Apr 2016 22:39:59 +0200 Subject: Fix winner and game over state determination --- src/ch/epfl/xblast/server/GameState.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ch') diff --git a/src/ch/epfl/xblast/server/GameState.java b/src/ch/epfl/xblast/server/GameState.java index 2797e41..6ff0ded 100644 --- a/src/ch/epfl/xblast/server/GameState.java +++ b/src/ch/epfl/xblast/server/GameState.java @@ -425,7 +425,7 @@ public final class GameState { * @return true if all the players are dead or if the game reached the time limit */ public boolean isGameOver() { - return this.alivePlayers().isEmpty() || this.ticks >= Ticks.TOTAL_TICKS; + return this.alivePlayers().size() <= this.players().size() - 1 || this.ticks >= Ticks.TOTAL_TICKS; } /** @@ -443,8 +443,8 @@ public final class GameState { * @return the ID of the player who won the game. */ public Optional winner() { - if (this.players.size() == 1 && this.ticks < Ticks.TOTAL_TICKS) - return Optional.of(this.players.get(0).id()); + if (this.alivePlayers().size() == 1) + return Optional.of(this.alivePlayers().get(0).id()); else return Optional.empty(); } -- cgit v1.2.3