summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-07-03 23:55:08 +0200
committerTor Andersson <tor@ccxvii.net>2024-08-21 00:28:20 +0200
commitb229c12bcc1796936e8ef78d15d7fad20f219df9 (patch)
tree2c4d2f8d8e2e33b0771bc2354561de616efdaa45
parent9fa1ec26370a79a0f55a4a9a677aa61132eb3204 (diff)
downloadwashingtons-war-b229c12bcc1796936e8ef78d15d7fad20f219df9.tar.gz
disperse congress and overrun _after_ intercept/retreat before battle.
-rw-r--r--rules.js83
1 files changed, 40 insertions, 43 deletions
diff --git a/rules.js b/rules.js
index ebf090b..241b327 100644
--- a/rules.js
+++ b/rules.js
@@ -1,8 +1,7 @@
"use strict"
// TODO: capture washington
-// TODO: retreat with 0 CU after battle ?
-// TODO: retreat with 0 CU into lone enemy general ?
+// TODO: remove general after placing rochambeau
/* washington's capture
- winning general with no CU on enemy PC (no undo anyway)
@@ -1781,7 +1780,8 @@ states.remove_general_after_retreat = {
move_general(g, BRITISH_REINFORCEMENTS)
else
move_general(g, AMERICAN_REINFORCEMENTS)
- goto_end_battle()
+ end_battle()
+ next_strategy_card() // NOTE: skip pause at end of movement
},
}
@@ -1932,26 +1932,18 @@ states.ops_general_move = {
move_army(game.move)
- // TODO: overrun after intercept?
- // TODO: disperse continental congress after intercept?
-
- if (cu > 0) {
- if (game.active === P_BRITAIN && game.congress === to && !has_enemy_cu(to)) {
- disperse_continental_congress()
- }
- if (cu >= 4 && count_enemy_cu(to) === 1 && !has_enemy_general(to)) {
- overrun(to)
- }
- }
-
if (may_intercept)
game.state = "confirm_move_intercept"
- else if (game.active === P_BRITAIN && has_enemy_cu(game.move.to))
- game.state = "confirm_move_battle"
- else if (game.active === P_AMERICA && has_enemy_cu(game.move.to))
- goto_start_battle()
- else
- resume_moving()
+ else {
+ disperse_and_overrun_after_move()
+
+ if (game.active === P_BRITAIN && has_enemy_cu(game.move.to))
+ game.state = "confirm_move_battle"
+ else if (game.active === P_AMERICA && has_enemy_cu(game.move.to))
+ goto_start_battle()
+ else
+ resume_moving()
+ }
},
stop() {
push_undo()
@@ -1982,6 +1974,19 @@ states.confirm_move_battle = {
},
}
+function disperse_and_overrun_after_move() {
+ let cu = game.move.carry_british + game.move.carry_american + game.move.carry_french
+ let to = game.move.to
+ if (cu > 0) {
+ if (cu >= 4 && count_enemy_cu(to) === 1 && !has_enemy_general(to)) {
+ overrun(to)
+ }
+ if (game.active === P_BRITAIN && game.congress === to && !has_enemy_cu(to)) {
+ disperse_continental_congress()
+ }
+ }
+}
+
function resume_moving() {
game.move.from = game.move.to
@@ -2176,11 +2181,6 @@ states.intercept_roll = {
move_army(game.intercept)
- /* TODO: IMPOSSIBLE?
- if (has_enemy_general(game.move.to) && !has_enemy_cu(game.move.to))
- capture_enemy_general(game.move.to)
- */
-
if (count_friendly_generals(game.move.to) > 1)
goto_remove_general_after_intercept()
else
@@ -2197,6 +2197,9 @@ states.intercept_roll = {
function end_intercept() {
game.active = P_BRITAIN
delete game.intercept
+
+ disperse_and_overrun_after_move()
+
if (has_enemy_cu(game.move.to))
goto_start_battle()
else
@@ -2292,7 +2295,7 @@ function goto_remove_general_after_retreat_before_battle(where) {
game.state = "remove_general_after_retreat_before_battle"
game.where = where
} else {
- end_remove_general_after_retreat_before_battle()
+ end_retreat_before_battle()
}
}
@@ -2307,23 +2310,20 @@ states.remove_general_after_retreat_before_battle = {
move_general(g, BRITISH_REINFORCEMENTS)
else
move_general(g, AMERICAN_REINFORCEMENTS)
- end_remove_general_after_retreat_before_battle()
+ end_retreat_before_battle()
},
}
-function end_remove_general_after_retreat_before_battle() {
+function end_retreat_before_battle() {
game.active = P_BRITAIN
- let b_cu = count_british_cu(game.move.to)
- let a_cu = count_american_and_french_cu(game.move.to)
- if (a_cu === 0) {
- end_battle()
- next_strategy_card() // NOTE: skip pause at end of movement
- } else if (b_cu >= 4 && a_cu === 1) {
- overrun(game.move.to)
+
+ disperse_and_overrun_after_move()
+
+ if (has_enemy_cu(game.move.to)) {
+ goto_play_attacker_battle_card()
+ } else {
end_battle()
next_strategy_card() // NOTE: skip pause at end of movement
- } else {
- end_retreat_before_battle()
}
}
@@ -2517,6 +2517,8 @@ function apply_american_and_french_combat_losses(max) {
return n
}
+// TODO: battle_roll state with pause?
+
function resolve_battle() {
let a_log = []
let b_log = []
@@ -2720,11 +2722,6 @@ function gen_attacker_retreat() {
view.actions.surrender = 1
}
-function end_retreat_before_battle() {
- goto_play_attacker_battle_card()
-}
-
-
function goto_retreat_after_battle(victor) {
if (victor === P_BRITAIN) {
let who = find_american_or_french_general(game.move.to)