summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/rules.js b/rules.js
index 7d876d4..1909669 100644
--- a/rules.js
+++ b/rules.js
@@ -112,6 +112,7 @@ const F_LANDING_PARTY = 64
const general_count = data.generals.length
const space_count = 66
const all_spaces = new Array(space_count).fill(0).map((_,i)=>i)
+const all_port_spaces = all_spaces.filter(s => is_port(s))
const ENEMY = { [P_AMERICA]: P_BRITAIN, [P_BRITAIN]: P_AMERICA }
@@ -2751,9 +2752,13 @@ states.retreat_after_battle = {
retreat_british_army(game.move.to, to)
else
retreat_american_army(game.move.to, to)
+
if (has_enemy_general(to))
- // TODO: what if moving without CU?
capture_enemy_general(to)
+
+ if (game.active === game.combat.attacker)
+ game.move.to = to
+
if (count_friendly_generals(to) > 1)
goto_remove_general_after_retreat(to)
else
@@ -3275,6 +3280,7 @@ states.declaration_of_independence = {
gen_place_american_pc_in_colony(game.colonies)
},
space(space) {
+ push_undo()
let colony = SPACES[space].colony
set_delete(game.colonies, colony)
place_american_pc(space)
@@ -3282,6 +3288,7 @@ states.declaration_of_independence = {
end_declaration_of_independence()
},
pass() {
+ push_undo()
end_declaration_of_independence()
},
}
@@ -3518,10 +3525,9 @@ states.place_french_navy_trigger = {
}
function can_place_rochambeau() {
- for (let space in SPACES)
- if (is_port(space))
- if (!has_british_cu(space) && !has_british_pc(space))
- return true
+ for (let space of all_port_spaces)
+ if (!has_british_cu(space) && !has_british_pc(space))
+ return true
return false
}
@@ -3530,7 +3536,7 @@ function goto_place_rochambeau() {
game.state = "place_rochambeau"
} else {
move_general(ROCHAMBEAU, AMERICAN_REINFORCEMENTS)
- move_cu(FRENCH, FRENCH_REINFORCEMENTS, AMERICAN_REINFORCEMENTS, 5)
+ move_french_cu(FRENCH_REINFORCEMENTS, AMERICAN_REINFORCEMENTS, 5)
end_place_rochambeau()
}
}
@@ -3538,27 +3544,29 @@ function goto_place_rochambeau() {
states.place_rochambeau = {
prompt() {
view.prompt = "Place Rochambeau in a port."
+ view.move = { who: ROCHAMBEAU, from: FRENCH_REINFORCEMENTS, to: FRENCH_REINFORCEMENTS, carry_american: 0, carry_french: 5 }
let can_place = false
- for (let space in SPACES) {
- if (is_port(space)) {
- if (!has_british_cu(space) && !has_british_pc(space)) {
- gen_action_space(space)
- can_place = true
- }
+ for (let space of all_port_spaces) {
+ if (!has_british_cu(space) && !has_british_pc(space)) {
+ gen_action_space(space)
+ can_place = true
}
}
},
space(space) {
+ // TODO: remove_general!
push_undo()
logp("placed Rochambeau .")
move_general(ROCHAMBEAU, space)
- move_cu(FRENCH, FRENCH_REINFORCEMENTS, space, 5)
+ move_french_cu(FRENCH_REINFORCEMENTS, space, 5)
game.state = "end_place_rochambeau"
},
}
states.end_place_rochambeau = {
prompt() {
+ let where = location_of_general(ROCHAMBEAU)
+ view.move = { who: ROCHAMBEAU, from: where, to: where, carry_american: 0, carry_french: 5 }
view.prompt = "Done."
view.actions.next = 1
},