summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-01-17 02:06:23 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commitcafe38b4b89e028246f5283c7ff05656d2cce3e6 (patch)
treea555344c2709aca3cd9e81e055aa5518e4766248
parent9c4a6c287fe1369a5bfe2d82aea7340793a9c943 (diff)
downloadwilderness-war-cafe38b4b89e028246f5283c7ff05656d2cce3e6.tar.gz
Acadians Expelled.
-rw-r--r--rules.js60
1 files changed, 59 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index 2540a9d..494fb79 100644
--- a/rules.js
+++ b/rules.js
@@ -5239,7 +5239,65 @@ states.royal_americans = {
},
}
-events.acadians_expelled = TODO;
+function find_unused_coureurs_unit() {
+ for (let p = first_french_unit; p <= last_french_unit; ++p)
+ if (is_coureurs_unit(p) && is_piece_unused(p))
+ return p;
+ return 0;
+}
+
+events.acadians_expelled = {
+ play() {
+ // TODO: acadians_expelled_halifax state for manual placing?
+ for (let i = 0; i < 2; ++i) {
+ let p = find_unused_3_4_regular_unit();
+ log(`${piece_name(p)} placed at Halifax.`);
+ move_piece_to(p, HALIFAX);
+ }
+
+ // TODO: restore_acadians_expelled state for manual restoring?
+ for (let p = first_french_unit; p <= last_french_unit; ++p) {
+ if (is_militia_unit(p) || is_coureurs_unit(p)) {
+ if (is_unit_reduced(p) && is_piece_unbesieged(p)) {
+ log(`${piece_name(p)} restored.`);
+ set_unit_reduced(p, 0);
+ }
+ }
+ }
+
+ set_active(enemy());
+ game.state = 'acadians_expelled';
+ game.count = 1;
+ },
+}
+
+states.acadians_expelled = {
+ prompt() {
+ view.prompt = "Place a Coureurs unit at Québec or Louisbourg.";
+ if (game.count > 0) {
+ if (has_unbesieged_friendly_fortress(QUEBEC))
+ gen_action_space(QUEBEC);
+ if (has_unbesieged_friendly_fortress(LOUISBOURG))
+ gen_action_space(LOUISBOURG);
+ } else {
+ gen_action_next();
+ }
+ },
+ space(s) {
+ push_undo();
+ let p = find_unused_coureurs_unit();
+ if (p) {
+ log(`${piece_name(p)} placed at ${space_name(s)}.`);
+ move_piece_to(p, s);
+ }
+ game.count = 0;
+ },
+ next() {
+ set_active(enemy());
+ end_action_phase();
+ },
+}
+
events.william_pitt = TODO;
events.diplomatic_revolution = TODO; /* {