Show host and early stop

This commit is contained in:
Joey Yakimowich-Payne 2026-01-15 20:26:22 -07:00
commit eee3e7e47b
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
3 changed files with 34 additions and 6 deletions

View file

@ -850,12 +850,18 @@ export const useGame = () => {
});
const newScore = Math.max(0, currentPlayer.score + breakdown.total);
setPlayers(prev => prev.map(p => {
const updatedPlayers = playersRef.current.map(p => {
if (p.id !== playerId) return p;
return { ...p, score: newScore, previousScore: p.score, streak: newStreak, lastAnswerCorrect: isCorrect, selectedShape, pointsBreakdown: breakdown };
}));
});
setPlayers(updatedPlayers);
conn.send({ type: 'RESULT', payload: { isCorrect, scoreAdded: breakdown.total, newScore, breakdown } });
const allAnswered = updatedPlayers.every(p => p.lastAnswerCorrect !== null);
if (allAnswered && gameStateRef.current === 'QUESTION') {
endQuestion();
}
}
};
@ -1369,10 +1375,16 @@ export const useGame = () => {
setCurrentPlayerScore(newScore);
setCurrentStreak(newStreak);
setPlayers(prev => prev.map(p => {
const updatedPlayers = playersRef.current.map(p => {
if (p.id !== 'host') return p;
return { ...p, score: newScore, previousScore: p.score, streak: newStreak, lastAnswerCorrect: isCorrect, selectedShape: option.shape, pointsBreakdown: breakdown };
}));
});
setPlayers(updatedPlayers);
const allAnswered = updatedPlayers.every(p => p.lastAnswerCorrect !== null);
if (allAnswered && gameStateRef.current === 'QUESTION') {
endQuestion();
}
} else {
const option = arg as AnswerOption;
setSelectedOption(option);