diff --git a/back/src/Game.ts b/back/src/Game.ts index 293baa3..dbc4612 100644 --- a/back/src/Game.ts +++ b/back/src/Game.ts @@ -28,6 +28,7 @@ class Player { players: otherPlayers.map((p: Player) => ({ username: p.client.username, numCards: p.cards.length, + stackSize: p.stack.length, rank: p.rank, })), phase: this.game.phase, diff --git a/front/pages/index.tsx b/front/pages/index.tsx index 92d967f..8246f9a 100644 --- a/front/pages/index.tsx +++ b/front/pages/index.tsx @@ -8,7 +8,7 @@ import LoginForm from '../components/LoginForm'; interface GameState { cards: Card[], - players: {username: string, numCards: number, rank: number}[], + players: {username: string, numCards: number, stackSize: number, rank: number}[], lastPlayed: number, lastPlayedPlayer: string | null, playerTurn: string @@ -33,6 +33,8 @@ export default function Game() { const [num, setNum] = useState(0); + const [stackSelected, setStackSelected] = useState([]); + useEffect(() => { const socket = io(process.env.NEXT_PUBLIC_BACK_HOST!); setSocket(socket); @@ -108,6 +110,7 @@ export default function Game() { ); } + const selectedStacks = gameState.players.filter((_, i) => stackSelected[i]); const selectedCards = gameState.cards.filter((_, i) => cardSelected[i]); if (gameState.phase === 0) { return ( @@ -124,7 +127,7 @@ export default function Game() { ); } - else if (gameState.phase === 1) { + if (gameState.phase === 1) { return ( <>