summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-06 22:46:08 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 19:05:52 +0200
commit78cbb621a1cef47ce2d79b40f5ab2a2c13872a9d (patch)
treebca99af77933c629e2d0984b2e07f833435e9f12 /rules.js
parente137caa6f4cef04e18c8ecb2f41df49682f87678 (diff)
downloadtime-of-crisis-78cbb621a1cef47ce2d79b40f5ab2a2c13872a9d.tar.gz
Format votes as need + have + dice.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/rules.js b/rules.js
index ee82eeb..01c874c 100644
--- a/rules.js
+++ b/rules.js
@@ -2368,17 +2368,26 @@ function calc_extra_votes(where) {
return n
}
+function format_votes(need, extra, dice) {
+ let s = "Need " + need + (need === 1 ? " vote." : " votes.")
+ if (extra > 0)
+ s += " Have " + extra + (extra === 1 ? " vote." : " votes.")
+ s += " Rolling " + dice + (dice === 1 ? " die." : " dice.")
+ return s
+}
+
states.place_governor = {
inactive: "Place Governor",
prompt() {
- let need = Math.max(0, calc_needed_votes(game.where, false) - calc_extra_votes(game.where))
+ let need = calc_needed_votes(game.where, false)
+ let extra = calc_extra_votes(game.where)
let dice = game.count
if (game.where === ITALIA)
dice += count_own_basilicas()
view.color = SENATE
view.selected_region = game.where
view.selected_governor = game.selected_governor
- prompt(`Place Governor: ${game.sip} senate. Rolling ${dice} dice. ${need} votes needed.`)
+ 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)
@@ -2408,14 +2417,15 @@ states.place_governor = {
states.praetorian_guard = {
inactive: "Praetorian Guard",
prompt() {
- let need = Math.max(0, calc_needed_votes(game.where, true) - calc_extra_votes(game.where))
+ let need = calc_needed_votes(game.where, true)
+ let extra = calc_extra_votes(game.where)
let dice = game.count
if (game.where === ITALIA)
dice += count_own_basilicas()
view.color = MILITARY
view.selected_region = game.where
view.selected_governor = game.selected_governor
- prompt(`Praetorian Guard: ${game.mip} military. Rolling ${dice} dice. ${need} votes needed.`)
+ 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)