From b353dda4df7fc7be973e52a2f529360e7bfc8fed Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Sat, 24 Jul 2021 18:14:26 +0530 Subject: Added menu to host/join game and protection against cheating --- src/components/App.js | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src/components/App.js') diff --git a/src/components/App.js b/src/components/App.js index f10b5eb..db5af1b 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -16,6 +16,7 @@ */ import React, { useState } from 'react'; +import GamemodeChooser from './GamemodeChooser'; import MessageBox from './MessageBox'; import ScoreBoard from './ScoreBoard'; import Grid from './Grid'; @@ -31,6 +32,7 @@ const App = () => { const [turn, setTurn] = useState(1); const [showMessageBox, setShowMessageBox] = useState(false); const [message, setMessage] = useState(""); + const [isHost, setIsHost] = useState(false); return gameStarted ? ( <> @@ -45,14 +47,18 @@ const App = () => { turn={turn} scoreX={scoreX} scoreO={scoreO} + multiplayer={multiplayer} + isHost={isHost} /> {multiplayer ? : { setTurn={setTurn} scoreX={scoreX} setScoreX={setScoreX} - scoreO={scoreO} setScoreO={setScoreO} + scoreO={scoreO} + setScoreO={setScoreO} setMessage={setMessage} setShowMessage={setShowMessageBox} /> @@ -70,21 +77,11 @@ const App = () => { ) : ( <> -
-
{ - setGameStarted(true); - setMultiplayer(false); - }}> - SINGLE PLAYER -
- -
{ - setGameStarted(true); - setMultiplayer(true); - }}> - MULTIPLAYER -
-
+