From 2c2a7d926ccaa7a208d923d16a7da792dd977e56 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 25 Jun 2022 12:23:49 +0200 Subject: Check supply lines for "can play" checks on events that restore units. --- rules.js | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/rules.js b/rules.js index 9b13ffd..ea9d0ab 100644 --- a/rules.js +++ b/rules.js @@ -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' -- cgit v1.2.3