From 903e1002013938c5111726b9896b0f8da7666b74 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 15 Apr 2023 11:55:54 +0200 Subject: 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. --- rules.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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() -- cgit v1.2.3