diff --git a/back/src/Game.ts b/back/src/Game.ts index 9b0b5d6..61bbdf9 100644 --- a/back/src/Game.ts +++ b/back/src/Game.ts @@ -67,19 +67,17 @@ export default class Game { } const startingPlayer = this.players[0]; // Pick a random starting player instead?? this.playerTurn = this.players.indexOf(startingPlayer); + this.playersFinished = this.room.clients.length; + // Run the game while (true) { - // Check if game ended - // Rewrite const playersLeft: Player[] = []; this.players.forEach((p: Player) => { - if (!p.rank && !p.disconnected) - playersLeft.push(p); + if (!p.rank && !p.disconnected) { + if (p.cards.length === 0) p.rank = this.playersFinished--; + else playersLeft.push(p); + } }); - if (playersLeft.length < 2) { - if (playersLeft.length === 1) - playersLeft[0].rank = ++this.playersFinished; // rank is reversed, fix later - break; - } + if (playersLeft.length === 1) break; await this.round(); } this.broadcastGameState(); diff --git a/front/pages/index.tsx b/front/pages/index.tsx index 9dd7293..17dca58 100644 --- a/front/pages/index.tsx +++ b/front/pages/index.tsx @@ -18,6 +18,20 @@ interface GameState { const rankStrs = ['', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']; const suitChars = ['♣', '♦', '♥', '♠']; +const rules = String.raw`Welcome to BSX!\n +
+There are only 5 simple rules!
+ +1. You will first be dealt 5 cards. + +2. At the beginning of each round, you must rearrange the order of your cards and place them face down in a stack. + +3. During the round, players go around in a circle, claiming increasingly greater numbers. If it is you turn to claim a number, you must either claim a larger number than the previously claimed number or call BS. If you call BS, the previous player must flip over their claimed number of black (clubs or spades) cards from the tops of everyone's stacks. + +4. If the previous player manages to flip over their claimed number of black cards, you must choose a card from your stack to give up. Otherwise, the previous player must choose one of their cards to give up. + +5. If you give up all your cards, you lose! Last player remaining wins!` + function useForceUpdate(){ const [value, setValue] = useState(0); return () => setValue(value => value + 1); @@ -71,14 +85,16 @@ export default function Game() { if (!socket) return null; if (!loggedIn) { return ( - { - setLoggedIn(true); - setUsername(s); - }} - username={username} - /> + <> + { + setLoggedIn(true); + setUsername(s); + }} + username={username} + /> + ); } if (!room) {