summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-17 00:47:44 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commitd0625abc0f411cff4db21056e16c753e1970e941 (patch)
tree2269dc93b1b78f05ef207988963797a752666368
parent82cd8e5add980fed74447893a9aa65911003c1df (diff)
downloadwilderness-war-d0625abc0f411cff4db21056e16c753e1970e941.tar.gz
French Regulars.
-rw-r--r--rules.js65
1 files changed, 64 insertions, 1 deletions
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;