diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/App.tsx | 2 | ||||
-rw-r--r-- | src/components/MultiplayerGrid.tsx | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/components/App.tsx b/src/components/App.tsx index 1f646b3..a76e3b3 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -53,7 +53,7 @@ const App: React.FC = () => { scoreO={scoreO} setScoreO={setScoreO} setMessage={setMessage} setShowMessage={setShowMessageBox} - /> : <MultiplayerGrid + /> : <Grid turn={turn} setTurn={setTurn} scoreX={scoreX} diff --git a/src/components/MultiplayerGrid.tsx b/src/components/MultiplayerGrid.tsx index 2643667..89ab564 100644 --- a/src/components/MultiplayerGrid.tsx +++ b/src/components/MultiplayerGrid.tsx @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import React, { useState, useEffect, Dispatch, SetStateAction } from 'react'; +import React, { useState/*, useEffect*/, Dispatch, SetStateAction } from 'react'; import { io } from 'socket.io-client'; import Box from './Box'; import './style.css'; @@ -49,10 +49,14 @@ const MultiplayerGrid: React.FC<Props> = (props) => { const gameWinner = winner < 2 ? (winner === 1 ? "X" : "O") : "Draw"; props.setMessage(`WINNER: ${gameWinner}`); props.setShowMessage(true); + console.log(gameWinner, "X: ", props.scoreX, "O: ", props.scoreO); + gameWinner === "Draw" || (gameWinner === "X" ? props.setScoreX(props.scoreX + 1) : props.setScoreO(props.scoreO + 1)); - socket.emit("update-remote-board", [2,2,2,2,2,2,2,2,2]); + + console.log(gameWinner, "X: ", props.scoreX, "O: ", props.scoreO); + socket.emit("update-remote-data", {board: [2,2,2,2,2,2,2,2,2], turn: turn}); winner < 2 && props.setTurn(winner); // set turn to prev. winner } |