diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -3982,13 +3982,9 @@ function draw_deck() { function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_hand_limit) { let turn = "communist" while (democrat_hand.length < dem_hand_limit || communist_hand.length < com_hand_limit) { - if (deck.length === 0) { - log_h3("--- Reshuffle ---") - deck.push(...game.strategy_discard) - game.strategy_discard = [] - if (deck.length === 0) - throw "NO MORE CARDS" // abort! - } else if (turn === "communist" && communist_hand.length < com_hand_limit) { + if (deck.length === 0) + reshuffle(deck) + 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) { @@ -4002,9 +3998,19 @@ function draw_cards(deck, democrat_hand, communist_hand, dem_hand_limit, com_han throw new Error("Impossible state when drawing cards.") } } + if (deck.length === 0) + reshuffle(deck) clear_undo() } +function reshuffle(deck) { + log_h3("--- Reshuffle ---") + deck.push(...game.strategy_discard) + game.strategy_discard = [] + if (deck.length === 0) + throw "NO MORE CARDS" // abort! +} + function draw_card(deck) { if (deck.length === 0) { log_h3('--- Reshuffle ---') |