Fix for incorrect unit_count in layout

- Raise LayoutException if the unit_count in the layout is greater than the available units
- Fix Flak Layout to solve #2043
This commit is contained in:
RndName
2022-03-16 22:10:19 +01:00
parent c238e50e41
commit 46694e458d
2 changed files with 4 additions and 0 deletions

View File

@@ -129,6 +129,10 @@ class TgoLayoutGroup:
self, go: TheaterGroundObject, unit_type: Type[DcsUnitType], amount: int
) -> list[TheaterUnit]:
"""Generate units of the given unit type and amount for the TgoLayoutGroup"""
if amount > len(self.layout_units):
raise LayoutException(
f"{self.name} has incorrect unit_count for {unit_type.id}"
)
return [
TheaterUnit.from_template(i, unit_type, self.layout_units[i], go)
for i in range(amount)