Show host and early stop
This commit is contained in:
parent
1d8c08a680
commit
eee3e7e47b
3 changed files with 34 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue