Add game-over state and pre-populate names on new game

Highlights the winning player's column in green when the game ends,
changes the footer button to "New Game" (reusing the existing confirm
dialog), and pre-populates player names from the previous game when
starting a new one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 21:52:10 -05:00
parent 9201273dc4
commit e5fa0ae66f
4 changed files with 20 additions and 7 deletions
+3 -1
View File
@@ -23,8 +23,10 @@ function clearGame() {
export default function App() {
const [game, setGame] = useState<GameState | null>(loadGame)
const [page, setPage] = useState<Page>(() => (game ? 'scoresheet' : 'title'))
const [previousPlayers, setPreviousPlayers] = useState<string[] | undefined>(undefined)
function handleNewGame() {
setPreviousPlayers(game?.players)
clearGame()
setGame(null)
setPage('setup')
@@ -45,7 +47,7 @@ export default function App() {
}
if (page === 'title') return <TitleScreen onNewGame={handleNewGame} />
if (page === 'setup') return <PlayerSetup onStart={handleStart} />
if (page === 'setup') return <PlayerSetup onStart={handleStart} initialNames={previousPlayers} />
if (page === 'scoresheet') return <ScoreSheet game={game!} onScoreRound={() => setPage('enterscores')} onNewGame={handleNewGame} />
if (page === 'enterscores') return <EnterScores game={game!} onSubmit={handleSubmitScores} />
}