diff --git a/src/App.tsx b/src/App.tsx index 23e4e9d..04ba19e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,8 +7,8 @@ import { PlayerModel } from "./models/player"; import TicTacToeBoard from "./games/tictactoe/TicTacToeBoard"; export default function App() { - // setting up a 2D game board - const [board, setBoard] = useState([[]]); + // setting up a 2D game boards + const [boards, setBoards] = useState>({}); const [turn, setTurn] = useState(0); const [winner, setWinner] = useState(null); const [gameOver, setGameOver] = useState(null); @@ -26,7 +26,7 @@ export default function App() { const state = msg.data; console.log("Match state:", state); - setBoard(state.board.grid); + setBoards(state.boards); setTurn(state.turn); setGameOver(state.game_over); if (state.winner >= 0) { @@ -114,7 +114,7 @@ export default function App() { }} > ; turn: number; winner: string | null; gameOver: boolean | null; @@ -15,7 +15,7 @@ interface BoardProps { } export default function TicTacToeBoard({ - board, + boards, turn, winner, gameOver, @@ -62,6 +62,7 @@ export default function TicTacToeBoard({ const nextLineIn = 3600; const allLinesStay = 2400; const allLinesFade = 1200; + const board = boards['tictactoe']?.grid ?? null; useEffect(() => { const totalTime = haiku.length * nextLineIn + allLinesStay + allLinesFade; @@ -107,7 +108,9 @@ export default function TicTacToeBoard({ {/* ------------------------- BOARD -------------------------- */} - Loading...} + + {board && + } {!winner && (