diff options
author | Pacien TRAN-GIRARD | 2016-04-09 22:39:59 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-04-09 22:39:59 +0200 |
commit | dd3fa83b18bdfa2010dbaa372682bd11bdb3e9bb (patch) | |
tree | 852b85ee1739c3adcd6060f8dfc3693621927379 /src/ch/epfl | |
parent | 22f54da84e8e7e7a52fbc418ac6f168aff77997a (diff) | |
download | xblast-dd3fa83b18bdfa2010dbaa372682bd11bdb3e9bb.tar.gz |
Fix winner and game over state determination
Diffstat (limited to 'src/ch/epfl')
-rw-r--r-- | src/ch/epfl/xblast/server/GameState.java | 6 |
1 files changed, 3 insertions, 3 deletions
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 { | |||
425 | * @return true if all the players are dead or if the game reached the time limit | 425 | * @return true if all the players are dead or if the game reached the time limit |
426 | */ | 426 | */ |
427 | public boolean isGameOver() { | 427 | public boolean isGameOver() { |
428 | return this.alivePlayers().isEmpty() || this.ticks >= Ticks.TOTAL_TICKS; | 428 | return this.alivePlayers().size() <= this.players().size() - 1 || this.ticks >= Ticks.TOTAL_TICKS; |
429 | } | 429 | } |
430 | 430 | ||
431 | /** | 431 | /** |
@@ -443,8 +443,8 @@ public final class GameState { | |||
443 | * @return the ID of the player who won the game. | 443 | * @return the ID of the player who won the game. |
444 | */ | 444 | */ |
445 | public Optional<PlayerID> winner() { | 445 | public Optional<PlayerID> winner() { |
446 | if (this.players.size() == 1 && this.ticks < Ticks.TOTAL_TICKS) | 446 | if (this.alivePlayers().size() == 1) |
447 | return Optional.of(this.players.get(0).id()); | 447 | return Optional.of(this.alivePlayers().get(0).id()); |
448 | else | 448 | else |
449 | return Optional.empty(); | 449 | return Optional.empty(); |
450 | } | 450 | } |