From d0625abc0f411cff4db21056e16c753e1970e941 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 17 Jan 2022 00:47:44 +0100 Subject: French Regulars. --- rules.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/rules.js b/rules.js index ea9a77d..d8cedb0 100644 --- a/rules.js +++ b/rules.js @@ -361,6 +361,9 @@ define_indian_settlement("Pays d'en Haut", "Potawatomi"); define_indian_settlement("Pays d'en Haut", "Huron"); const JOHNSON = find_leader("Johnson"); +const MONTCALM = find_leader("Montcalm"); +const LEVIS = find_leader("Lévis"); +const BOUGAINVILLE = find_leader("Bougainville"); const HALIFAX = find_space("Halifax"); const LOUISBOURG = find_space("Louisbourg"); @@ -4943,7 +4946,67 @@ states.light_infantry = { }, } -events.french_regulars = TODO; +function find_unused_french_regular() { + for (let p = first_french_unit; p <= last_french_unit; ++p) + if (is_regulars_unit(p) && is_piece_unused(p)) + return p; + return 0; +} + +events.french_regulars = { + can_play() { + if (game.events.french_regulars) + return false; + if (game.events.quiberon) + return false; + if (!has_british_units(QUEBEC)) + return true; + if (!has_british_units(LOUISBOURG)) + return true; + return false; + }, + play() { + game.state = 'french_regulars'; + game.count = 2; + } +} + +states.french_regulars = { + prompt() { + view.prompt = `Place 2 regular units at either Québec or Louisbourg.`; + if (game.count > 0) { + if (!has_british_units(QUEBEC)) + gen_action_space(QUEBEC); + if (!has_british_units(LOUISBOURG)) + gen_action_space(LOUISBOURG); + } else { + gen_action_next(); + } + }, + space(s) { + let p; + push_undo(); + for (p of [ MONTCALM, LEVIS, BOUGAINVILLE ]) { + if (is_piece_unused(p)) { + log(`${piece_name(p)} placed in ${space_name(s)}.`); + move_piece_to(p, s); + } + } + for (let i = 0; i < game.count; ++i) { + p = find_unused_french_regular(); + if (p) { + log(`${piece_name(p)} placed in ${space_name(s)}.`); + move_piece_to(p, s); + } + } + game.count = 0; + }, + next() { + game.events.french_regulars = 1; + end_action_phase(); + }, +} + events.british_regulars = TODO; events.highlanders = TODO; events.royal_americans = TODO; -- cgit v1.2.3