From f7403f41bfc1a563a15cffb816619f96dd79ef8c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 14 Jul 2023 12:35:54 +0200 Subject: Don't allow trashing to below 4 cards. Handle Pax Deorum when all cards are in hand. --- rules.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/rules.js b/rules.js index c3f021e..33cfa25 100644 --- a/rules.js +++ b/rules.js @@ -1378,11 +1378,14 @@ function goto_pax_deorum() { } function resume_pax_deorum() { - game.state = "pax_deorum" - if (game.draw[game.current].length === 0) { + if (game.draw[game.current].length === 0 && game.discard[game.current].length > 0) { log(PLAYER_NAME[game.current] + " put discard in available.") flip_discard_to_available() } + if (game.draw[game.current].length > 0) + game.state = "pax_deorum" + else + game.state = "pax_deorum_done" } states.pax_deorum = { @@ -5026,6 +5029,10 @@ function spend_senate_credit(cost) { return cost - credit } +function count_owned_cards() { + return game.draw[game.current].length + game.discard[game.current].length + game.hand[game.current].length +} + states.buy_trash = { inactive: "Buy/Trash Cards", prompt() { @@ -5036,10 +5043,15 @@ states.buy_trash = { view.prompt += " " + game.sip + " senate credits." let nprov = count_own_provinces() + if (game.pp >= 3) { - for (let c of current_discard()) - gen_action_card(c) + // Don't trash if it would leave you with fewer than 4 cards. + // Worst case: 3x Demagogue + Ludi Saeculares + if (count_owned_cards() > 4) + for (let c of current_discard()) + gen_action_card(c) } + for (let m of game.market) { if (m.length > 0) { let c = m[0] -- cgit v1.2.3