Remove client-side game over check to prevent premature game end
The client was checking activePlayers.length <= 1 and calling endGame() prematurely, before the server's authoritative game-over event. Now the client only ends the game when the server explicitly sends the 'game-over' event. Added server-side logging to track active player count and winner.
This commit is contained in:
+2
-7
@@ -70,13 +70,8 @@ function setupNetworkListeners() {
|
||||
localGame.loadState(localState);
|
||||
}
|
||||
|
||||
// Check for game over
|
||||
const allStates = network.getAllGameStates();
|
||||
const activePlayers = Object.values(allStates).filter(s => !s.eliminated);
|
||||
|
||||
if (activePlayers.length <= 1) {
|
||||
endGame(allStates);
|
||||
}
|
||||
// Game over is handled by the server via 'game-over' event
|
||||
// Don't check locally to avoid premature game end
|
||||
});
|
||||
|
||||
// Game over
|
||||
|
||||
Reference in New Issue
Block a user