diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-06-25 12:23:49 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 11:54:52 +0100 |
commit | 2c2a7d926ccaa7a208d923d16a7da792dd977e56 (patch) | |
tree | 450c74b8805152279da2941d2001b01916cde3b2 /rules.js | |
parent | bcc9c38cfe3dd56e9a190610dc96be50b7eb5aaa (diff) | |
download | wilderness-war-2c2a7d926ccaa7a208d923d16a7da792dd977e56.tar.gz |
Check supply lines for "can play" checks on events that restore units.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 41 |
1 files changed, 15 insertions, 26 deletions
@@ -7745,20 +7745,18 @@ function count_unbesieged_northern_provincials() { return n } -function count_reduced_unbesieged_southern_provincials() { - let n = 0 +function can_restore_southern_provincial_regiments() { for (let p = first_southern_provincial; p <= last_southern_provincial; ++p) - if (is_piece_on_map(p) && is_piece_unbesieged(p) && is_unit_reduced(p)) - ++n - return n + if (can_restore_unit(p)) + return true + return false } -function count_reduced_unbesieged_northern_provincials() { - let n = 0 +function can_restore_northern_provincial_regiments() { for (let p = first_northern_provincial; p <= last_northern_provincial; ++p) - if (is_piece_on_map(p) && is_piece_unbesieged(p) && is_unit_reduced(p)) - ++n - return n + if (can_restore_unit(p)) + return true + return false } events.stingy_provincial_assembly = { @@ -7930,14 +7928,6 @@ function can_raise_northern_provincial_regiments() { return num < max } -function can_restore_southern_provincial_regiments() { - return count_reduced_unbesieged_southern_provincials() > 0 -} - -function can_restore_northern_provincial_regiments() { - return count_reduced_unbesieged_northern_provincials() > 0 -} - events.raise_provincial_regiments = { can_play() { if (game.pa === RELUCTANT) @@ -8130,11 +8120,10 @@ function is_colonial_recruit(p) { events.colonial_recruits = { can_play() { - let n = 0 for (let p = first_friendly_unit; p <= last_friendly_unit; ++p) - if (is_colonial_recruit(p) && is_piece_unbesieged(p) && is_unit_reduced(p)) - ++n - return n > 0 + if (can_restore_unit(p)) + return true + return false }, play() { let roll = roll_die() @@ -8173,10 +8162,10 @@ states.colonial_recruits = { }, } -function has_unbesieged_reduced_regular_or_light_infantry_units() { +function can_restore_regular_or_light_infantry_units() { for (let p = first_friendly_unit; p <= last_friendly_unit; ++p) if (is_regular(p) || is_light_infantry(p)) - if (is_piece_unbesieged(p) && is_unit_reduced(p)) + if (can_restore_unit(p)) return true return false } @@ -8189,7 +8178,7 @@ events.troop_transports_and_local_enlistments = { if (is_british_controlled_space(QUEBEC)) return false } - return has_unbesieged_reduced_regular_or_light_infantry_units() + return can_restore_regular_or_light_infantry_units() }, play() { game.state = 'restore_regular_or_light_infantry_units' @@ -8210,7 +8199,7 @@ events.victories_in_germany_release_troops_and_finances_for_new_world = { if (is_british_controlled_space(QUEBEC)) return false } - return has_unbesieged_reduced_regular_or_light_infantry_units() + return can_restore_regular_or_light_infantry_units() }, play() { game.state = 'restore_regular_or_light_infantry_units' |