summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-05 14:39:52 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-05 14:39:52 +0200
commit80c9051afc6e6804f04d44f5e8cad22c7fed823a (patch)
tree59d322e7681c09c821b4f3d9cfa992c902fb4e8f
parent6694167b8f0e2427b3e0ccb8da94cfb2a652dd09 (diff)
downloadandean-abyss-80c9051afc6e6804f04d44f5e8cad22c7fed823a.tar.gz
Fix Kidnap possibility checks.
Can't Kidnap if no resources to take, or if no shipment to steal.
-rw-r--r--rules.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/rules.js b/rules.js
index 1f2a719..25a4b72 100644
--- a/rules.js
+++ b/rules.js
@@ -5181,11 +5181,32 @@ function goto_kidnap() {
game.state = "kidnap"
}
+function is_govt_kidnap_space(s) {
+ return is_city_or_loc(s) && game.resources[GOVT] > 0
+}
+
+function is_cartels_kidnap_space(s) {
+ if (has_piece(s, CARTELS, BASE)) {
+ if (game.resources[CARTELS] > 0)
+ return true
+ if (is_any_shipment_held_by_faction_in_space(CARTELS, s))
+ return true
+ }
+ return false
+}
+
function can_kidnap_in_space(s) {
// City, LoC, or Cartels Base
if (is_city_or_loc(s) || has_piece(s, CARTELS, BASE)) {
// FARC Guerrillas outnumber Police
if (count_pieces(s, FARC, GUERRILLA) > count_pieces(s, GOVT, POLICE)) {
+ let g = is_govt_kidnap_space(s)
+ let c = is_cartels_kidnap_space(s)
+
+ // Nothing to take!
+ if (!g && !c)
+ return false
+
// Selected for Terror
if (is_selected_op_space(s))
return true
@@ -5246,8 +5267,8 @@ states.kidnap_space = {
let s = game.sa.where
- let g = is_city_or_loc(s) && game.resources[GOVT] > 0
- let c = has_piece(s, CARTELS, BASE) && game.resources[CARTELS] > 0
+ let g = is_govt_kidnap_space(s)
+ let c = is_cartels_kidnap_space(s)
if (g)
gen_action_resources(GOVT)