diff --git a/public/js/app.js b/public/js/app.js index e0c0347..7d5332a 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -27,6 +27,10 @@ function setupNetworkListeners() { if (ui.screens.room.classList.contains('active')) { ui.showScreen('lobby'); } + // Reset lobby state when returning from game over (player is null indicates game over reset) + if (!player) { + ui.resetLobbyState(); + } }); // Player left lobby @@ -225,6 +229,10 @@ function endGame(states) { network.isSpectator = false; ui.hideSpectatorMode(); + // Reset ready button state + ui.buttons.ready.textContent = 'READY'; + ui.buttons.ready.disabled = true; + ui.showGameOver(winner, scores); } diff --git a/public/js/ui.js b/public/js/ui.js index 06da636..18b4914 100644 --- a/public/js/ui.js +++ b/public/js/ui.js @@ -80,9 +80,24 @@ class UIManager { handleBackToLobby() { this.hideGameOver(); + this.resetLobbyState(); this.showScreen('room'); } + resetLobbyState() { + // Reset ready button to default state + this.buttons.ready.textContent = 'READY'; + this.buttons.ready.disabled = true; + + // Clear player and spectator lists + this.displays.playerList.innerHTML = ''; + this.displays.spectatorList.innerHTML = ''; + + // Reset game room name + this.displays.gameRoomName.textContent = 'GLOBAL LOBBY'; + this.displays.gameRoomName.classList.remove('spectator-mode'); + } + updatePlayerList(players) { this.displays.playerList.innerHTML = ''; Object.values(players).forEach(player => {