summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-04-15 11:55:54 +0200
committerTor Andersson <tor@ccxvii.net>2023-04-15 12:09:01 +0200
commit903e1002013938c5111726b9896b0f8da7666b74 (patch)
tree3387eb5e1d5e64fd39ba53c06c074a9e89a7ad07
parent243c18f8eb1309e03834f49508451c882c703792 (diff)
downloadwilderness-war-903e1002013938c5111726b9896b0f8da7666b74.tar.gz
Don't activate forces in Halifax/Louisbourg if they can't do anything.
Trying to move from Halifax without a 3 card, or siege with a subordinate in Louisbourg, etc.
-rw-r--r--rules.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index edccf06..0e3c181 100644
--- a/rules.js
+++ b/rules.js
@@ -2412,12 +2412,29 @@ states.activate_individually = {
},
}
+function can_activate_force(who) {
+ let where = game.location[who]
+ // If at Halifax or Louisbourg ...
+ if (where === HALIFAX || where === LOUISBOURG) {
+ // must be able to Naval move
+ if (game.activation_value === 3)
+ return true
+ // or Siege/Assault
+ if (can_siege_or_assault_if_activated(who, where))
+ return true
+ // otherwise it's a do-nothing action
+ return false
+ }
+ return true
+}
+
states.activate_force = {
prompt() {
view.prompt = "Activate a Force."
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p)
if (is_piece_on_map(p) && leader_initiative(p) <= game.activation_value)
- gen_action_piece(p)
+ if (can_activate_force(p))
+ gen_action_piece(p)
},
piece(p) {
push_undo()
@@ -5782,6 +5799,18 @@ function resume_retreat_lone_leader(from) {
const SIEGE_TABLE = [ 0, 0, 0, 1, 1, 1, 2, 2 ]
+function can_siege_or_assault_if_activated(leader, where) {
+ if (has_besieged_enemy_fortifications(where)) {
+ let commanding = find_friendly_commanding_leader_in_space(where)
+ if (commanding > 0) {
+ let cmd_rank = leader_command(commanding)
+ let ldr_rank = leader_command(leader)
+ if (ldr_rank === cmd_rank && has_friendly_supplied_drilled_troops(where))
+ return true
+ }
+ }
+}
+
function can_moving_force_siege_or_assault() {
let leader = moving_piece()
let where = moving_piece_space()