mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Type check the contents of untyped functions.
By default mypy doesn't type check the code within an untyped function. This enables that and fixes typing errors to accomodate it. This did uncover a very old bug: https://github.com/dcs-liberation/dcs_liberation/issues/1417
This commit is contained in:
parent
299ed88f09
commit
fc32b98341
@ -323,7 +323,7 @@ class ControlPoint(MissionTarget, ABC):
|
||||
self.target_position: Optional[Point] = None
|
||||
|
||||
def __repr__(self):
|
||||
return f"<{__class__}: {self.name}>"
|
||||
return f"<{self.__class__}: {self.name}>"
|
||||
|
||||
@property
|
||||
def ground_objects(self) -> List[TheaterGroundObject]:
|
||||
|
||||
10
gen/armor.py
10
gen/armor.py
@ -136,6 +136,7 @@ class GroundConflictGenerator:
|
||||
position = Conflict.frontline_position(
|
||||
self.conflict.front_line, self.game.theater
|
||||
)
|
||||
|
||||
frontline_vector = Conflict.frontline_vector(
|
||||
self.conflict.front_line, self.game.theater
|
||||
)
|
||||
@ -150,6 +151,13 @@ class GroundConflictGenerator:
|
||||
self.enemy_planned_combat_groups, frontline_vector, False
|
||||
)
|
||||
|
||||
# TODO: Differentiate AirConflict and GroundConflict classes.
|
||||
if self.conflict.heading is None:
|
||||
raise RuntimeError(
|
||||
"Cannot generate ground units for non-ground conflict. Ground unit "
|
||||
"conflicts cannot have the heading `None`."
|
||||
)
|
||||
|
||||
# Plan combat actions for groups
|
||||
self.plan_action_for_groups(
|
||||
self.player_stance,
|
||||
@ -174,7 +182,7 @@ class GroundConflictGenerator:
|
||||
code = 1688 - len(self.jtacs)
|
||||
|
||||
utype = self.game.player_faction.jtac_unit
|
||||
if self.game.player_faction.jtac_unit is None:
|
||||
if utype is None:
|
||||
utype = AircraftType.named("MQ-9 Reaper")
|
||||
|
||||
jtac = self.mission.flight_group(
|
||||
|
||||
@ -52,7 +52,6 @@ class CombatGroup:
|
||||
self.unit_type = unit_type
|
||||
self.size = size
|
||||
self.role = role
|
||||
self.assigned_enemy_cp = None
|
||||
self.start_position = None
|
||||
|
||||
def __str__(self):
|
||||
@ -89,11 +88,9 @@ class GroundPlanner:
|
||||
|
||||
remaining_available_frontline_units = ground_unit_limit
|
||||
|
||||
if hasattr(self.cp, "stance"):
|
||||
group_size_choice = GROUP_SIZES_BY_COMBAT_STANCE[self.cp.stance]
|
||||
else:
|
||||
self.cp.stance = CombatStance.DEFENSIVE
|
||||
group_size_choice = GROUP_SIZES_BY_COMBAT_STANCE[CombatStance.DEFENSIVE]
|
||||
# TODO: Fix to handle the per-front stances.
|
||||
# https://github.com/dcs-liberation/dcs_liberation/issues/1417
|
||||
group_size_choice = GROUP_SIZES_BY_COMBAT_STANCE[CombatStance.DEFENSIVE]
|
||||
|
||||
# Create combat groups and assign them randomly to each enemy CP
|
||||
for unit_type in self.cp.base.armor:
|
||||
@ -152,20 +149,9 @@ class GroundPlanner:
|
||||
if len(self.connected_enemy_cp) > 0:
|
||||
enemy_cp = random.choice(self.connected_enemy_cp).id
|
||||
self.units_per_cp[enemy_cp].append(group)
|
||||
group.assigned_enemy_cp = enemy_cp
|
||||
else:
|
||||
self.reserve.append(group)
|
||||
group.assigned_enemy_cp = "__reserve__"
|
||||
collection.append(group)
|
||||
|
||||
if remaining_available_frontline_units == 0:
|
||||
break
|
||||
|
||||
print("------------------")
|
||||
print("Ground Planner : ")
|
||||
print(self.cp.name)
|
||||
print("------------------")
|
||||
for unit_type in self.units_per_cp.keys():
|
||||
print("For : #" + str(unit_type))
|
||||
for group in self.units_per_cp[unit_type]:
|
||||
print(str(group))
|
||||
|
||||
@ -637,6 +637,7 @@ class GroundObjectsGenerator:
|
||||
).generate()
|
||||
|
||||
for ground_object in cp.ground_objects:
|
||||
generator: GenericGroundObjectGenerator
|
||||
if isinstance(ground_object, FactoryGroundObject):
|
||||
generator = FactoryGenerator(
|
||||
ground_object, country, self.game, self.m, self.unit_map
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user