From 9b2ad2b20b3b89ffccec525a3b1637e5f64db122 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 20 Feb 2025 18:24:34 +0100 Subject: Fix infinite loop when player starts with more cards than limit. --- rules.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rules.js b/rules.js index 91d848c..2dd77f5 100644 --- a/rules.js +++ b/rules.js @@ -3986,13 +3986,15 @@ function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_han } else if (turn === "communist" && communist_hand.length < com_hand_limit) { communist_hand.push(draw_card(deck)) turn = "democrat" - } else if (turn === "communist" && communist_hand.length === com_hand_limit) { + } else if (turn === "communist" && communist_hand.length >= com_hand_limit) { turn = "democrat" } else if (turn === "democrat" && democrat_hand.length < dem_hand_limit) { democrat_hand.push(draw_card(deck)) turn = "communist" - } else if (turn === "democrat" && democrat_hand.length === dem_hand_limit) { + } else if (turn === "democrat" && democrat_hand.length >= dem_hand_limit) { turn = "communist" + } else { + throw new Error("Impossible state when drawing cards.") } } clear_undo() -- cgit v1.2.3