Implement enter scores page with per-field and round validation
Each player gets a number input; scores are validated individually (divisible by 5, ≤ 110) and as a round (must sum to −110). Submit stays disabled until all constraints pass. A running sum indicator turns green when the round is valid. Submitting appends the round to game state and persists it to localStorage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -37,12 +37,15 @@ export default function App() {
|
||||
setPage('scoresheet')
|
||||
}
|
||||
|
||||
function handleSubmitScores() {
|
||||
function handleSubmitScores(scores: number[]) {
|
||||
const updated: GameState = { ...game!, rounds: [...game!.rounds, scores] }
|
||||
saveGame(updated)
|
||||
setGame(updated)
|
||||
setPage('scoresheet')
|
||||
}
|
||||
|
||||
if (page === 'title') return <TitleScreen onNewGame={handleNewGame} />
|
||||
if (page === 'setup') return <PlayerSetup onStart={handleStart} />
|
||||
if (page === 'scoresheet') return <ScoreSheet game={game!} onScoreRound={() => setPage('enterscores')} onNewGame={handleNewGame} />
|
||||
if (page === 'enterscores') return <EnterScores onSubmit={handleSubmitScores} />
|
||||
if (page === 'enterscores') return <EnterScores game={game!} onSubmit={handleSubmitScores} />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user