diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-09 14:40:08 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-09 14:40:08 +0200 |
commit | c35fade0634a90576e483bbe229dc7f3f9b8b497 (patch) | |
tree | 9f1666c3c78ca6075b78599ace2edc3ba71ad3aa | |
parent | 20acf7157cbeb49d8a684313eb7de659603c84fe (diff) | |
download | time-of-crisis-c35fade0634a90576e483bbe229dc7f3f9b8b497.tar.gz |
Improve Automatic UI.
-rw-r--r-- | play.js | 2 | ||||
-rw-r--r-- | rules.js | 67 |
2 files changed, 30 insertions, 39 deletions
@@ -1508,7 +1508,7 @@ function on_update() { action_button("enter", "Enter Capital") action_button("leave", "Leave Capital") - action_button("spend_enough", "Automatic") + action_button("automatic", "Automatic") action_button("spend_military", "Spend Military") action_button("spend_senate", "Spend Senate") action_button("reroll", "Reroll") @@ -2383,6 +2383,31 @@ function format_votes(need, extra, dice) { return s } +function gen_place_governor_spend(ip, enough, action) { + view.selected_region = game.where + view.selected_governor = game.selected_governor + + if (game.ambitus < game.count && has_card_event(CARD_P2X)) { + view.prompt += " Ambitus?" + gen_card_event(CARD_P2X) + } + + if (is_neutral_province(game.where)) { + if (enough > 0) { + view.actions[action] = (ip >= 1) ? 1 : 0 + view.actions.automatic = 0 + view.actions.roll = 1 + } else { + view.actions[action] = 0 + view.actions.automatic = 1 + view.actions.roll = 0 + } + } else { + view.actions[action] = (ip >= 1) ? 1 : 0 + view.actions.roll = 1 + } +} + states.place_governor = { inactive: "Place Governor", prompt() { @@ -2390,25 +2415,8 @@ states.place_governor = { let extra = calc_extra_votes() let dice = calc_used_dice() view.color = SENATE - view.selected_region = game.where - view.selected_governor = game.selected_governor prompt("Place Governor: " + game.sip + " senate. " + format_votes(need, extra, dice)) - if (game.ambitus < game.count && has_card_event(CARD_P2X)) { - view.prompt += " Ambitus?" - gen_card_event(CARD_P2X) - } - if (game.sip >= 1) - view.actions.spend_senate = 1 - else - view.actions.spend_senate = 0 - if (is_neutral_province(game.where)) { - let enough = Math.max(0, need - extra - dice) - if (game.sip >= enough) - view.actions.spend_enough = 1 - else - view.actions.spend_enough = 0 - } - view.actions.roll = 1 + gen_place_governor_spend(game.sip, need - extra - dice, "spend_senate") }, card(c) { push_undo() @@ -2420,7 +2428,7 @@ states.place_governor = { spend_senate(1) game.count += 1 }, - spend_enough() { + automatic() { push_undo() let need = calc_needed_votes(false) let extra = calc_extra_votes() @@ -2443,25 +2451,8 @@ states.praetorian_guard = { let extra = calc_extra_votes() let dice = calc_used_dice() view.color = MILITARY - view.selected_region = game.where - view.selected_governor = game.selected_governor prompt("Praetorian Guard: " + game.mip + " military. " + format_votes(need, extra, dice)) - if (game.ambitus < game.count && has_card_event(CARD_P2X)) { - view.prompt += " Ambitus?" - gen_card_event(CARD_P2X) - } - if (game.mip >= 1) - view.actions.spend_military = 1 - else - view.actions.spend_military = 0 - if (is_neutral_province(game.where)) { - let enough = Math.max(0, need - extra - dice) - if (game.mip >= enough) - view.actions.spend_enough = 1 - else - view.actions.spend_enough = 0 - } - view.actions.roll = 1 + gen_place_governor_spend(game.mip, need - extra - dice, "spend_military") }, card(c) { push_undo() @@ -2473,7 +2464,7 @@ states.praetorian_guard = { spend_military(1) game.count += 1 }, - spend_enough() { + automatic() { push_undo() let need = calc_needed_votes(true) let extra = calc_extra_votes() |