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 +++++++++---------- src/components/GamemodeChooser.js | 63 +++++++++++++++++++++++++++++++++++++++ src/components/MultiplayerGrid.js | 3 ++ src/components/MultiplayerMenu.js | 40 +++++++++++++++++++++++++ src/components/ScoreBoard.js | 7 ++++- src/components/style.css | 2 +- 6 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 src/components/GamemodeChooser.js create mode 100644 src/components/MultiplayerMenu.js (limited to 'src') 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 -
-
+