From cf7a4a4f89ac9b186fde77c161caae15b93eb996 Mon Sep 17 00:00:00 2001 From: DominicS99 Date: Tue, 12 Nov 2024 20:58:41 -0800 Subject: [PATCH 1/4] Adding GameState enum and barebones pre-game screen --- .../simon-game/src/app/components/App.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/workspaces/simon-game/src/app/components/App.tsx b/workspaces/simon-game/src/app/components/App.tsx index b04df109..3cd1bbf5 100644 --- a/workspaces/simon-game/src/app/components/App.tsx +++ b/workspaces/simon-game/src/app/components/App.tsx @@ -4,8 +4,27 @@ import { Box } from "./Box.tsx"; import { playNote } from "../util/playNote.ts"; import { config } from "../constants.ts"; +type GameState = "pre-game" | "game-over" | "player-turn" | "cpu-turn"; + export function App() { const [playerMoves, setPlayerMoves] = useState([]); + const [gameState, setGameState] = useState("pre-game"); + + if (gameState === "pre-game") { + return ( +
+ + Simon Game +
+ ); + } + return ( <>
From a26cd5b69ad353c31e76bddcc222b655763d5c4b Mon Sep 17 00:00:00 2001 From: DominicS99 Date: Tue, 12 Nov 2024 21:06:56 -0800 Subject: [PATCH 2/4] Addition of _correctMoves for tracking successful player turn. --- workspaces/simon-game/src/app/components/App.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/workspaces/simon-game/src/app/components/App.tsx b/workspaces/simon-game/src/app/components/App.tsx index 3cd1bbf5..a2bfedcc 100644 --- a/workspaces/simon-game/src/app/components/App.tsx +++ b/workspaces/simon-game/src/app/components/App.tsx @@ -9,6 +9,7 @@ type GameState = "pre-game" | "game-over" | "player-turn" | "cpu-turn"; export function App() { const [playerMoves, setPlayerMoves] = useState([]); const [gameState, setGameState] = useState("pre-game"); + const [_correctMoves, _setCorrectMoves] = useState([0,1,2,3]); if (gameState === "pre-game") { return ( From 8389dfe7cddca79ae61d2cc8c03d423d8c10e3da Mon Sep 17 00:00:00 2001 From: DominicS99 Date: Tue, 12 Nov 2024 21:08:33 -0800 Subject: [PATCH 3/4] Lint update: Forgot to run yarn format --- workspaces/simon-game/src/app/components/App.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workspaces/simon-game/src/app/components/App.tsx b/workspaces/simon-game/src/app/components/App.tsx index a2bfedcc..560ee4b4 100644 --- a/workspaces/simon-game/src/app/components/App.tsx +++ b/workspaces/simon-game/src/app/components/App.tsx @@ -9,7 +9,9 @@ type GameState = "pre-game" | "game-over" | "player-turn" | "cpu-turn"; export function App() { const [playerMoves, setPlayerMoves] = useState([]); const [gameState, setGameState] = useState("pre-game"); - const [_correctMoves, _setCorrectMoves] = useState([0,1,2,3]); + const [_correctMoves, _setCorrectMoves] = useState([ + 0, 1, 2, 3, + ]); if (gameState === "pre-game") { return ( From 371159a022c8bda95fb277762c46639beeafaaf7 Mon Sep 17 00:00:00 2001 From: DominicS99 Date: Tue, 12 Nov 2024 21:12:40 -0800 Subject: [PATCH 4/4] Keeping lint happy --- workspaces/simon-game/src/app/components/App.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/workspaces/simon-game/src/app/components/App.tsx b/workspaces/simon-game/src/app/components/App.tsx index 560ee4b4..5359b2ee 100644 --- a/workspaces/simon-game/src/app/components/App.tsx +++ b/workspaces/simon-game/src/app/components/App.tsx @@ -13,6 +13,8 @@ export function App() { 0, 1, 2, 3, ]); + console.log(_correctMoves, _setCorrectMoves); + if (gameState === "pre-game") { return (