refactor: improve game start logic to ensure all active players are ready before starting
All checks were successful
Build and Push Docker Image / docker (push) Successful in 8s

This commit is contained in:
2025-09-04 19:18:19 +02:00
parent 7361174b15
commit df8b9a3e00
3 changed files with 10 additions and 485 deletions

View File

@@ -56,8 +56,10 @@ export function renderRoom(room) {
$readyChk.parentElement.classList.toggle('hidden', room.state.status !== 'lobby');
}
const isHost = state.playerId === room.hostId;
const allReady = room.players.length>0 && room.players.every(p=>p.ready);
if ($startGame) $startGame.classList.toggle('hidden', !(isHost && room.state.status==='lobby' && allReady));
const activePlayers = room.players.filter(p => !p.spectator && p.connected);
const allReady = activePlayers.length>0 && activePlayers.every(p=>p.ready);
const canStart = room.state.status==='lobby' && isHost && allReady;
if ($startGame) $startGame.classList.toggle('hidden', !canStart);
const isMyTurn = room.state.status==='playing' && room.state.phase==='guess' && room.state.currentGuesser===state.playerId && room.state.currentTrack;
const canGuess = isMyTurn;
// Media controls (play/pause) only for current guesser while guessing and a track is active