summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-08-02 15:38:10 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-05 20:46:48 +0200
commit49b08c3a8d0af28317f5ad7a93142be201e4cef6 (patch)
tree22014f742772239adb0e7f6e5b1a18702a1be20f /rules.js
parente0a0d1a57d4ef0c45509f5241b0d1aebf312e4a1 (diff)
downloadtime-of-crisis-49b08c3a8d0af28317f5ad7a93142be201e4cef6.tar.gz
v2: build new improvements
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js94
1 files changed, 77 insertions, 17 deletions
diff --git a/rules.js b/rules.js
index bbc9550..5bb85bc 100644
--- a/rules.js
+++ b/rules.js
@@ -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