summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js2
-rw-r--r--rules.js67
2 files changed, 30 insertions, 39 deletions
diff --git a/play.js b/play.js
index e538cb9..8248ede 100644
--- a/play.js
+++ b/play.js
@@ -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")
diff --git a/rules.js b/rules.js
index c601859..ab926c8 100644
--- a/rules.js
+++ b/rules.js
@@ -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()