diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-20 18:24:34 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-20 18:26:38 +0100 |
commit | 9b2ad2b20b3b89ffccec525a3b1637e5f64db122 (patch) | |
tree | 11b5426ae87ed87b39eac75282f614ff545c1377 | |
parent | 956f0be01f7027a6ea4053132d1c5d154ba0826e (diff) | |
download | 1989-dawn-of-freedom-9b2ad2b20b3b89ffccec525a3b1637e5f64db122.tar.gz |
Fix infinite loop when player starts with more cards than limit.
-rw-r--r-- | rules.js | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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() |