diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index 7631b3eb..d43e8a2f 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -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]: diff --git a/gen/armor.py b/gen/armor.py index bae64166..ff8e8180 100644 --- a/gen/armor.py +++ b/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( diff --git a/gen/ground_forces/ai_ground_planner.py b/gen/ground_forces/ai_ground_planner.py index 045c4b39..63d5b1ab 100644 --- a/gen/ground_forces/ai_ground_planner.py +++ b/gen/ground_forces/ai_ground_planner.py @@ -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)) diff --git a/gen/groundobjectsgen.py b/gen/groundobjectsgen.py index f3cf94f3..2350f160 100644 --- a/gen/groundobjectsgen.py +++ b/gen/groundobjectsgen.py @@ -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 diff --git a/mypy.ini b/mypy.ini index f4888eca..3549d3b7 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,6 +1,6 @@ [mypy] # TODO: Cleanup so we can enable the checks commented out here. -# check_untyped_defs = True +check_untyped_defs = True # disallow_any_decorated = True # disallow_any_expr = True # disallow_any_generics = True