diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-06-26 11:55:13 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-06-26 11:55:13 +0200 |
commit | 7d1d8653dad62f6409e8de1db7bd0a223fdc7f94 (patch) | |
tree | 28763996210e4e7392975ab6358e1e3387fc82c8 | |
parent | c5d377e8e1c907149327ba45c22e5e52b8cecf1f (diff) | |
download | plantagenet-7d1d8653dad62f6409e8de1db7bd0a223fdc7f94.tar.gz |
fix sail
-rw-r--r-- | rules.js | 10 | ||||
-rw-r--r-- | rules.ts | 11 |
2 files changed, 17 insertions, 4 deletions
@@ -996,6 +996,12 @@ function count_lord_all_forces(lord) { get_lord_forces(lord, MILITIA) + get_lord_forces(lord, LONGBOWMEN)); } +function count_group_all_forces(list) { + let n = 0; + for (let lord of list) + n += count_lord_all_forces(lord); + return n; +} function lord_has_unrouted_units(lord) { for (let x of all_force_types) if (get_lord_forces(lord, x) > 0) @@ -3232,7 +3238,7 @@ states.command = { view.actions.sail = 1; can_move = true; } - if (can_move && can_pick_up_lords(game.command)) { + if (can_pick_up_lords(game.command)) { view.group = game.group; for_each_friendly_lord_in_locale(here, other => { if (can_pick_up_other(game.command, other)) @@ -3553,7 +3559,7 @@ states.blockade_supply = { // === 4.6.1 ACTION: SAIL === function has_enough_available_ships_for_army() { let ships = count_group_ships(game.group, true); - let army = count_lord_all_forces(game.command); + let army = count_group_all_forces(game.group); let needed_ships = army / 6; return needed_ships <= ships; } @@ -1384,6 +1384,13 @@ function count_lord_all_forces(lord: Lord) { ) } +function count_group_all_forces(list: Lord[]) { + let n = 0 + for (let lord of list) + n += count_lord_all_forces(lord) + return n +} + function lord_has_unrouted_units(lord: Lord) { for (let x of all_force_types) if (get_lord_forces(lord, x) > 0) @@ -3943,7 +3950,7 @@ states.command = { can_move = true } - if (can_move && can_pick_up_lords(game.command)) { + if (can_pick_up_lords(game.command)) { view.group = game.group for_each_friendly_lord_in_locale(here, other => { if (can_pick_up_other(game.command, other)) @@ -4318,7 +4325,7 @@ states.blockade_supply = { function has_enough_available_ships_for_army() { let ships = count_group_ships(game.group, true) - let army = count_lord_all_forces(game.command) + let army = count_group_all_forces(game.group) let needed_ships = army / 6 return needed_ships <= ships } |