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
All checks were successful
Build and Push Docker Image / docker (push) Successful in 8s
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user