summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js71
1 files changed, 44 insertions, 27 deletions
diff --git a/rules.js b/rules.js
index 0bd537f..6d83184 100644
--- a/rules.js
+++ b/rules.js
@@ -651,7 +651,18 @@ function can_build_improvement(province) {
return true
}
-function update_neutral_italia() {
+function adjust_neutral_italia(add) {
+ if (is_neutral_province(ITALIA)) {
+ let n = get_support(ITALIA) + add
+ if (n < 1) {
+ log("Removed governor in Italia.")
+ reset_neutral_italia()
+ } else
+ set_support(ITALIA, n)
+ }
+}
+
+function reset_neutral_italia() {
if (is_neutral_province(ITALIA)) {
let n = 1
for (let s = 1; s < 12; ++s)
@@ -1204,7 +1215,7 @@ states.setup_province = {
set_general_inside_capital(game.current * 6 + 0)
set_legion_location(find_unused_legion(), ARMY + game.current * 6 + 0)
- update_neutral_italia()
+ reset_neutral_italia()
clear_undo()
game.current = next_player()
@@ -2334,10 +2345,12 @@ function remove_governor(where, verbose) {
reduce_support(ITALIA)
}
- if (where !== ITALIA)
+ if (where !== ITALIA) {
set_support(where, 1)
-
- update_neutral_italia()
+ adjust_neutral_italia(1)
+ } else {
+ reset_neutral_italia()
+ }
}
function place_governor(where, new_governor) {
@@ -2357,15 +2370,16 @@ function place_governor(where, new_governor) {
}
set_governor_location(new_governor, where)
- if (where === ITALIA)
+ if (where === ITALIA) {
set_support(where, count_own_provinces())
- else
+ } else {
set_support(where, Math.max(1, get_support(where) - 1))
+ if (is_governor_of_emperor_player(new_governor))
+ increase_support(ITALIA)
+ else if (old_governor < 0)
+ adjust_neutral_italia(-1)
+ }
- if (where !== ITALIA && is_governor_of_emperor_player(new_governor))
- increase_support(ITALIA)
-
- update_neutral_italia()
}
function count_units_in_capital(where) {
@@ -3055,7 +3069,8 @@ states.replace_pretender_governor = {
set_governor_location(id, game.where)
if (is_emperor_player())
increase_support(ITALIA)
- update_neutral_italia()
+ else
+ adjust_neutral_italia(1)
end_occupation_of_pretender_capital()
},
pass() {
@@ -3652,17 +3667,22 @@ states.frumentarii = {
// CARD: Mobile Vulgus
-function can_play_mobile_vulgus() {
- for (let where = 0; where < 12; ++where) {
- if (is_enemy_province(where)) {
- let n = get_support(where) + count_owner_units_in_capital(where)
- if (game.pip >= n)
- return true
- }
+function can_mobile_vulgus_in_province(where) {
+ if (is_enemy_province(where) || (where === ITALIA && is_neutral_province(ITALIA))) {
+ let n = get_support(where) + count_owner_units_in_capital(where)
+ if (game.pip >= n)
+ return true
}
return false
}
+function can_play_mobile_vulgus() {
+ for (let where = 0; where < 12; ++where)
+ if (can_mobile_vulgus_in_province(where))
+ return true
+ return false
+}
+
function play_mobile_vulgus() {
game.state = "mobile_vulgus_where"
}
@@ -3673,11 +3693,8 @@ states.mobile_vulgus_where = {
prompt("Mobile Vulgus: Choose a province...")
view.color = POPULACE
for (let where = 0; where < 12; ++where) {
- if (is_enemy_province(where)) {
- let n = get_support(where) + count_owner_units_in_capital(where)
- if (game.pip >= n)
- gen_action_region(where)
- }
+ if (can_mobile_vulgus_in_province(where))
+ gen_action_region(where)
}
},
region(where) {
@@ -3703,8 +3720,8 @@ states.mobile_vulgus = {
spend_populace(get_support(game.where) + n)
reduce_support(game.where)
if (get_support(game.where) === 0)
- remove_governor(game.where)
- if (is_neutral_province(game.where) || game.pip < get_support(game.where) + n)
+ remove_governor(game.where, true)
+ if (!can_mobile_vulgus_in_province(game.where))
resume_take_actions()
},
done() {
@@ -5580,7 +5597,7 @@ exports.setup = function (seed, scenario, options) {
game.discard[player] = []
}
- update_neutral_italia()
+ reset_neutral_italia()
game.first = game.current = random(player_count)