From ce7bd9def7688ea1de985802dbc5eed29b2a0743 Mon Sep 17 00:00:00 2001 From: Raffson Date: Sat, 1 Apr 2023 17:39:42 +0200 Subject: [PATCH] Fix edge-case bug in layout's group size --- changelog.md | 1 + game/campaignloader/campaign.py | 2 +- game/layout/layout.py | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 0c63846a..ff71e946 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ ## Fixes * **[Plugins]** Fix bug where changes to plugin options doesn't do anything. * **[Campaign Management]** Fix bug in procurement when no squadrons are present. +* **[Layouts]** Fix edge-case bug layout's group size. # Retribution v1.1.0 diff --git a/game/campaignloader/campaign.py b/game/campaignloader/campaign.py index b8531482..379594b8 100644 --- a/game/campaignloader/campaign.py +++ b/game/campaignloader/campaign.py @@ -141,7 +141,7 @@ class Campaign: def load_ground_forces_config(self) -> TgoConfig: ground_forces = self.data.get("ground_forces", {}) if not ground_forces: - logging.warning(f"Campaign {self.name} does not define any squadrons") + logging.warning(f"Campaign {self.name} does not define any ground_forces") return TgoConfig({}) return TgoConfig.from_campaign_data(ground_forces) diff --git a/game/layout/layout.py b/game/layout/layout.py index 5fc6eecc..6c169005 100644 --- a/game/layout/layout.py +++ b/game/layout/layout.py @@ -137,11 +137,14 @@ class TgoLayoutUnitGroup: @property def group_size(self) -> int: - """The amount of units to be generated. If unit_count is defined in the layout this will be randomized accordingly. Otherwise this will be the maximum size.""" + """ + The amount of units to be generated. If unit_count is defined in the layout this will be + randomized accordingly. Otherwise this will be the maximum size. + """ if self.unit_count: if len(self.unit_count) == 1: return self.unit_count[0] - return random.choice(range(min(self.unit_count), max(self.unit_count))) + return random.choice(range(min(self.unit_count), max(self.unit_count) + 1)) return self.max_size @property