From 16e1d1cd86c2d87ce59091756eed50db62d3f5c3 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 20 Apr 2024 14:57:56 +0200 Subject: Disband lords that end up without troops in Welsh Rebellion. --- rules.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/rules.ts b/rules.ts index 00203a0..f4a25af 100644 --- a/rules.ts +++ b/rules.ts @@ -10538,34 +10538,39 @@ states.welsh_rebellion_remove_troops = { }, burgundians(lord) { add_lord_forces(lord, BURGUNDIANS, -1) - if (--game.count === 0 || !lord_has_unrouted_units(lord)) - game.who = NOBODY + resume_welsh_rebellion_remove_troops(lord) }, mercenaries(lord) { add_lord_forces(lord, MERCENARIES, -1) - if (--game.count === 0 || !lord_has_unrouted_units(lord)) - game.who = NOBODY + resume_welsh_rebellion_remove_troops(lord) }, longbowmen(lord) { add_lord_forces(lord, LONGBOWMEN, -1) - if (--game.count === 0 || !lord_has_unrouted_units(lord)) - game.who = NOBODY + resume_welsh_rebellion_remove_troops(lord) }, men_at_arms(lord) { add_lord_forces(lord, MEN_AT_ARMS, -1) - if (--game.count === 0 || !lord_has_unrouted_units(lord)) - game.who = NOBODY + resume_welsh_rebellion_remove_troops(lord) }, militia(lord) { add_lord_forces(lord, MILITIA, -1) - if (--game.count === 0 || !lord_has_unrouted_units(lord)) - game.who = NOBODY + resume_welsh_rebellion_remove_troops(lord) }, done() { end_welsh_rebellion_remove_troops() }, } +function resume_welsh_rebellion_remove_troops(lord: Lord) { + if (!lord_has_unrouted_troops(lord)) { + disband_lord(lord) + game.who = NOBODY + } + if (--game.count === 0) { + game.who = NOBODY + } +} + function end_welsh_rebellion_remove_troops() { for (let lord of all_york_lords) { if (is_lord_on_map(lord) && is_lord_in_wales(lord) && !lord_has_unrouted_units(lord)) -- cgit v1.2.3