diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-08-22 21:28:40 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-08-22 21:38:42 +0200 |
commit | bf6a280e8d11940a76c829c6accaedf8e82aad18 (patch) | |
tree | d624d7331546218452b514ffbcd66c7115f5c7c4 | |
parent | 57926abeb710b8311d67b0e0657b8a23f1058323 (diff) | |
download | time-of-crisis-bf6a280e8d11940a76c829c6accaedf8e82aad18.tar.gz |
Only remove governor when support is zero during supply check.
Exception: Mobile Vulgus (remove governor when support reaches zero).
Do not allow Disperse Mob at zero support.
Do not allow support to drop below zero.
-rw-r--r-- | rules.js | 38 |
1 files changed, 26 insertions, 12 deletions
@@ -2030,7 +2030,7 @@ states.take_actions = { if (game.selected_militia >= 0) { view.actions.disperse_mob = 0 - if (game.mip >= 1 && get_mobs(where)) + if (game.mip >= 1 && get_mobs(where) && get_support(where) > 0) view.actions.disperse_mob = 1 // Initiate Battle with Militia not stacked with General @@ -2308,9 +2308,7 @@ function gen_place_governor() { } function reduce_support(where) { - if (get_support(where) === 1) - remove_governor(where, true) - else + if (get_support(where) > 0) set_support(where, get_support(where) - 1) } @@ -3704,6 +3702,8 @@ states.mobile_vulgus = { let n = count_owner_units_in_capital(game.where) 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) resume_take_actions() }, @@ -4790,7 +4790,7 @@ function is_any_rival_emperor_or_pretender() { function needs_support_check() { for (let where = 0; where < 12; ++where) if ((game.count & (1 << where)) === 0) - if (is_own_province(where)) + if (is_own_province(where) && get_support(where) > 0) if (has_active_barbarians(where) || has_rival_emperor(where) || has_enemy_general_in_capital(where)) return true return false @@ -4812,7 +4812,10 @@ states.support_check = { if ((game.count & (1 << where)) === 0) if (is_own_province(where)) if (has_active_barbarians(where) || has_rival_emperor(where) || has_enemy_general_in_capital(where)) - gen_action_region(where) + gen_action_support(where, get_support(where) - 1) + }, + support(arg) { + this.region(arg >> 3) }, region(where) { push_undo() @@ -4824,7 +4827,7 @@ states.support_check = { } function needs_support_check_emperor() { - return is_emperor_player() && is_any_rival_emperor_or_pretender() + return get_support(ITALIA) > 0 && is_emperor_player() && is_any_rival_emperor_or_pretender() } function goto_support_check_emperor() { @@ -4839,7 +4842,10 @@ states.support_check_emperor = { prompt() { prompt("Support Check: Reduce support in Italia for rival emperor and/or pretender on map.") view.color = POPULACE - gen_action_region(ITALIA) + gen_action_support(ITALIA, get_support(ITALIA) - 1) + }, + support(arg) { + this.region(arg >> 3) }, region(where) { push_undo() @@ -4854,6 +4860,7 @@ function needs_support_check_mobs() { for (let where = 0; where < 12; ++where) if (is_own_province(where) && get_mobs(where) >= get_support(where)) return true + return false } function goto_support_check_mobs() { @@ -4866,15 +4873,22 @@ function goto_support_check_mobs() { states.support_check_mobs = { inactive: "Support Check", prompt() { - prompt("Support Check: Remove governors where number of mobs exceed support.") + prompt("Support Check: Remove governors where support level is zero or lower than number of mobs.") view.color = POPULACE - for (let where = 0; where < 12; ++where) - if (is_own_province(where) && get_mobs(where) >= get_support(where)) + for (let where = 0; where < 12; ++where) { + if (is_own_province(where) && get_mobs(where) >= get_support(where)) { gen_action_region(where) + gen_action_governor(get_province_governor(where)) + } + } + }, + governor(id) { + this.region(get_governor_location(id)) }, region(where) { push_undo() - log("Too many mobs in %" + where + ".") + if (get_mobs(where) > 0) + log("Too many mobs in %" + where + ".") remove_governor(where, true) goto_support_check_mobs() }, |