diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-02 15:38:10 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-27 12:00:41 +0100 |
commit | afb2a57376a1ea25a807ca016b9564a339f192ba (patch) | |
tree | 6127cde68d9c016783ebaa4e32a727a2459fb201 | |
parent | ba532d98fd0f2f848f9cf4d804b3a5a29daba7ab (diff) | |
download | time-of-crisis-afb2a57376a1ea25a807ca016b9564a339f192ba.tar.gz |
v2: build new improvements
-rw-r--r-- | rules.js | 94 |
1 files changed, 77 insertions, 17 deletions
@@ -680,16 +680,35 @@ function find_unused_legion() { return -1 } -function can_build_improvement(province) { - if (has_amphitheater(province) && has_basilica(province) && has_limes(province)) +function count_improvements(where) { + let n = 0 + if (has_amphitheater(where)) + ++n + if (has_basilica(where)) + ++n + if (has_limes(where)) + ++n + if (has_market(where)) + ++n + if (has_monument(where)) + ++n + if (has_port(where)) + ++n + if (has_temple(where)) + ++n + return n +} + +function can_build_improvement(where) { + if (count_improvements(where) >= 3) return false - if (get_mobs(province)) + if (get_mobs(where)) return false - if (has_active_barbarians(province)) + if (has_active_barbarians(where)) return false - if (has_rival_emperor(province)) + if (has_rival_emperor(where)) return false - if (has_enemy_general_in_capital(province)) + if (has_enemy_general_in_capital(where)) return false return true } @@ -1045,12 +1064,7 @@ function count_own_improvements() { let n = 0 for (let where = 0; where < 12; ++where) { if (is_own_province(where)) { - if (has_amphitheater(where)) - ++n - if (has_basilica(where)) - ++n - if (has_limes(where)) - ++n + n += count_improvements(where) } } return n @@ -2301,16 +2315,42 @@ states.build_improvement = { view.color = POPULACE view.selected_region = game.where - view.actions.amphitheater = 0 - view.actions.basilica = 0 - view.actions.limes = 0 - if (!has_amphitheater(game.where)) - view.actions.amphitheater = 1 + if (is_classic()) { + if (!has_amphitheater(game.where)) + view.actions.amphitheater = 1 + else + view.actions.amphitheater = 0 + } + if (!has_basilica(game.where)) view.actions.basilica = 1 + else + view.actions.basilica = 0 + if (!has_limes(game.where)) view.actions.limes = 1 + else + view.actions.limes = 0 + + if (is_deluxe()) { + if (!has_market(game.where)) + view.actions.market = 1 + else + view.actions.market = 0 + if (!has_monument(game.where)) + view.actions.monument = 1 + else + view.actions.monument = 0 + if (!has_port(game.where)) + view.actions.port = 1 + else + view.actions.port = 0 + if (!has_temple(game.where)) + view.actions.temple = 1 + else + view.actions.temple = 0 + } }, amphitheater() { add_amphitheater(game.where) @@ -2327,6 +2367,26 @@ states.build_improvement = { log("Build Limes in %" + game.where + ".") resume_take_actions() }, + market() { + add_market(game.where) + log("Build Market in %" + game.where + ".") + resume_take_actions() + }, + monument() { + add_monument(game.where) + log("Build Monument in %" + game.where + ".") + resume_take_actions() + }, + port() { + add_port(game.where) + log("Build Port in %" + game.where + ".") + resume_take_actions() + }, + temple() { + add_temple(game.where) + log("Build Temple in %" + game.where + ".") + resume_take_actions() + }, } // ACTION: INCREASE SUPPORT LEVEL |