fix(card-sorting): enable New Game button during active gameplay

The "New Game" button in the mini nav menu now works even when in the
middle of a game.

When clicked during gameplay:
1. Transitions to setup phase first (to clean up game state)
2. Waits 100ms for setup phase to render
3. Automatically starts a new game

When clicked from setup or results phase:
- Starts new game immediately (existing behavior)

This allows players to quickly restart without manually going to setup
first, improving the game flow when players want to try again.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-10-23 21:30:21 -05:00
parent 0eefc332ac
commit f3f6eca1db
1 changed files with 10 additions and 1 deletions

View File

@ -41,7 +41,16 @@ export function GameComponent() {
: undefined
}
onNewGame={() => {
startGame()
// If currently playing, go to setup first to clean up, then start immediately
if (state.gamePhase === 'playing') {
goToSetup()
// Use a small delay to let setup phase render, then start new game
setTimeout(() => {
startGame()
}, 100)
} else {
startGame()
}
}}
>
<StandardGameLayout>