File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
workspaces/simon-game/src/app/components Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,27 @@ import { Box } from "./Box.tsx";
4
4
import { playNote } from "../util/playNote.ts" ;
5
5
import { config } from "../constants.ts" ;
6
6
7
+ type GameState = "pre-game" | "game-over" | "player-turn" | "cpu-turn" ;
8
+
7
9
export function App ( ) {
8
10
const [ playerMoves , setPlayerMoves ] = useState < readonly number [ ] > ( [ ] ) ;
11
+ const [ gameState , setGameState ] = useState < GameState > ( "pre-game" ) ;
12
+
13
+ if ( gameState === "pre-game" ) {
14
+ return (
15
+ < div style = { { display : "flex" , gap : 10 } } >
16
+ < button
17
+ onClick = { ( ) => {
18
+ setGameState ( "cpu-turn" ) ;
19
+ } }
20
+ >
21
+ Start Game
22
+ </ button >
23
+ Simon Game
24
+ </ div >
25
+ ) ;
26
+ }
27
+
9
28
return (
10
29
< >
11
30
< div style = { { display : "flex" , gap : 10 } } >
You can’t perform that action at this time.
0 commit comments