diff --git a/src/TicTacToe/Root.tsx b/src/TicTacToe/Root.tsx index d565e6e..f735d01 100644 --- a/src/TicTacToe/Root.tsx +++ b/src/TicTacToe/Root.tsx @@ -13,9 +13,18 @@ function TicTacToe() { setGridState(gridState); } + function resetGridState() { + setGridState(Array(9).fill(0)); + setPlayerState(false); + setWinState(0); + } + function playTurn(index : number) { + if (winState) { + resetGridState() + return; + } if (gridState[index]) return; - if (winState) return; const newState = playerState ? 2 : 1; updateGridState(index, newState); @@ -106,9 +115,9 @@ function TicTacToe() {
{getStateChar(getState())}
+{getStateChar(state)}