diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-07-22 14:58:12 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-07-22 14:58:12 +0530 |
commit | c3e1feffb9ac607bb73de6d4164be5fd23e41871 (patch) | |
tree | 84af1e013290a21e85f21bdd1dcc523ea8e2c8a6 /src/components/MultiplayerGrid.tsx | |
parent | 5f23dfc40ded0f5935843781829e67ffd5d77ab4 (diff) |
fixed wrong winner showing
Diffstat (limited to 'src/components/MultiplayerGrid.tsx')
-rw-r--r-- | src/components/MultiplayerGrid.tsx | 8 |
1 files changed, 6 insertions, 2 deletions
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 } |