diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-05-22 23:28:15 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-05-30 21:59:25 +0200 |
commit | 10f26afeb34d06458fd791a1d330539deb654750 (patch) | |
tree | 89bca535107a3462044768c7c300c3ddec7fd55b | |
parent | 76a70112e397a6be8ea7375113fa7c23209d08e6 (diff) | |
download | friedrich-10f26afeb34d06458fd791a1d330539deb654750.tar.gz |
fix edge cases with card draw and deck reconstitution
-rw-r--r-- | rules.js | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -795,9 +795,13 @@ function next_tactics_deck() { let held = [ 0, 0, 0, 0 ] // count cards in hands - for (let pow of all_powers) + for (let pow of all_powers) { for (let c of game.hand[pow]) held[to_deck(c)]++ + } + if (game.draw) + for (let c of game.draw) + held[to_deck(c)]++ // find next unused deck for (let i = 1; i < 4; ++i) { @@ -808,6 +812,8 @@ function next_tactics_deck() { } } + log("Discards " + held.map(x=>50-x).join(", ")) + // find two largest discard piles let a = find_largest_discard(held) if (held[a] === 50) @@ -866,7 +872,7 @@ function should_power_discard_tc() { states.tactical_cards = { prompt() { view.draw = game.draw - if (should_power_discard_tc()) { + if (should_power_discard_tc() && game.draw.length > 0) { prompt("Drew " + game.draw.length + " TCs. Discard one of them.") for (let c of game.draw) gen_action_card(c) @@ -2279,6 +2285,8 @@ function make_tactics_deck(n) { function make_tactics_discard(n) { return make_tactics_deck(n).filter(c => { + if (game.draw && set_has(game.draw, c)) + return false for (let pow of all_powers) if (set_has(game.hand[pow], c)) return false |