From f43b45d89af841a5c9e9ae66e0c0333730c15c64 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Fri, 7 May 2021 10:07:45 -0500 Subject: [PATCH] Finish implementing phase 0 --- back/src/Game.ts | 5 ++--- front/pages/index.tsx | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/back/src/Game.ts b/back/src/Game.ts index dbc4612..043e1f2 100644 --- a/back/src/Game.ts +++ b/back/src/Game.ts @@ -125,11 +125,10 @@ export default class Game { const p = this.players[i]; if (p.rank || p.disconnected) continue; playerPromises.push(new Promise(resolve => { - p.client.once('prepare', order => { + p.client.once('prepare', stack => { delete p.disconnectListener; (() => { - - + p.stack = stack; p.client.socket.disconnect(); logSocket(p.client.socket, 'Bad cards argument on turn'); })(); diff --git a/front/pages/index.tsx b/front/pages/index.tsx index 8246f9a..2a15c6c 100644 --- a/front/pages/index.tsx +++ b/front/pages/index.tsx @@ -29,11 +29,10 @@ export default function Game() { const [roomHost, setRoomHost] = useState(''); const [gameState, setGameState] = useState(null); - const [cardSelected, setCardSelected] = useState([]); const [num, setNum] = useState(0); - const [stackSelected, setStackSelected] = useState([]); + const [cardSelected, setCardSelected] = useState([]); useEffect(() => { const socket = io(process.env.NEXT_PUBLIC_BACK_HOST!); @@ -122,8 +121,31 @@ export default function Game() { ))} - - + {`Rearrange your card stack from top to bottom!`} +
+

Your cards:

+ {gameState.cards.map((card, i) => ( + + ))} + +
); }