Fix host screen
This commit is contained in:
parent
0de5a3bd8c
commit
5242f8d1f3
3 changed files with 44 additions and 8 deletions
|
|
@ -544,11 +544,26 @@ export const useGame = (defaultGameConfig?: GameConfig) => {
|
|||
await updateHostPeerId(session.pin, session.hostSecret!, peerId);
|
||||
}
|
||||
|
||||
if (hostData.gameState === 'LOBBY') {
|
||||
// Determine which state to restore to
|
||||
const savedState = hostData.gameState;
|
||||
const restoredPlayers = hostData.players || [];
|
||||
const allAnswered = restoredPlayers.length > 0 && restoredPlayers.every((p: Player) => p.lastAnswerCorrect !== null);
|
||||
|
||||
if (savedState === 'LOBBY') {
|
||||
setGameState('LOBBY');
|
||||
} else if (hostData.gameState === 'PODIUM') {
|
||||
} else if (savedState === 'PODIUM') {
|
||||
setGameState('PODIUM');
|
||||
} else if (savedState === 'REVEAL') {
|
||||
// Go directly to reveal screen - players may have already seen their results
|
||||
setGameState('REVEAL');
|
||||
} else if (savedState === 'SCOREBOARD') {
|
||||
// Go directly to scoreboard
|
||||
setGameState('SCOREBOARD');
|
||||
} else if (savedState === 'QUESTION' && allAnswered) {
|
||||
// All players answered while host was disconnected - go directly to reveal
|
||||
setGameState('REVEAL');
|
||||
} else {
|
||||
// For QUESTION or COUNTDOWN states where not everyone answered, show HOST_RECONNECTED to let them resume
|
||||
setGameState('HOST_RECONNECTED');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue