diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-04 02:43:18 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-07 19:05:52 +0200 |
commit | 3fd0d79b656c2edd523093e098062e67cb14e60e (patch) | |
tree | 2510f34471407e9426d4ec413526c0e82c2f867c | |
parent | 823c5ef0776c95ec4a8daf70d5c57ee74e457abe (diff) | |
download | time-of-crisis-3fd0d79b656c2edd523093e098062e67cb14e60e.tar.gz |
Lots of tweaks.
-rw-r--r-- | rules.js | 92 |
1 files changed, 54 insertions, 38 deletions
@@ -7,13 +7,16 @@ TODO [ ] display of general+castra stacked with militia+castra [ ] todo: battle twice with militia (remove mbattled?) +TODO: can_select_general - check actual possible actions +TODO: can_select_governor - check actual possible actions + */ var game var view const states = {} -const AUTO_PLAY_EVENTS = true +const AUTO_PLAY_EVENTS = false const P1 = "Red" const P2 = "Blue" @@ -689,6 +692,10 @@ function get_tribe_count() { return get_player_count() + 1 } +function can_general_leave_capital(id) { + return is_general_inside_capital(id) && !has_general_battled(id) +} + function can_enter_capital(where) { // No Capital if (is_no_place_governor(where)) @@ -1781,7 +1788,7 @@ states.take_actions = { break default: // TODO: can_select_general (check possible actions) - if (game.mip >= 1) + if (game.mip >= 1 || can_general_leave_capital(id) || can_enter_capital(get_general_location(id))) gen_action_general(id) break } @@ -2213,9 +2220,12 @@ function place_governor(where, new_governor) { let old_governor = get_province_governor(where) if (old_governor >= 0) { + log("Replaced " + PLAYER_NAME[old_governor/6|0] + ".") set_governor_location(old_governor, AVAILABLE) if (where !== ITALIA && is_governor_of_emperor_player(old_governor)) reduce_support(ITALIA) + } else { + log("Replaced Neutral.") } set_governor_location(new_governor, where) @@ -2227,6 +2237,8 @@ function place_governor(where, new_governor) { if (where !== ITALIA && is_governor_of_emperor_player(new_governor)) increase_support(ITALIA) + log_br() + update_neutral_italia() } @@ -2260,22 +2272,21 @@ function calc_needed_votes(where, pg) { } // ... to a minimum of one - n = Math.max(1, n) - - // Ambitus votes - n -= game.ambitus + return Math.max(1, n) +} +function calc_extra_votes(where) { + let n = game.ambitus // Populace Emperor disadvantage votes if (game.where === ITALIA && is_populace_emperor()) - n -= 2 - + n += 2 return n } states.place_governor = { inactive: "Place Governor", prompt() { - let need = calc_needed_votes(game.where, false) + let need = calc_needed_votes(game.where, false) - calc_extra_votes(game.where) let dice = game.count if (game.where === ITALIA) dice += count_own_basilicas() @@ -2312,7 +2323,7 @@ states.place_governor = { states.praetorian_guard = { inactive: "Praetorian Guard", prompt() { - let need = calc_needed_votes(game.where, true) + let need = calc_needed_votes(game.where, true) - calc_extra_votes(game.where) let dice = game.count if (game.where === ITALIA) dice += count_own_basilicas() @@ -2348,40 +2359,43 @@ states.praetorian_guard = { function roll_to_place_governor(pg) { let need = calc_needed_votes(game.where, pg) - let have = 0 + let have = calc_extra_votes(game.where) set_placed_governor(game.where) if (game.where === ITALIA) game.count += count_own_basilicas() + log_br() if (pg) - log("Praetorian Guard in %" + game.where) + log("Praetorian Guard in %" + game.where + ".") else - log("Place Governor in %" + game.where) + log("Place Governor in %" + game.where + ".") - if (game.where === ITALIA && is_populace_emperor()) - log("Populace Emperor B0 B0") - - if (game.ambitus > 0) { - let str = "Ambitus" - for (let i = 0; i < game.ambitus; ++i) - str += " B0" - log(str) - } + if (need === 1) + log("Need " + need + " vote.") + else + log("Need " + need + " votes.") if (is_neutral_province(game.where)) - have = roll_dice(game.count, 1) + have += roll_dice(game.count, 1) else if (!pg && has_quaestor(game.where)) - have = roll_dice(game.count, 3) + have += roll_dice(game.count, 3) else - have = roll_dice(game.count, 2) + have += roll_dice(game.count, 2) - if (have >= need) { - log("Success!") - log_br() + if (game.where === ITALIA && is_populace_emperor()) { + log("Populace Emperor") + logi("B0 B0") + } + if (game.ambitus > 0) { + log("Ambitus") + logi(new Array(game.ambitus).fill("B0").join(" ")) + } + + if (have >= need) { if (game.where === ITALIA) { // Remember for Damnatio Memoriae let was_senate_emperor = is_senate_emperor() @@ -2588,9 +2602,11 @@ states.becoming_emperor = { let where = get_governor_location(id) if (where === ITALIA) { log("Senate Emperor in Italia.") + log_br() game.state = "take_actions" } else { log("Populace Emperor in %" + where + ".") + log_br() if (has_mobs_in_own_provinces()) game.state = "becoming_populace_emperor" else @@ -2602,6 +2618,7 @@ states.becoming_emperor = { game.emperor = ARMY + id let where = get_general_location(id) log("Military Emperor in %" + where + ".") + log_br() game.state = "take_actions" }, } @@ -2617,7 +2634,7 @@ states.becoming_populace_emperor = { }, region(where) { push_undo() - log("Remove mobs from %" + where + ".") + log("Remove mob from %" + where + ".") set_mobs(where, 0) if (!has_mobs_in_own_provinces()) game.state = "take_actions" @@ -4175,13 +4192,6 @@ states.combat_victory = { } function goto_combat_victory() { - - // Military Emperor check for death in battle - if (game.emperor === ARMY + game.combat.attacker) - roll_military_emperor_check(game.combat.ataken) - else if (game.combat.type === "general" && game.emperor === ARMY + game.combat.target) - roll_military_emperor_check(game.combat.dtaken) - log_br() log("RESULT") let de = is_defender_eliminated() @@ -4292,6 +4302,13 @@ function goto_post_combat() { if (game.selected_general >= 0 && get_general_location(game.selected_general) === AVAILABLE) game.selected_general = -1 + // Military Emperor check for death in battle + if (game.emperor === ARMY + game.combat.attacker) + roll_military_emperor_check(game.combat.ataken) + else if (game.combat.type === "general" && game.emperor === ARMY + game.combat.target) + roll_military_emperor_check(game.combat.dtaken) + + goto_free_increase_support_level() } @@ -4406,8 +4423,7 @@ function goto_support_check() { } game.count = 0 - if (needs_any_support_check()) - log_h2("Support Check") + log_br() resume_support_check() } |