diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-07-03 23:48:45 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-08-21 00:28:20 +0200 |
commit | 0236343793137ecb887e78b5a145de49fa2c2e1f (patch) | |
tree | 2ed0e33415302038d9c4ed3fbd5d3c5a12ef30b2 | |
parent | d4bfa6838b1a4e7ace1766cb27a3233c881cadfc (diff) | |
download | washingtons-war-0236343793137ecb887e78b5a145de49fa2c2e1f.tar.gz |
fix rochambeau
-rw-r--r-- | rules.js | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -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 }, |