Fix game.started not firing when Jackbox room is full
The waitForGameStart() function checked roomStatus.full before roomStatus.locked, causing it to short-circuit when a room was full but the game hadn't started yet. This meant game.started was never broadcast and watchGameAsAudience() was never called for full games. Now only locked=true triggers game start detection. When full=true but locked=false, the poller continues until the game actually starts. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -406,24 +406,20 @@ async function startPlayerCountCheck(sessionId, gameId, roomCode, maxPlayers = 8
|
||||
return false;
|
||||
}
|
||||
|
||||
// If full, we know the count immediately
|
||||
if (roomStatus.full) {
|
||||
console.log(`[Player Count] Room is FULL - ${roomStatus.maxPlayers} players`);
|
||||
updatePlayerCount(sessionId, gameId, roomStatus.maxPlayers, 'completed');
|
||||
stopPlayerCountCheck(sessionId, gameId);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If locked, game has started - ready to watch
|
||||
if (roomStatus.locked) {
|
||||
console.log(`[Player Count] Room is LOCKED - game in progress, starting watch`);
|
||||
// Return both status and real maxPlayers from Jackbox
|
||||
return { ready: true, maxPlayers: roomStatus.maxPlayers };
|
||||
}
|
||||
|
||||
// Not ready yet
|
||||
console.log(`[Player Count] Room not ready yet (lobby still open)`);
|
||||
return null;
|
||||
// Log if full but not yet started
|
||||
if (roomStatus.full) {
|
||||
console.log(`[Player Count] Room is FULL but not locked yet - waiting for game start`);
|
||||
} else {
|
||||
console.log(`[Player Count] Room not ready yet (lobby still open)`);
|
||||
}
|
||||
|
||||
return null; // Not ready, keep polling
|
||||
};
|
||||
|
||||
// Wait 10 seconds before first check
|
||||
|
||||
Reference in New Issue
Block a user