From 3428fb365202313b0995d71510f103989bbc6ace Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Mon, 3 Oct 2022 17:12:02 -0700 Subject: [PATCH 01/23] file setup --- src/components/Board.js | 10 ++++++++++ src/components/ExecuteMoveButton.js | 10 ++++++++++ src/components/Tile.js | 17 +++++++++++++++++ src/context/GameContext.js | 13 +++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 src/components/Board.js create mode 100644 src/components/ExecuteMoveButton.js create mode 100644 src/components/Tile.js create mode 100644 src/context/GameContext.js diff --git a/src/components/Board.js b/src/components/Board.js new file mode 100644 index 0000000..4477383 --- /dev/null +++ b/src/components/Board.js @@ -0,0 +1,10 @@ +import React from 'react' +import Tile from './Tile' +import { useContext } from 'react'; +import { GameContext } from '../context/GameContext'; + +export default function Board() { + return ( +
Board
+ ) +} diff --git a/src/components/ExecuteMoveButton.js b/src/components/ExecuteMoveButton.js new file mode 100644 index 0000000..a85100b --- /dev/null +++ b/src/components/ExecuteMoveButton.js @@ -0,0 +1,10 @@ +import React from 'react' +import Tile from './Tile'; +import { useContext } from 'react'; +import { GameContext } from '../context/GameContext'; + +export default function ExecuteMoveButton() { + return ( +
ExecuteMoveButton
+ ) +} diff --git a/src/components/Tile.js b/src/components/Tile.js new file mode 100644 index 0000000..32cbc0e --- /dev/null +++ b/src/components/Tile.js @@ -0,0 +1,17 @@ +import React from 'react'; +import { useContext } from 'react'; +import { GameContext } from '../context/GameContext'; + +const tileType = { + circle: 'O', + ex: 'X', +} + +export default function Tile() { + + + return ( + <> + + ) +} \ No newline at end of file diff --git a/src/context/GameContext.js b/src/context/GameContext.js new file mode 100644 index 0000000..e5d6c96 --- /dev/null +++ b/src/context/GameContext.js @@ -0,0 +1,13 @@ +import { createContext, useState } from 'react'; + +const GameContext = createContext(); + +const GameProvider = ({ children }) => { + const gameState = { + + } + + return {children} +}; + +export { GameProvider, GameContext } \ No newline at end of file From 389a73bc0f6483f38dc06845080b2c7259da8d5f Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Mon, 3 Oct 2022 17:28:35 -0700 Subject: [PATCH 02/23] removed errors --- src/App.js | 17 ++--------------- src/Component_and_state_framework_v1.png | Bin 0 -> 13220 bytes src/components/Board.js | 6 +++--- src/components/Tile.js | 6 +++--- src/context/GameContext.js | 6 +++--- 5 files changed, 11 insertions(+), 24 deletions(-) create mode 100644 src/Component_and_state_framework_v1.png diff --git a/src/App.js b/src/App.js index 3784575..43a2e07 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,10 @@ -import logo from './logo.svg'; import './App.css'; +import Board from './components/Board'; function App() { return (
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+
); } diff --git a/src/Component_and_state_framework_v1.png b/src/Component_and_state_framework_v1.png new file mode 100644 index 0000000000000000000000000000000000000000..b0c3cf488cec6a298a3484baf4a348d96b72b608 GIT binary patch literal 13220 zcmeHuXH=6}+wP;h*l6QO8L28L2m(T+NfS^|=|zw(2%#6L(h&zTB27Ucbfk$$k>0_H zGzkO=EmRQ+HH01@l(U25jPE&XowLr5_d7q%_ru4P{XF~Lce}2A@4_=J4HddmtfwFd zqPuhZrVa#ApN62L5+{y=mZzf63E;mY?m8-pP*FGg9Qg4s8wGU*2znn)vui;OexG!` zZRid`zj{#q9T|snJ%%8d)Sa6OdXLQrW0Nn+ZYNyo5w{9bcl@|>j;)oxMnou1U?Sa3 zS^OQH?9q!cJS->q?uNc}zrejC7{}wP5bpnb_Wq1HkbLd}j0%EosKJjxP;ere7Bq<< z&w{6=C=5J5TEW5dj}A0={t}Bk0y4Mqkqh2N>r_=Egu1RTE|JA#PAaJRb2}OevTmxEitykCnk_2Bk8Q!~0*bbY zqGcF3732xDo{#ynVCxiA!i_xp1tZh=#6P+gHQCGC@EUc5c+6|D2QfIDEXR z(MHr=PI<)Tad|YZp{+J+WI$NXgM%GaVoW+BJoX-f{4W3@!Vy#UESK9XJo%&3$^zEV z>|XQIyH{a|vD}B^;p`01@?|S{a8n5%%)2Tc(G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s`uu)0de%5>!{*~Ji`OW z@P{s&VMgg*?sF^K=+UC2lcMe}GM@_2yN*GXhUNg=0w9GsJUHXwnes`NOA8sHAq?d^ zxW0=$Z32HT-wS@i36&Ux(93jZ)pVE)X z-7O+au`n)OE1gMZ!N!v16nAixR@+1S0*ZM(r}W z8(nV|G+_Kgt3%2uNdO*M5hn0D-Q^IS_rI{0jINhGuj#}OBt`!tY2HSce5Nl!g@?mt z29Ep1==lwQGCg3JQESKa?^3^S@%%+(B?&-Pp-zpaKX*^$pi;-=2y*)pI(rj7Q3OA= zUl-+&J{|k-s%in@nEgXI3+d{HC%STsG2Vuky6H}e&Bsho(^p=Ns=^*wiq;&w`>=5| zy?=lOuSX0ox1XMzHR3YjlgyyQL&ZX@`<#Tj2#(48|^|tFb zLfvyLia+1)0Cxu*#3TLz??S^`iSZ8SD$fwJly4l8&00B%*88nBTvGHW^zZoGXZA}@ z|7^D}+x=#WYq%qD3yz-}B%Rycnkb=t_V^`|>$%WgdY5;?NTF47S|_@UT=r>4@rcMz zGCuj-XZI@`X_{iV!~4JHr@o;f-vj*>$KD^ikD%yFMtGiFKYbk`%&MvQ$mr_cCAZ%k zdA&ZNX*O-%dxjpxGhr?{DgCu|Nm--Z4;)D^`p1LM29{JuF=FZJ-UFzDg zf2FcWtGWIwF5AgAKMr#JjY1Am3^bOr%XE{=?mc%{0w<8jghh;{0H78AH1)qXF%Oq$ zn}bz4tBVzvJ=@=`JzIAXU7P=1rlL{n#=FPjc0YDTL1EH`8cxq>l({e`DJ{_%)?@Uq zuOr^eBe*G{hh!`KMRM6tts=PghNSH2m@+PwF0KopqqVM&;t1HKsUYtDgVdR!#x|Z0 zORg!~V5 C%}-4L literal 0 HcmV?d00001 diff --git a/src/components/Board.js b/src/components/Board.js index 4477383..b128017 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -1,10 +1,10 @@ -import React from 'react' -import Tile from './Tile' +import React from 'react'; +import Tile from './Tile'; import { useContext } from 'react'; import { GameContext } from '../context/GameContext'; export default function Board() { return (
Board
- ) + ); } diff --git a/src/components/Tile.js b/src/components/Tile.js index 32cbc0e..5ee799f 100644 --- a/src/components/Tile.js +++ b/src/components/Tile.js @@ -5,13 +5,13 @@ import { GameContext } from '../context/GameContext'; const tileType = { circle: 'O', ex: 'X', -} +}; export default function Tile() { - + return ( <> - ) + ); } \ No newline at end of file diff --git a/src/context/GameContext.js b/src/context/GameContext.js index e5d6c96..9083f41 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -5,9 +5,9 @@ const GameContext = createContext(); const GameProvider = ({ children }) => { const gameState = { - } + }; - return {children} + return {children}; }; -export { GameProvider, GameContext } \ No newline at end of file +export { GameProvider, GameContext }; \ No newline at end of file From f0004dd77da38fdc9569bec89e6ce3f1ecf062c3 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Mon, 3 Oct 2022 17:37:47 -0700 Subject: [PATCH 03/23] gamecontext.js additions --- src/context/GameContext.js | 14 +++++++++++++- src/index.js | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/context/GameContext.js b/src/context/GameContext.js index 9083f41..f90817e 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -3,8 +3,20 @@ import { createContext, useState } from 'react'; const GameContext = createContext(); const GameProvider = ({ children }) => { - const gameState = { + const [board, setBoard] = useState([]); + const [playerX, setPlayerX] = useState(); + const [playerO, setPlayerO] = useState(); + const [tile, setTile] = useState(); + const gameState = { + board, + setBoard, + tile, + setTile, + playerX, + setPlayerX, + playerO, + setPlayerO }; return {children}; diff --git a/src/index.js b/src/index.js index d563c0f..a2431e2 100644 --- a/src/index.js +++ b/src/index.js @@ -3,11 +3,14 @@ import ReactDOM from 'react-dom/client'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; +import { GameProvider } from './context/GameContext'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + + + ); From 418d5c11e6d23f2e6325d6fe86faf2b94d14b9bb Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Mon, 3 Oct 2022 17:51:07 -0700 Subject: [PATCH 04/23] test1 --- src/components/Board.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Board.js b/src/components/Board.js index b128017..510ecdd 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -4,7 +4,18 @@ import { useContext } from 'react'; import { GameContext } from '../context/GameContext'; export default function Board() { + const { board, setBoard, tile, setTile } = useContext(GameContext); return ( -
Board
+
+ 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +
); } From ca1288b319b18fae89a718dbf5710420775158eb Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Mon, 3 Oct 2022 17:56:05 -0700 Subject: [PATCH 05/23] css test2 --- src/components/Board.css | 4 ++++ src/components/Board.js | 1 + src/components/Tile.js | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/components/Board.css diff --git a/src/components/Board.css b/src/components/Board.css new file mode 100644 index 0000000..4095571 --- /dev/null +++ b/src/components/Board.css @@ -0,0 +1,4 @@ +.board { + display: flex; + flex-wrap: wrap; +} \ No newline at end of file diff --git a/src/components/Board.js b/src/components/Board.js index 510ecdd..154d750 100644 --- a/src/components/Board.js +++ b/src/components/Board.js @@ -1,3 +1,4 @@ +import './Board.css'; import React from 'react'; import Tile from './Tile'; import { useContext } from 'react'; diff --git a/src/components/Tile.js b/src/components/Tile.js index 5ee799f..3921aea 100644 --- a/src/components/Tile.js +++ b/src/components/Tile.js @@ -11,7 +11,7 @@ export default function Tile() { return ( - <> + <>Tile ); } \ No newline at end of file From 49dc4bbd5020f8143b95944e86594649f8619631 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 10:29:54 -0700 Subject: [PATCH 06/23] file setup v2 --- src/App.js | 2 +- src/components/{ => Board}/Board.css | 0 src/components/{ => Board}/Board.js | 4 ++-- src/components/ExecuteMoveButton/ExecuteMoveButton.css | 0 .../{ => ExecuteMoveButton}/ExecuteMoveButton.js | 4 ++-- src/components/Tile/Tile.css | 0 src/components/{ => Tile}/Tile.js | 2 +- src/context/GameContext.js | 9 +++++++-- 8 files changed, 13 insertions(+), 8 deletions(-) rename src/components/{ => Board}/Board.css (100%) rename src/components/{ => Board}/Board.js (80%) create mode 100644 src/components/ExecuteMoveButton/ExecuteMoveButton.css rename src/components/{ => ExecuteMoveButton}/ExecuteMoveButton.js (74%) create mode 100644 src/components/Tile/Tile.css rename src/components/{ => Tile}/Tile.js (76%) diff --git a/src/App.js b/src/App.js index 43a2e07..0c9aa33 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ import './App.css'; -import Board from './components/Board'; +import Board from './components/Board/Board'; function App() { return ( diff --git a/src/components/Board.css b/src/components/Board/Board.css similarity index 100% rename from src/components/Board.css rename to src/components/Board/Board.css diff --git a/src/components/Board.js b/src/components/Board/Board.js similarity index 80% rename from src/components/Board.js rename to src/components/Board/Board.js index 154d750..16d70c9 100644 --- a/src/components/Board.js +++ b/src/components/Board/Board.js @@ -1,8 +1,8 @@ import './Board.css'; import React from 'react'; -import Tile from './Tile'; +import Tile from '../../components/Tile/Tile'; import { useContext } from 'react'; -import { GameContext } from '../context/GameContext'; +import { GameContext } from '../../context/GameContext'; export default function Board() { const { board, setBoard, tile, setTile } = useContext(GameContext); diff --git a/src/components/ExecuteMoveButton/ExecuteMoveButton.css b/src/components/ExecuteMoveButton/ExecuteMoveButton.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/ExecuteMoveButton.js b/src/components/ExecuteMoveButton/ExecuteMoveButton.js similarity index 74% rename from src/components/ExecuteMoveButton.js rename to src/components/ExecuteMoveButton/ExecuteMoveButton.js index a85100b..07652c9 100644 --- a/src/components/ExecuteMoveButton.js +++ b/src/components/ExecuteMoveButton/ExecuteMoveButton.js @@ -1,10 +1,10 @@ import React from 'react' import Tile from './Tile'; import { useContext } from 'react'; -import { GameContext } from '../context/GameContext'; +import { GameContext } from '../../context/GameContext'; export default function ExecuteMoveButton() { return (
ExecuteMoveButton
- ) + ); } diff --git a/src/components/Tile/Tile.css b/src/components/Tile/Tile.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/Tile.js b/src/components/Tile/Tile.js similarity index 76% rename from src/components/Tile.js rename to src/components/Tile/Tile.js index 3921aea..ce033f9 100644 --- a/src/components/Tile.js +++ b/src/components/Tile/Tile.js @@ -1,6 +1,6 @@ import React from 'react'; import { useContext } from 'react'; -import { GameContext } from '../context/GameContext'; +import { GameContext } from '../../context/GameContext'; const tileType = { circle: 'O', diff --git a/src/context/GameContext.js b/src/context/GameContext.js index f90817e..270fced 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -2,11 +2,14 @@ import { createContext, useState } from 'react'; const GameContext = createContext(); +const initialBoard = + const GameProvider = ({ children }) => { - const [board, setBoard] = useState([]); + const [board, setBoard] = useState([initialBoard]); const [playerX, setPlayerX] = useState(); const [playerO, setPlayerO] = useState(); const [tile, setTile] = useState(); + const [active, setActive] = useState(); const gameState = { board, @@ -16,7 +19,9 @@ const GameProvider = ({ children }) => { playerX, setPlayerX, playerO, - setPlayerO + setPlayerO, + active, + setActive }; return {children}; From de6aeabcd4fc588cacf6f74bda1225b459caa2cc Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 15:49:14 -0700 Subject: [PATCH 07/23] post food poisoning: added css, handling onClick within Tile.js, change to currentPlayer --- src/components/Board/Board.css | 8 +++++ src/components/Board/Board.js | 34 ++++++++++++------- .../ExecuteMoveButton/ExecuteMoveButton.js | 4 +-- src/components/Tile/Tile.css | 8 +++++ src/components/Tile/Tile.js | 19 +++++++++-- src/context/GameContext.js | 10 ++++-- 6 files changed, 64 insertions(+), 19 deletions(-) diff --git a/src/components/Board/Board.css b/src/components/Board/Board.css index 4095571..79075a3 100644 --- a/src/components/Board/Board.css +++ b/src/components/Board/Board.css @@ -1,4 +1,12 @@ .board { display: flex; flex-wrap: wrap; + flex-direction: column; + align-content: center; +} + +.row { + display: flex; + flex-wrap: wrap; + flex-direction: row; } \ No newline at end of file diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 16d70c9..411276b 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -5,18 +5,28 @@ import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; export default function Board() { - const { board, setBoard, tile, setTile } = useContext(GameContext); + const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); return ( -
- 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 -
+
+
WELCOME TO ALCHEMY TIC TAC-O
+
It is {currentPlayer}s turn
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+
); } diff --git a/src/components/ExecuteMoveButton/ExecuteMoveButton.js b/src/components/ExecuteMoveButton/ExecuteMoveButton.js index 07652c9..094d0db 100644 --- a/src/components/ExecuteMoveButton/ExecuteMoveButton.js +++ b/src/components/ExecuteMoveButton/ExecuteMoveButton.js @@ -1,5 +1,5 @@ -import React from 'react' -import Tile from './Tile'; +import React from 'react'; +import Tile from '../Tile/Tile'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; diff --git a/src/components/Tile/Tile.css b/src/components/Tile/Tile.css index e69de29..5c35eec 100644 --- a/src/components/Tile/Tile.css +++ b/src/components/Tile/Tile.css @@ -0,0 +1,8 @@ +.tile { + width: 100px; + height: 100px; + margin: 5px; + border: 2px solid; + box-sizing: border-box; + background-color: aquamarine; +} \ No newline at end of file diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index ce033f9..aec6f48 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -1,17 +1,30 @@ import React from 'react'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; +// import ExecuteMoveButton from '../ExecuteMoveButton/ExecuteMoveButton'; +import './Tile.css'; const tileType = { circle: 'O', ex: 'X', }; -export default function Tile() { +export default function Tile() { + const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); + + function handleTileClick() { + if (currentPlayer === 'X') { + currentPlayer === 'O'; + } else { + currentPlayer === 'X'; + } + console.log('you clicked!'); + console.log('it is now ' + currentPlayer + 'turn'); + } return ( - <>Tile - +
+
); } \ No newline at end of file diff --git a/src/context/GameContext.js b/src/context/GameContext.js index 270fced..ad95521 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -3,13 +3,17 @@ import { createContext, useState } from 'react'; const GameContext = createContext(); const initialBoard = + ['', '', '', + '', '', '', + '', '', '']; const GameProvider = ({ children }) => { const [board, setBoard] = useState([initialBoard]); const [playerX, setPlayerX] = useState(); const [playerO, setPlayerO] = useState(); const [tile, setTile] = useState(); - const [active, setActive] = useState(); + const [active, setActive] = useState(true); + const [currentPlayer, setCurrentPlayer] = useState('X'); const gameState = { board, @@ -21,7 +25,9 @@ const GameProvider = ({ children }) => { playerO, setPlayerO, active, - setActive + setActive, + currentPlayer, + setCurrentPlayer }; return {children}; From 0f6d262792e6b67af6197be33f2f9d54da491534 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 15:57:23 -0700 Subject: [PATCH 08/23] context changes player on click --- src/components/Tile/Tile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index aec6f48..4b9e255 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -15,12 +15,12 @@ export default function Tile() { function handleTileClick() { if (currentPlayer === 'X') { - currentPlayer === 'O'; + setCurrentPlayer('O'); } else { - currentPlayer === 'X'; + setCurrentPlayer('X'); } console.log('you clicked!'); - console.log('it is now ' + currentPlayer + 'turn'); + console.log('it is now ' + currentPlayer + ' turn'); } return ( From c0f329dd771ba591705b52f1a88154e7d0c838a2 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 16:21:33 -0700 Subject: [PATCH 09/23] changed gamecontext, testing initial board settings and display in board.js --- src/components/Board/Board.js | 5 ++++- src/context/GameContext.js | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 411276b..e2f5f39 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -5,14 +5,17 @@ import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; export default function Board() { + const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); + console.log(...board[1][1]); //5 + console.log(...board[0][0]); //1 return (
WELCOME TO ALCHEMY TIC TAC-O
It is {currentPlayer}s turn
- +
diff --git a/src/context/GameContext.js b/src/context/GameContext.js index ad95521..bca685c 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -3,12 +3,12 @@ import { createContext, useState } from 'react'; const GameContext = createContext(); const initialBoard = - ['', '', '', - '', '', '', - '', '', '']; + [['1', '2', '3'], + ['4', '5', '6'], + ['7', '8', '9']]; const GameProvider = ({ children }) => { - const [board, setBoard] = useState([initialBoard]); + const [board, setBoard] = useState(initialBoard); const [playerX, setPlayerX] = useState(); const [playerO, setPlayerO] = useState(); const [tile, setTile] = useState(); From d2a8b715c019065d3e54a1f44734cab687321e51 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 16:48:08 -0700 Subject: [PATCH 10/23] tiles show board object values --- src/components/Board/Board.js | 21 +++++++-------- src/components/Tile/Tile.js | 5 +++- src/context/GameContext.js | 49 +++++++++++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index e2f5f39..29ad613 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -7,27 +7,26 @@ import { GameContext } from '../../context/GameContext'; export default function Board() { const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); - console.log(...board[1][1]); //5 - console.log(...board[0][0]); //1 + return (
WELCOME TO ALCHEMY TIC TAC-O
It is {currentPlayer}s turn
- - - + + +
- - - + + +
- - - + + +
diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 4b9e255..6c6458d 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -10,7 +10,7 @@ const tileType = { }; -export default function Tile() { +export default function Tile({ location }) { const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); function handleTileClick() { @@ -22,9 +22,12 @@ export default function Tile() { console.log('you clicked!'); console.log('it is now ' + currentPlayer + ' turn'); } + // console.log(location); + console.log(board[location].value); return (
+
{board[location].value}
); } \ No newline at end of file diff --git a/src/context/GameContext.js b/src/context/GameContext.js index bca685c..6eb7316 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -2,13 +2,52 @@ import { createContext, useState } from 'react'; const GameContext = createContext(); -const initialBoard = - [['1', '2', '3'], - ['4', '5', '6'], - ['7', '8', '9']]; +// const initialBoardArray = +// [['1', '2', '3'], +// ['4', '5', '6'], +// ['7', '8', '9']]; + +const initialBoardObject = [ + { + place: 1, + value: '1' + }, + { + place: 2, + value: '2' + }, + { + place: 3, + value: '3' + }, + { + place: 4, + value: '4' + }, + { + place: 5, + value: '5' + }, + { + place: 6, + value: '6' + }, + { + place: 7, + value: '7' + }, + { + place: 8, + value: '8' + }, + { + place: 9, + value: '9' + } +]; const GameProvider = ({ children }) => { - const [board, setBoard] = useState(initialBoard); + const [board, setBoard] = useState(initialBoardObject); const [playerX, setPlayerX] = useState(); const [playerO, setPlayerO] = useState(); const [tile, setTile] = useState(); From f8d8cb8daf5ced900bf113b9085986b90f39ed54 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 16:52:34 -0700 Subject: [PATCH 11/23] tiles show X or O on click depending on whos turn it is --- src/components/Tile/Tile.js | 3 +-- src/context/GameContext.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 6c6458d..f7777b2 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -14,6 +14,7 @@ export default function Tile({ location }) { const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); function handleTileClick() { + board[location].value = currentPlayer; if (currentPlayer === 'X') { setCurrentPlayer('O'); } else { @@ -22,8 +23,6 @@ export default function Tile({ location }) { console.log('you clicked!'); console.log('it is now ' + currentPlayer + ' turn'); } - // console.log(location); - console.log(board[location].value); return (
diff --git a/src/context/GameContext.js b/src/context/GameContext.js index 6eb7316..66d263d 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -10,39 +10,39 @@ const GameContext = createContext(); const initialBoardObject = [ { place: 1, - value: '1' + value: '' }, { place: 2, - value: '2' + value: '' }, { place: 3, - value: '3' + value: '' }, { place: 4, - value: '4' + value: '' }, { place: 5, - value: '5' + value: '' }, { place: 6, - value: '6' + value: '' }, { place: 7, - value: '7' + value: '' }, { place: 8, - value: '8' + value: '' }, { place: 9, - value: '9' + value: '' } ]; From 242cf6d882a5c94fbbb4536a9d8e74071ea3061b Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 17:16:19 -0700 Subject: [PATCH 12/23] created custom hook resetgame, no errors but also not functioning --- src/App.js | 2 + src/components/Board/Board.js | 16 ++++++- .../ExecuteMoveButton/ExecuteMoveButton.css | 0 .../ExecuteMoveButton/ExecuteMoveButton.js | 10 ---- src/context/GameContext.js | 48 +------------------ src/initial-board-data.js | 38 +++++++++++++++ 6 files changed, 56 insertions(+), 58 deletions(-) delete mode 100644 src/components/ExecuteMoveButton/ExecuteMoveButton.css delete mode 100644 src/components/ExecuteMoveButton/ExecuteMoveButton.js create mode 100644 src/initial-board-data.js diff --git a/src/App.js b/src/App.js index 0c9aa33..77b22ce 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,8 @@ import './App.css'; import Board from './components/Board/Board'; + + function App() { return (
diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 29ad613..a0c5fa5 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -1,17 +1,29 @@ import './Board.css'; -import React from 'react'; +import { React, useState } from 'react'; import Tile from '../../components/Tile/Tile'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; +import initialBoard from '../../initial-board-data'; export default function Board() { - const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); + + if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { + setActive(false); + console.log('X wins!'); + } + + function ResetGame() { + setBoard(initialBoard); + console.log(board); + console.log('you pressed reset game'); + } return (
WELCOME TO ALCHEMY TIC TAC-O
It is {currentPlayer}s turn
+
diff --git a/src/components/ExecuteMoveButton/ExecuteMoveButton.css b/src/components/ExecuteMoveButton/ExecuteMoveButton.css deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/ExecuteMoveButton/ExecuteMoveButton.js b/src/components/ExecuteMoveButton/ExecuteMoveButton.js deleted file mode 100644 index 094d0db..0000000 --- a/src/components/ExecuteMoveButton/ExecuteMoveButton.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; -import Tile from '../Tile/Tile'; -import { useContext } from 'react'; -import { GameContext } from '../../context/GameContext'; - -export default function ExecuteMoveButton() { - return ( -
ExecuteMoveButton
- ); -} diff --git a/src/context/GameContext.js b/src/context/GameContext.js index 66d263d..f5d3249 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -1,53 +1,9 @@ import { createContext, useState } from 'react'; - +import initialBoard from '../initial-board-data'; const GameContext = createContext(); -// const initialBoardArray = -// [['1', '2', '3'], -// ['4', '5', '6'], -// ['7', '8', '9']]; - -const initialBoardObject = [ - { - place: 1, - value: '' - }, - { - place: 2, - value: '' - }, - { - place: 3, - value: '' - }, - { - place: 4, - value: '' - }, - { - place: 5, - value: '' - }, - { - place: 6, - value: '' - }, - { - place: 7, - value: '' - }, - { - place: 8, - value: '' - }, - { - place: 9, - value: '' - } -]; - const GameProvider = ({ children }) => { - const [board, setBoard] = useState(initialBoardObject); + const [board, setBoard] = useState(initialBoard); const [playerX, setPlayerX] = useState(); const [playerO, setPlayerO] = useState(); const [tile, setTile] = useState(); diff --git a/src/initial-board-data.js b/src/initial-board-data.js new file mode 100644 index 0000000..3d933a1 --- /dev/null +++ b/src/initial-board-data.js @@ -0,0 +1,38 @@ +export default [ + { + place: 1, + value: '' + }, + { + place: 2, + value: '' + }, + { + place: 3, + value: '' + }, + { + place: 4, + value: '' + }, + { + place: 5, + value: '' + }, + { + place: 6, + value: '' + }, + { + place: 7, + value: '' + }, + { + place: 8, + value: '' + }, + { + place: 9, + value: '' + } +]; \ No newline at end of file From 553aa3bf886c8d3492b99487e278d2f971f04885 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 17:44:17 -0700 Subject: [PATCH 13/23] reset game button works --- src/components/Board/Board.js | 46 +++++++++++++++++++++++++++++++---- src/components/Tile/Tile.js | 1 - 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index a0c5fa5..12a6b13 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -3,10 +3,9 @@ import { React, useState } from 'react'; import Tile from '../../components/Tile/Tile'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; -import initialBoard from '../../initial-board-data'; export default function Board() { - const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); + const { board, setBoard, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { setActive(false); @@ -14,9 +13,46 @@ export default function Board() { } function ResetGame() { - setBoard(initialBoard); - console.log(board); - console.log('you pressed reset game'); + setActive(true); + setCurrentPlayer('X'); + setBoard([ + { + place: 1, + value: '' + }, + { + place: 2, + value: '' + }, + { + place: 3, + value: '' + }, + { + place: 4, + value: '' + }, + { + place: 5, + value: '' + }, + { + place: 6, + value: '' + }, + { + place: 7, + value: '' + }, + { + place: 8, + value: '' + }, + { + place: 9, + value: '' + } + ]); } return ( diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index f7777b2..267c5c0 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -1,7 +1,6 @@ import React from 'react'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; -// import ExecuteMoveButton from '../ExecuteMoveButton/ExecuteMoveButton'; import './Tile.css'; const tileType = { From f864cf2a06e9d1829500c7a5d5c671f0326cf6fb Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 17:47:32 -0700 Subject: [PATCH 14/23] tile uses active state to enable click --- src/components/Tile/Tile.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 267c5c0..2ad472b 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -3,26 +3,26 @@ import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; import './Tile.css'; -const tileType = { - circle: 'O', - ex: 'X', -}; - export default function Tile({ location }) { - const { board, setBoard, playerX, setPlayerX, playerO, setPlayerO, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); + const { board, active, currentPlayer, setCurrentPlayer } = useContext(GameContext); function handleTileClick() { - board[location].value = currentPlayer; - if (currentPlayer === 'X') { - setCurrentPlayer('O'); + if (!active) { + return; } else { - setCurrentPlayer('X'); + board[location].value = currentPlayer; + if (currentPlayer === 'X') { + setCurrentPlayer('O'); + } else { + setCurrentPlayer('X'); + } + console.log('you clicked!'); + console.log('it is now ' + currentPlayer + ' turn'); } - console.log('you clicked!'); - console.log('it is now ' + currentPlayer + ' turn'); } + return (
{board[location].value}
From 046c971f0a9e9d6c66dde0d4f046ea8de13683a4 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 17:53:15 -0700 Subject: [PATCH 15/23] win conditions, displays alert on victory --- src/components/Board/Board.js | 44 +++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 12a6b13..7d7c260 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -6,11 +6,51 @@ import { GameContext } from '../../context/GameContext'; export default function Board() { const { board, setBoard, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); - + // conditions for player X to win if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { setActive(false); - console.log('X wins!'); + alert('X wins!'); + } + if (board[3].value === 'X' && board[4].value === 'X' && board[5].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[6].value === 'X' && board[7].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[0].value === 'X' && board[4].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[6].value === 'X' && board[4].value === 'X' && board[2].value === 'X') { + setActive(false); + alert('X wins!'); + } + + // conditions for player O to win + if (board[0].value === 'O' && board[1].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[3].value === 'O' && board[4].value === 'O' && board[5].value === 'O') { + setActive(false); + alert('O wins!'); } + if (board[6].value === 'O' && board[7].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[0].value === 'O' && board[4].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[6].value === 'O' && board[4].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + } + + function ResetGame() { setActive(true); From 9c3364a4bcf2ba8232e66c81f22253465dae2d1f Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 17:56:14 -0700 Subject: [PATCH 16/23] cats game check added, removed extra state and console logs --- src/components/Board/Board.js | 19 +++++++++++++++++-- src/components/Tile/Tile.js | 2 -- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 7d7c260..f17d0d1 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -1,12 +1,27 @@ import './Board.css'; -import { React, useState } from 'react'; +import { React } from 'react'; import Tile from '../../components/Tile/Tile'; import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; export default function Board() { const { board, setBoard, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); - // conditions for player X to win + // check for cats game + if (active && + board[0].value && + board[1].value && + board[2].value && + board[3].value && + board[4].value && + board[5].value && + board[6].value && + board[7].value && + board[8].value) { + setActive(false); + alert('cats game!'); + } + + // conditions for player X to win if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { setActive(false); alert('X wins!'); diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 2ad472b..b5ec884 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -17,8 +17,6 @@ export default function Tile({ location }) { } else { setCurrentPlayer('X'); } - console.log('you clicked!'); - console.log('it is now ' + currentPlayer + ' turn'); } } From 95bff8f6e16f3eb629c50be9516b09e046ddb304 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 18:05:24 -0700 Subject: [PATCH 17/23] added css --- src/components/Board/Board.css | 3 +++ src/components/Board/Board.js | 2 -- src/components/Tile/Tile.css | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Board/Board.css b/src/components/Board/Board.css index 79075a3..f6c43fa 100644 --- a/src/components/Board/Board.css +++ b/src/components/Board/Board.css @@ -3,6 +3,9 @@ flex-wrap: wrap; flex-direction: column; align-content: center; + height: 90vh; + background-image: url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS7s9yhHPtcMcWRQFDm9tCBS2RhsUyyOye46A&usqp=CAU); + } .row { diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index f17d0d1..bdff08a 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -64,9 +64,7 @@ export default function Board() { setActive(false); alert('O wins!'); } - - function ResetGame() { setActive(true); setCurrentPlayer('X'); diff --git a/src/components/Tile/Tile.css b/src/components/Tile/Tile.css index 5c35eec..137db39 100644 --- a/src/components/Tile/Tile.css +++ b/src/components/Tile/Tile.css @@ -5,4 +5,5 @@ border: 2px solid; box-sizing: border-box; background-color: aquamarine; + font-size: 3em; } \ No newline at end of file From 16ee9e24d6f7c56304df99146bff76c0ba9d374a Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Tue, 4 Oct 2022 18:22:25 -0700 Subject: [PATCH 18/23] added more css --- src/components/Board/Board.css | 5 +++++ src/components/Board/Board.js | 4 ++-- src/components/Tile/Tile.css | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Board/Board.css b/src/components/Board/Board.css index f6c43fa..92b2645 100644 --- a/src/components/Board/Board.css +++ b/src/components/Board/Board.css @@ -12,4 +12,9 @@ display: flex; flex-wrap: wrap; flex-direction: row; +} + +.message { + font-size: 2em; + margin: 10px; } \ No newline at end of file diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index bdff08a..92bde52 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -64,7 +64,7 @@ export default function Board() { setActive(false); alert('O wins!'); } - + function ResetGame() { setActive(true); setCurrentPlayer('X'); @@ -112,7 +112,7 @@ export default function Board() {
WELCOME TO ALCHEMY TIC TAC-O
It is {currentPlayer}s turn
- +
diff --git a/src/components/Tile/Tile.css b/src/components/Tile/Tile.css index 137db39..ace138b 100644 --- a/src/components/Tile/Tile.css +++ b/src/components/Tile/Tile.css @@ -6,4 +6,5 @@ box-sizing: border-box; background-color: aquamarine; font-size: 3em; + text-align: center; } \ No newline at end of file From 4a133d063e1aed4c0f9a5c925c0a550b608789a1 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Thu, 6 Oct 2022 15:26:44 -0700 Subject: [PATCH 19/23] fixed double win alerts --- src/components/Board/Board.js | 129 ++++++++++++++++++---------------- src/components/Tile/Tile.js | 13 +++- 2 files changed, 80 insertions(+), 62 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 92bde52..9afee1c 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -6,69 +6,82 @@ import { GameContext } from '../../context/GameContext'; export default function Board() { const { board, setBoard, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); - // check for cats game - if (active && - board[0].value && - board[1].value && - board[2].value && - board[3].value && - board[4].value && - board[5].value && - board[6].value && - board[7].value && - board[8].value) { - setActive(false); - alert('cats game!'); - } - + + const checkWinner = () => { + if (!active) + return; // conditions for player X to win - if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[3].value === 'X' && board[4].value === 'X' && board[5].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[6].value === 'X' && board[7].value === 'X' && board[8].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[0].value === 'X' && board[4].value === 'X' && board[8].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[6].value === 'X' && board[4].value === 'X' && board[2].value === 'X') { - setActive(false); - alert('X wins!'); - } + // check for cats game + if (active && + board[0].value && + board[1].value && + board[2].value && + board[3].value && + board[4].value && + board[5].value && + board[6].value && + board[7].value && + board[8].value) { + setActive(false); + alert('cats game!'); + } + if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[3].value === 'X' && board[4].value === 'X' && board[5].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[6].value === 'X' && board[7].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[0].value === 'X' && board[4].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + } + if (board[6].value === 'X' && board[4].value === 'X' && board[2].value === 'X') { + setActive(false); + alert('X wins!'); + } + + // add vertical win conditions + + // conditions for player O to win + if (board[0].value === 'O' && board[1].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[3].value === 'O' && board[4].value === 'O' && board[5].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[6].value === 'O' && board[7].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[0].value === 'O' && board[4].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + } + if (board[6].value === 'O' && board[4].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + } + }; + + checkWinner(); - // conditions for player O to win - if (board[0].value === 'O' && board[1].value === 'O' && board[2].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[3].value === 'O' && board[4].value === 'O' && board[5].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[6].value === 'O' && board[7].value === 'O' && board[8].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[0].value === 'O' && board[4].value === 'O' && board[8].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[6].value === 'O' && board[4].value === 'O' && board[2].value === 'O') { - setActive(false); - alert('O wins!'); - } function ResetGame() { setActive(true); setCurrentPlayer('X'); setBoard([ + { + place: 0, + value: '' + }, { place: 1, value: '' @@ -100,10 +113,6 @@ export default function Board() { { place: 8, value: '' - }, - { - place: 9, - value: '' } ]); } diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index b5ec884..557a471 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -5,18 +5,27 @@ import './Tile.css'; export default function Tile({ location }) { - const { board, active, currentPlayer, setCurrentPlayer } = useContext(GameContext); + const { board, setBoard, active, currentPlayer, setCurrentPlayer } = useContext(GameContext); function handleTileClick() { if (!active) { return; } else { - board[location].value = currentPlayer; if (currentPlayer === 'X') { setCurrentPlayer('O'); } else { setCurrentPlayer('X'); } + setBoard((prevState) => { + return prevState.map((space)=>{ + if (space.place === location) { + return { place: location, value: currentPlayer }; + } else { + return { ...space }; + } + }); + }); + } } From 5e594a0d207b365556d2b6669ccc981fe2ac4001 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Thu, 13 Oct 2022 15:33:57 -0700 Subject: [PATCH 20/23] moved game logic to gamecontext --- src/components/Board/Board.js | 69 +--------------------- src/context/GameContext.js | 105 ++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 68 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 9afee1c..1c3edb2 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -5,74 +5,7 @@ import { useContext } from 'react'; import { GameContext } from '../../context/GameContext'; export default function Board() { - const { board, setBoard, active, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); - - const checkWinner = () => { - if (!active) - return; - // conditions for player X to win - // check for cats game - if (active && - board[0].value && - board[1].value && - board[2].value && - board[3].value && - board[4].value && - board[5].value && - board[6].value && - board[7].value && - board[8].value) { - setActive(false); - alert('cats game!'); - } - if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[3].value === 'X' && board[4].value === 'X' && board[5].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[6].value === 'X' && board[7].value === 'X' && board[8].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[0].value === 'X' && board[4].value === 'X' && board[8].value === 'X') { - setActive(false); - alert('X wins!'); - } - if (board[6].value === 'X' && board[4].value === 'X' && board[2].value === 'X') { - setActive(false); - alert('X wins!'); - } - - // add vertical win conditions - - // conditions for player O to win - if (board[0].value === 'O' && board[1].value === 'O' && board[2].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[3].value === 'O' && board[4].value === 'O' && board[5].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[6].value === 'O' && board[7].value === 'O' && board[8].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[0].value === 'O' && board[4].value === 'O' && board[8].value === 'O') { - setActive(false); - alert('O wins!'); - } - if (board[6].value === 'O' && board[4].value === 'O' && board[2].value === 'O') { - setActive(false); - alert('O wins!'); - } - }; - - checkWinner(); - + const { board, setBoard, setActive, currentPlayer, setCurrentPlayer } = useContext(GameContext); function ResetGame() { setActive(true); diff --git a/src/context/GameContext.js b/src/context/GameContext.js index f5d3249..cf98959 100644 --- a/src/context/GameContext.js +++ b/src/context/GameContext.js @@ -25,6 +25,111 @@ const GameProvider = ({ children }) => { setCurrentPlayer }; + const checkWinner = () => { + if (!active) + return; + // conditions for player X to win + + if (board[0].value === 'X' && board[1].value === 'X' && board[2].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[3].value === 'X' && board[4].value === 'X' && board[5].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[6].value === 'X' && board[7].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[0].value === 'X' && board[4].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[6].value === 'X' && board[4].value === 'X' && board[2].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[0].value === 'X' && board[3].value === 'X' && board[6].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[1].value === 'X' && board[4].value === 'X' && board[7].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + if (board[2].value === 'X' && board[5].value === 'X' && board[8].value === 'X') { + setActive(false); + alert('X wins!'); + return; + } + + // conditions for player O to win + if (board[0].value === 'O' && board[1].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + return; + } + if (board[3].value === 'O' && board[4].value === 'O' && board[5].value === 'O') { + setActive(false); + alert('O wins!'); + return; + } + if (board[6].value === 'O' && board[7].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + return; + } + if (board[0].value === 'O' && board[4].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('O wins!'); + return; + } + if (board[6].value === 'O' && board[4].value === 'O' && board[2].value === 'O') { + setActive(false); + alert('O wins!'); + return; + } + if (board[0].value === 'O' && board[3].value === 'O' && board[6].value === 'O') { + setActive(false); + alert('X wins!'); + return; + } + if (board[1].value === 'O' && board[4].value === 'O' && board[7].value === 'O') { + setActive(false); + alert('X wins!'); + return; + } + if (board[2].value === 'O' && board[5].value === 'O' && board[8].value === 'O') { + setActive(false); + alert('X wins!'); + return; + } + // check for cats game + else if (active && + board[0].value && + board[1].value && + board[2].value && + board[3].value && + board[4].value && + board[5].value && + board[6].value && + board[7].value && + board[8].value) { + setActive(false); + alert('cats game!'); + } + }; + checkWinner(); + + return {children}; }; From c6ea03d1b2d481641d5dd1a8c0d498c079ff0ffc Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Thu, 13 Oct 2022 15:37:23 -0700 Subject: [PATCH 21/23] fixed some game logic --- src/components/Tile/Tile.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 557a471..345d8f6 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -11,15 +11,15 @@ export default function Tile({ location }) { if (!active) { return; } else { - if (currentPlayer === 'X') { - setCurrentPlayer('O'); - } else { - setCurrentPlayer('X'); - } + setBoard((prevState) => { return prevState.map((space)=>{ - if (space.place === location) { - return { place: location, value: currentPlayer }; + if (space.place - 1 === location && space.value === '') { + if (currentPlayer === 'X') { + setCurrentPlayer('O'); + } else { + setCurrentPlayer('X'); + } return { place: location, value: currentPlayer }; } else { return { ...space }; } From 00a9f5c77549615e8a67d5f211067b9a2ed7d5e9 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Thu, 13 Oct 2022 15:41:38 -0700 Subject: [PATCH 22/23] bugfix --- src/components/Board/Board.js | 2 +- src/components/Tile/Tile.js | 3 +-- src/initial-board-data.js | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 1c3edb2..56561d0 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -49,7 +49,7 @@ export default function Board() { } ]); } - + console.log(board); return (
WELCOME TO ALCHEMY TIC TAC-O
diff --git a/src/components/Tile/Tile.js b/src/components/Tile/Tile.js index 345d8f6..ce01145 100644 --- a/src/components/Tile/Tile.js +++ b/src/components/Tile/Tile.js @@ -11,10 +11,9 @@ export default function Tile({ location }) { if (!active) { return; } else { - setBoard((prevState) => { return prevState.map((space)=>{ - if (space.place - 1 === location && space.value === '') { + if (space.place === location && space.value === '') { if (currentPlayer === 'X') { setCurrentPlayer('O'); } else { diff --git a/src/initial-board-data.js b/src/initial-board-data.js index 3d933a1..bfb7a64 100644 --- a/src/initial-board-data.js +++ b/src/initial-board-data.js @@ -1,4 +1,8 @@ export default [ + { + place: 0, + value: '' + }, { place: 1, value: '' @@ -30,9 +34,5 @@ export default [ { place: 8, value: '' - }, - { - place: 9, - value: '' } ]; \ No newline at end of file From e7ce768160d086164342f94907fbc7bccb0b07c3 Mon Sep 17 00:00:00 2001 From: Connor McCue Date: Fri, 14 Oct 2022 09:06:57 -0700 Subject: [PATCH 23/23] removed console statement --- src/components/Board/Board.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Board/Board.js b/src/components/Board/Board.js index 56561d0..58ce448 100644 --- a/src/components/Board/Board.js +++ b/src/components/Board/Board.js @@ -49,7 +49,6 @@ export default function Board() { } ]); } - console.log(board); return (
WELCOME TO ALCHEMY TIC TAC-O