From 10f26afeb34d06458fd791a1d330539deb654750 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 May 2024 23:28:15 +0200 Subject: fix edge cases with card draw and deck reconstitution --- rules.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rules.js b/rules.js index a98fc35..254de35 100644 --- a/rules.js +++ b/rules.js @@ -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 -- cgit v1.2.3