From 59f816569719416108e900939cccadb0ab2d413e Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Fri, 7 May 2021 12:59:17 -0500 Subject: Finally fix frontend --- front/pages/index.tsx | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/front/pages/index.tsx b/front/pages/index.tsx index 1d8918c..ec118e6 100644 --- a/front/pages/index.tsx +++ b/front/pages/index.tsx @@ -1,4 +1,4 @@ -import {Card} from 'bsx-core'; +import {Card, Suit} from 'bsx-core'; import {useEffect, useState} from 'react'; import io from 'socket.io-client'; @@ -18,7 +18,14 @@ interface GameState { const rankStrs = ['', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']; const suitChars = ['♣', '♦', '♥', '♠']; +function useForceUpdate(){ + const [value, setValue] = useState(0); + return () => setValue(value => value + 1); +} + export default function Game() { + const forceUpdate = useForceUpdate(); + const [socket, setSocket] = useState(null); const [connected, setConnected] = useState(false); const [loggedIn, setLoggedIn] = useState(false); @@ -109,7 +116,7 @@ export default function Game() { ); } - const selectedStacks = gameState.players.filter((_, i) => stackSelected[i]); + const selectedStacks = [...Array(gameState.players.length).keys()].filter((_, i) => stackSelected[i]); const selectedCards = gameState.cards.filter((_, i) => cardSelected[i]); if (gameState.phase === 0) { return ( @@ -125,18 +132,23 @@ export default function Game() {

Your cards:

{gameState.cards.map((card, i) => ( -