summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js195
1 files changed, 159 insertions, 36 deletions
diff --git a/rules.js b/rules.js
index 54bf7fd..5cbefd0 100644
--- a/rules.js
+++ b/rules.js
@@ -1052,6 +1052,18 @@ function goto_strategy_phase() {
game.state = "strategy_phase"
}
+function end_play_card() {
+ clear_undo()
+ goto_crisis_breach("strategy")
+}
+
+function end_crisis_breach_strategy() {
+ if (game.round === 4)
+ resume_final_crisis()
+ else
+ resume_strategy_phase()
+}
+
function resume_strategy_phase() {
if (game.red_hand.length === 1 && game.blue_hand.length === 1) {
goto_set_aside_cards()
@@ -1284,7 +1296,7 @@ function end_increase_momentum() {
if (game.vm)
vm_next()
else
- end_card_play()
+ end_play_card()
}
function decrease_revolutionary_momentum() {
@@ -1375,40 +1387,146 @@ states.increase_prussian_collaboration_trigger = {
// === CRISIS TRACK & CUBE POOLS ===
-function end_card_play() {
- clear_undo()
- assess_crisis_breach_all()
- if (game.round === 4)
- resume_final_crisis()
- else
- resume_strategy_phase()
+function is_commune_first_to_breach_final() {
+ return count_versailles_cubes(BLUE_CRISIS_TRACK[3]) === 2
}
-function assess_crisis_breach_all() {
- assess_crisis_breach(COMMUNE, 0, RED_CRISIS_TRACK[1], RED_BONUS_CUBES[0], 2, 0)
- assess_crisis_breach(COMMUNE, 1, RED_CRISIS_TRACK[2], RED_BONUS_CUBES[1], 2, 0)
- assess_crisis_breach(COMMUNE, 2, RED_CRISIS_TRACK[3], RED_BONUS_CUBES[2], 2, BLUE_CRISIS_TRACK[3])
- assess_crisis_breach(VERSAILLES, 0, BLUE_CRISIS_TRACK[1], BLUE_BONUS_CUBES[0], 2, 0)
- assess_crisis_breach(VERSAILLES, 1, BLUE_CRISIS_TRACK[2], BLUE_BONUS_CUBES[1], 1, 0)
- assess_crisis_breach(VERSAILLES, 2, BLUE_CRISIS_TRACK[3], BLUE_BONUS_CUBES[2], 2, RED_CRISIS_TRACK[3])
+function is_versailles_first_to_breach_final() {
+ return count_commune_cubes(RED_CRISIS_TRACK[3]) === 2
}
-function assess_crisis_breach(side, i, crisis_track, bonus_cubes, start_count, enemy_final_crisis) {
- let count = count_cubes(crisis_track)
- if (count < start_count && count_cubes(bonus_cubes) > 0) {
- log_br()
- log(side + " breached " + crisis_names[i] + "!")
- if (enemy_final_crisis) {
- if (count_cubes(enemy_final_crisis) === 2) {
- for_each_cube(bonus_cubes, remove_piece)
- add_political_vp(side, -1)
- } else {
- for_each_cube(bonus_cubes, remove_piece_from_play)
- }
- } else {
- for_each_cube(bonus_cubes, remove_piece)
+function goto_crisis_breach(next) {
+ game.breach_active = game.active
+ game.breach_next = next
+ goto_commune_crisis_breach()
+}
+
+function end_crisis_breach() {
+ game.active = game.breach_active
+ let next = game.breach_next
+ delete game.breach_active
+ delete game.breach_next
+ switch (next) {
+ case "strategy":
+ end_crisis_breach_strategy()
+ break
+ case "pivotal":
+ end_crisis_breach_pivotal()
+ break
+ case "objective":
+ end_crisis_breach_objective()
+ break
+ }
+}
+
+function assess_commune_crisis_track(i, an, bn) {
+ let a = count_commune_cubes(RED_CRISIS_TRACK[i+1])
+ let b = count_commune_cubes(RED_BONUS_CUBES[i])
+ if (a < an) {
+ if (b === bn) {
+ log_h3("Commune - " + crisis_names[i])
+ if (i === 2 && is_commune_first_to_breach_final())
+ // TODO: manual VP change?
+ add_political_vp(VERSAILLES, -1)
}
+ return b > 0
}
+ return false
+}
+
+function assess_versailles_crisis_track(i, an, bn) {
+ let a = count_versailles_cubes(BLUE_CRISIS_TRACK[i+1])
+ let b = count_versailles_cubes(BLUE_BONUS_CUBES[i])
+ if (a < an) {
+ if (b === bn) {
+ log_h3("Versailles - " + crisis_names[i])
+ if (i === 2 && is_versailles_first_to_breach_final())
+ // TODO: manual VP change?
+ add_political_vp(COMMUNE, -1)
+ }
+ return b > 0
+ }
+ return false
+}
+
+function goto_commune_crisis_breach() {
+ game.active = COMMUNE
+ game.state = "commune_crisis_breach"
+ if (assess_commune_crisis_track(0, 2, 2))
+ return
+ if (assess_commune_crisis_track(1, 2, 2))
+ return
+ if (assess_commune_crisis_track(2, 2, 2))
+ return
+ end_commune_crisis_breach()
+}
+
+function goto_versailles_crisis_breach() {
+ game.active = VERSAILLES
+ game.state = "versailles_crisis_breach"
+ if (assess_versailles_crisis_track(0, 2, 1))
+ return
+ if (assess_versailles_crisis_track(1, 1, 1))
+ return
+ if (assess_versailles_crisis_track(2, 2, 2))
+ return
+ end_versailles_crisis_breach()
+}
+
+function end_commune_crisis_breach() {
+ goto_versailles_crisis_breach()
+}
+
+function end_versailles_crisis_breach() {
+ end_crisis_breach()
+}
+
+states.commune_crisis_breach = {
+ prompt() {
+ view.prompt = "Crisis Breach: Add cubes to Pool."
+ if (count_commune_cubes(RED_CRISIS_TRACK[1]) < 2)
+ for_each_commune_cube(RED_BONUS_CUBES[0], gen_action_piece)
+ if (count_commune_cubes(RED_CRISIS_TRACK[2]) < 2)
+ for_each_commune_cube(RED_BONUS_CUBES[1], gen_action_piece)
+ if (count_commune_cubes(RED_CRISIS_TRACK[3]) < 2)
+ for_each_commune_cube(RED_BONUS_CUBES[2], gen_action_piece)
+ },
+ piece(p) {
+ if (p === RED_BONUS_CUBES[2] && !is_commune_first_to_breach_final()) {
+ remove_piece_from_play(p)
+ log("Removed RC from bonus.")
+ } else {
+ remove_piece(p)
+ if (game.pieces[p] < 0)
+ log("Removed RC from bonus.")
+ else
+ log("Added RC to Pool.")
+ }
+ goto_commune_crisis_breach()
+ },
+}
+
+states.versailles_crisis_breach = {
+ prompt() {
+ view.prompt = "Crisis Breach: Add cubes to Pool."
+ if (count_versailles_cubes(BLUE_CRISIS_TRACK[1]) < 2)
+ for_each_versailles_cube(BLUE_BONUS_CUBES[0], gen_action_piece)
+ if (count_versailles_cubes(BLUE_CRISIS_TRACK[2]) < 1)
+ for_each_versailles_cube(BLUE_BONUS_CUBES[1], gen_action_piece)
+ if (count_versailles_cubes(BLUE_CRISIS_TRACK[3]) < 2)
+ for_each_versailles_cube(BLUE_BONUS_CUBES[2], gen_action_piece)
+ },
+ piece(p) {
+ let s = game.pieces[p]
+ if (s === BLUE_BONUS_CUBES[2] && !is_versailles_first_to_breach_final()) {
+ remove_piece_from_play(p)
+ log("Removed BC from bonus.")
+ } else {
+ remove_piece(p)
+ log("Added BC to Pool.")
+ }
+ goto_versailles_crisis_breach()
+ },
}
// === OPERATIONS ===
@@ -1663,7 +1781,7 @@ function end_operations() {
if (game.vm)
vm_next()
else
- end_card_play()
+ end_play_card()
}
// === SET ASIDE CARDS ===
@@ -1691,7 +1809,10 @@ function goto_pivotal_space_bonus_actions() {
function resume_pivotal_space_bonus_actions() {
clear_undo()
- assess_crisis_breach_all()
+ goto_crisis_breach("pivotal")
+}
+
+function end_crisis_breach_pivotal() {
game.active = game.initiative
if (game.spaces.length > 0)
game.state = "pivotal_space_bonus_actions"
@@ -2119,7 +2240,7 @@ states.final_crisis_opponent_event = {
pass() {
log_h3(game.active + " - Pass")
logi("C" + game.what)
- end_card_play()
+ end_play_card()
},
}
@@ -2186,15 +2307,18 @@ function goto_play_event(c) {
function end_event() {
if (is_objective_card(game.vm.fp)) {
- assess_crisis_breach_all()
game.vm = null
- resume_objective_card_events()
+ goto_crisis_breach("objective")
} else {
game.vm = null
- end_card_play()
+ end_play_card()
}
}
+function end_crisis_breach_objective() {
+ resume_objective_card_events()
+}
+
function goto_vm(proc) {
game.state = "vm"
game.vm = {
@@ -2225,7 +2349,6 @@ function vm_operand(a) {
}
function vm_exec() {
- console.log("VM", game.vm.fp, game.vm.ip, vm_inst(0).name)
vm_inst(0)()
}