summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-04-09 21:46:05 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-03 18:48:16 +0200
commit17af660afb8b6d9a0eabccb9cc9b911d9f51eec5 (patch)
tree3d9c3957042128998c4f851250e3e1e81d97ebca /rules.js
parente1e051c1783e4aeee4bee7a93110d05d5aca1597 (diff)
downloadandean-abyss-17af660afb8b6d9a0eabccb9cc9b911d9f51eec5.tar.gz
Manual Sabotage.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js72
1 files changed, 59 insertions, 13 deletions
diff --git a/rules.js b/rules.js
index fb06fde..433afd3 100644
--- a/rules.js
+++ b/rules.js
@@ -2,9 +2,13 @@
// TODO: rules material - reference 6.3.3 Drug Profits to 5.2.2 should be 4.5.3
-// TODO: game.memory instead of president/aid/cylinder/resources/samper/pieces/
-// TODO: clean up init_free_operation and transitions
-// OP in a space -> next() transition handler to deal with ops/events/elite-backing in a common way
+// TODO: compact game.memory array instead of president/aid/cylinder/resources/samper/pieces/support/control
+// TODO: bit array for momentum and capabilities instead of set lists
+// TODO: clean up init_free_operation stuff
+
+// TODO: check how often and where to push_undo
+
+// TODO: log when resource/aid is capped
const AUTOMATIC = true
@@ -2221,6 +2225,10 @@ function end_operation() {
function goto_pass() {
push_undo()
+
+ game.op = 0
+ game.sa = 0
+
game.cylinder[game.current] = SOP_PASS
log_h2(faction_name[game.current] + " - Pass")
if (game.current === GOVT)
@@ -5301,18 +5309,24 @@ function goto_final_victory() {
function goto_sabotage_phase() {
game.prop.step = 2
- game.current = GOVT
+ game.current = FARC
log_h2("Sabotage Phase")
- for (let s = first_loc; s <= last_loc; ++s) {
- if (can_sabotage_phase_space(s)) {
- log("Sabotaged S" + s + ".")
- place_sabotage(s)
+ if (false) {
+ for (let s = first_loc; s <= last_loc; ++s) {
+ if (can_sabotage_phase_space(s)) {
+ log("Sabotaged S" + s + ".")
+ place_sabotage(s)
+ }
}
+ goto_resources_phase()
+ } else {
+ if (can_sabotage_phase())
+ game.state = "sabotage"
+ else
+ goto_resources_phase()
}
-
- goto_resources_phase()
}
function is_adjacent_to_city_farc_control(s) {
@@ -5322,6 +5336,13 @@ function is_adjacent_to_city_farc_control(s) {
return false
}
+function can_sabotage_phase() {
+ for (let s = first_loc; s <= last_loc; ++s)
+ if (can_sabotage_phase_space(s))
+ return true
+ return false
+}
+
function can_sabotage_phase_space(s) {
if (!has_sabotage(s)) {
if (is_adjacent_to_city_farc_control(s))
@@ -5333,6 +5354,20 @@ function can_sabotage_phase_space(s) {
return false
}
+states.sabotage = {
+ prompt() {
+ view.prompt = "Sabotage LoCs."
+ for (let s = first_loc; s <= last_loc; ++s)
+ if (can_sabotage_phase_space(s))
+ gen_action_space(s)
+ },
+ space(s) {
+ place_sabotage(s)
+ if (!can_sabotage_phase())
+ goto_resources_phase()
+ },
+}
+
// PROPAGANDA: RESOURCES PHASE
function calc_govt_earnings() {
@@ -5460,6 +5495,11 @@ function can_agitate(s) {
function goto_support_phase() {
game.prop.step = 4
log_h2("Support Phase")
+ goto_support_civic_action()
+}
+
+function goto_support_civic_action() {
+ // TODO: skip civic action if not possible?
log_h3("Civic Action")
game.current = GOVT
game.state = "civic_action"
@@ -5488,12 +5528,17 @@ states.civic_action = {
},
next() {
clear_undo()
- log_h3("Agitation")
- game.current = FARC
- game.state = "agitation"
+ goto_support_agitation()
},
}
+function goto_support_agitation() {
+ // TODO: skip agitation if not possible?
+ log_h3("Agitation")
+ game.current = FARC
+ game.state = "agitation"
+}
+
states.agitation = {
prompt() {
view.prompt = "Agitation: Encourage Opposition in Cities and Departments."
@@ -5797,6 +5842,7 @@ function goto_event(shaded) {
move_cylinder_to_event()
let c = this_card()
+ game.op = 0
game.sa = 0
if (shaded) {