summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-04-28 15:45:29 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-03 18:48:16 +0200
commit54ed5b6dba4a16ebeeb01cea0963f49d2cff6c04 (patch)
treea99e408db1333348d7d6062fccc0a4662263b64b
parentf13ba29fe752ce8698858cbd40faa8337cd76c0f (diff)
downloadandean-abyss-54ed5b6dba4a16ebeeb01cea0963f49d2cff6c04.tar.gz
Check Ecuador stacking for events.
-rw-r--r--events.txt11
-rw-r--r--rules.js27
2 files changed, 24 insertions, 14 deletions
diff --git a/events.txt b/events.txt
index 3fbb72b..a35eecd 100644
--- a/events.txt
+++ b/events.txt
@@ -154,9 +154,8 @@ SHADED 13
EVENT 14
current GOVT
# 5.1.3 - place base if possible!
- # 5.1.3 - TODO Ecuador max 2
prompt "Place 1 Base and 3 Troops into any Department."
- if_space is_dept(s) && can_place_piece(s, GOVT, BASE)
+ if_space is_dept(s) && can_place_base_and_n(s, GOVT, 3, TROOPS)
or_space is_dept(s) && can_stack_any(s, GOVT)
auto_place GOVT BASE
auto_place GOVT TROOPS
@@ -328,7 +327,6 @@ EVENT 25
SHADED 25
prompt "Place 3 FARC pieces into Antioquia or an adjacent Department."
- # TODO Ecuador max 2
space 1 (s === ANTIOQUIA || (is_dept(s) && is_adjacent(ANTIOQUIA, s))) && can_stack_any(s, FARC)
place FARC BASE_GUERRILLA
place FARC BASE_GUERRILLA
@@ -471,9 +469,8 @@ EVENT 34
SHADED 34
current FARC_AUC_CARTELS
# 5.1.3 - place base if possible
- # 5.1.3 - TODO Ecuador max 2
prompt "Place 2 Guerrillas and 1 Base into a 0 Population Department."
- if_space is_zero_pop_dept(s) && can_place_piece(s, game.current, BASE)
+ if_space is_zero_pop_dept(s) && can_place_base_and_n(s, game.current, 2, GUERRILLA)
or_space is_zero_pop_dept(s) && can_stack_any(s, game.current)
auto_place (game.current) BASE
auto_place (game.current) GUERRILLA
@@ -631,7 +628,6 @@ SHADED 42
EVENT 43
# 5.1.3 - farc bases if possible
- # 5.1.3 - TODO Ecuador max 2
prompt "Place 2 Terror and remove all FARC Bases from a Department with Troops."
if_space is_dept(s) && has_troops(s) && has_piece(s, FARC, BASE)
or_space is_dept(s) && has_troops(s)
@@ -763,9 +759,8 @@ EVENT 49
SHADED 49
# 5.1.3 - place base if possible
- # 5.1.3 - TODO Ecuador max 2
prompt "Place an AUC Guerrilla and Base in any Department."
- if_space is_dept(s) && can_place_piece(s, AUC, BASE)
+ if_space is_dept(s) && can_place_base_and_n(s, AUC, 1, GUERRILLA)
or_space is_dept(s) && can_stack_any(s, AUC)
auto_place AUC BASE
auto_place AUC GUERRILLA
diff --git a/rules.js b/rules.js
index d24fbd4..f66c12e 100644
--- a/rules.js
+++ b/rules.js
@@ -1709,6 +1709,21 @@ function can_place_piece(s, faction, type) {
return can_stack_piece(s, faction, type) && has_piece(AVAILABLE, faction, type)
}
+function can_place_base_and_n(s, faction, n, type) {
+ if (s === ECUADOR) {
+ if (!has_capability(EVT_SUCUMBIOS))
+ return false
+ n = Math.min(n, count_pieces(AVAILABLE, faction, type))
+ if (count_faction_pieces(s, faction) + 1 + n > 2)
+ return false
+ }
+ if (!can_place_piece(s, faction, BASE))
+ return false
+ if (!can_stack_any(s, faction))
+ return false
+ return true
+}
+
function did_maximum_damage(targeted) {
// Must do at least something!
if (targeted === 0)
@@ -8469,8 +8484,8 @@ CODE[13 * 2 + 1] = [
CODE[14 * 2 + 0] = [
[ vm_current, GOVT ],
[ vm_prompt, "Place 1 Base and 3 Troops into any Department." ],
- [ vm_if, ()=>can_vm_space(1,(s)=>is_dept(s) && can_place_piece(s, GOVT, BASE)) ],
- [ vm_space, true, 1, 1, (s)=>is_dept(s) && can_place_piece(s, GOVT, BASE) ],
+ [ vm_if, ()=>can_vm_space(1,(s)=>is_dept(s) && can_place_base_and_n(s, GOVT, 3, TROOPS)) ],
+ [ vm_space, true, 1, 1, (s)=>is_dept(s) && can_place_base_and_n(s, GOVT, 3, TROOPS) ],
[ vm_else ],
[ vm_space, true, 1, 1, (s)=>is_dept(s) && can_stack_any(s, GOVT) ],
[ vm_endif ],
@@ -8903,8 +8918,8 @@ CODE[34 * 2 + 0] = [
CODE[34 * 2 + 1] = [
[ vm_current, FARC_AUC_CARTELS ],
[ vm_prompt, "Place 2 Guerrillas and 1 Base into a 0 Population Department." ],
- [ vm_if, ()=>can_vm_space(1,(s)=>is_zero_pop_dept(s) && can_place_piece(s, game.current, BASE)) ],
- [ vm_space, true, 1, 1, (s)=>is_zero_pop_dept(s) && can_place_piece(s, game.current, BASE) ],
+ [ vm_if, ()=>can_vm_space(1,(s)=>is_zero_pop_dept(s) && can_place_base_and_n(s, game.current, 2, GUERRILLA)) ],
+ [ vm_space, true, 1, 1, (s)=>is_zero_pop_dept(s) && can_place_base_and_n(s, game.current, 2, GUERRILLA) ],
[ vm_else ],
[ vm_space, true, 1, 1, (s)=>is_zero_pop_dept(s) && can_stack_any(s, game.current) ],
[ vm_endif ],
@@ -9276,8 +9291,8 @@ CODE[49 * 2 + 0] = [
// SHADED 49
CODE[49 * 2 + 1] = [
[ vm_prompt, "Place an AUC Guerrilla and Base in any Department." ],
- [ vm_if, ()=>can_vm_space(1,(s)=>is_dept(s) && can_place_piece(s, AUC, BASE)) ],
- [ vm_space, true, 1, 1, (s)=>is_dept(s) && can_place_piece(s, AUC, BASE) ],
+ [ vm_if, ()=>can_vm_space(1,(s)=>is_dept(s) && can_place_base_and_n(s, AUC, 1, GUERRILLA)) ],
+ [ vm_space, true, 1, 1, (s)=>is_dept(s) && can_place_base_and_n(s, AUC, 1, GUERRILLA) ],
[ vm_else ],
[ vm_space, true, 1, 1, (s)=>is_dept(s) && can_stack_any(s, AUC) ],
[ vm_endif ],