summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-10 10:08:30 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-10 10:08:30 +0200
commit4ecc64f25199936de297a66f99d48608bda10470 (patch)
tree78aec82c2325e369974d9a943e2db34b03b3d747
parentaa603ee72fc9572f8120b45b72bfc97ef01c64aa (diff)
downloadandean-abyss-4ecc64f25199936de297a66f99d48608bda10470.tar.gz
Check control of LoC for Extort.
The cached control bit flags only register control for Cities and Depts. Do a dynamic check for LoC control.
-rw-r--r--rules.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index b21db10..d15fe8d 100644
--- a/rules.js
+++ b/rules.js
@@ -1028,14 +1028,20 @@ function remove_farc_zone(s) {
}
function has_govt_control(s) {
+ if (is_loc(s))
+ return calc_control(s) === GOVT
return (s <= last_dept) && game.govt_control & (1 << s)
}
function has_farc_control(s) {
+ if (is_loc(s))
+ return calc_control(s) === FARC
return (s <= last_dept) && game.farc_control & (1 << s)
}
function has_auc_control(s) {
+ if (is_loc(s))
+ return calc_control(s) === AUC
return (s <= last_dept) && game.auc_control & (1 << s)
}
@@ -1250,20 +1256,31 @@ function is_within_adjacent_depts(s, here, depth) {
// === MISC STATE COMMANDS ==
+function calc_control(s) {
+ let g = count_faction_pieces(s, GOVT)
+ let f = count_faction_pieces(s, FARC)
+ let a = count_faction_pieces(s, AUC)
+ let c = count_faction_pieces(s, CARTELS)
+ if (g > a + c + f)
+ return GOVT
+ if (f > g + a + c)
+ return FARC
+ if (a > g + f + c)
+ return AUC
+ return -1
+}
+
function update_control() {
game.govt_control = 0
game.farc_control = 0
game.auc_control = 0
for (let s = first_space; s <= last_dept; ++s) {
- let g = count_faction_pieces(s, GOVT)
- let f = count_faction_pieces(s, FARC)
- let a = count_faction_pieces(s, AUC)
- let c = count_faction_pieces(s, CARTELS)
- if (g > a + c + f)
+ let c = calc_control(s)
+ if (c === GOVT)
game.govt_control |= (1 << s)
- else if (f > g + a + c)
+ else if (c === FARC)
game.farc_control |= (1 << s)
- else if (a > g + f + c)
+ else if (c === AUC)
game.auc_control |= (1 << s)
}
}