Skip to content

Commit e7e7942

Browse files
Raoul StraczowskiRaoul Straczowski
authored andcommitted
change difficulty should reset game
1 parent fd156fe commit e7e7942

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const App = () => {
2424
onDifficultyChange={setDifficulty}
2525
onClockDisplayModeChange={setClockDisplayMode}
2626
/>
27+
2728
<Header />
2829

2930
<div className="space-y-4">

src/store.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { playSuccessSound, playFailSound, playExpression } from './utils/play-so
44
import { getEncouragementMessage } from './utils/get-encouragement-message'
55
import { type Expression, Difficulty, ClockDisplayMode } from './types'
66

7-
8-
97
interface AppStore {
108
timeId: string | null
119
userInput: string
@@ -59,7 +57,14 @@ export const useStore = create<AppStore>((set, get) => ({
5957
}, 700)
6058
},
6159
setDifficulty: (difficulty: Difficulty) => {
62-
set({ difficulty })
60+
set({
61+
difficulty,
62+
timeId: null,
63+
userInput: '',
64+
result: null,
65+
allValidExpressions: null,
66+
encouragementMessage: null
67+
})
6368
},
6469
setClockDisplayMode: (mode: ClockDisplayMode) => {
6570
set({ clockDisplayMode: mode })

0 commit comments

Comments
 (0)