diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index ff371923..7644d813 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -1510,6 +1510,11 @@ class Carrier(NavalControlPoint): return "cv" +class EssexCarrier(Carrier): + def can_operate(self, aircraft: AircraftType) -> bool: + return aircraft.lha_capable + + class Lha(NavalControlPoint): def __init__( self, name: str, at: Point, theater: ConflictTheater, starts_blue: bool diff --git a/game/theater/start_generator.py b/game/theater/start_generator.py index 73182062..cef91550 100644 --- a/game/theater/start_generator.py +++ b/game/theater/start_generator.py @@ -13,7 +13,12 @@ from game import Game from game.factions.faction import Faction from game.naming import namegen from game.scenery_group import SceneryGroup -from game.theater import PointWithHeading, PresetLocation, NavalControlPoint +from game.theater import ( + PointWithHeading, + PresetLocation, + NavalControlPoint, + EssexCarrier, +) from game.theater.theatergroundobject import ( BuildingGroundObject, IadsBuildingGroundObject, @@ -322,6 +327,7 @@ class CarrierGroundObjectGenerator(GenericCarrierGroundObjectGenerator): logging.error(f"{self.faction_name} has no access to AircraftCarrier") return False + self.transform_to_essex_if_needed(unit_group) self.generate_ground_object_from_group( unit_group, PresetLocation( @@ -334,6 +340,21 @@ class CarrierGroundObjectGenerator(GenericCarrierGroundObjectGenerator): self.apply_carrier_config() return True + def transform_to_essex_if_needed(self, unit_group: ForceGroup) -> None: + classes = [u.unit_class for u in unit_group.units] + if any([c for c in classes if c == UnitClass.HELICOPTER_CARRIER]) and not any( + [c for c in classes if c == UnitClass.AIRCRAFT_CARRIER] + ): + self.game.theater.controlpoints.remove(self.control_point) + self.control_point = EssexCarrier( + self.control_point.name, + self.control_point.position, + self.game.theater, + self.control_point.starts_blue, + ) + self.control_point.finish_init(self.game) + self.game.theater.controlpoints.append(self.control_point) + class LhaGroundObjectGenerator(GenericCarrierGroundObjectGenerator): def generate(self) -> bool: diff --git a/resources/groups/WW2Essex.yaml b/resources/groups/WW2Essex.yaml index c0b5a064..22624be2 100644 --- a/resources/groups/WW2Essex.yaml +++ b/resources/groups/WW2Essex.yaml @@ -1,6 +1,6 @@ name: WW2Essex tasks: - - HelicopterCarrier + - AircraftCarrier units: - USS Bennington (CV-20) layouts: diff --git a/resources/layouts/naval/WW2-Essex_Carrier.yaml b/resources/layouts/naval/WW2-Essex_Carrier.yaml index 3a58d3d5..9b4c0040 100644 --- a/resources/layouts/naval/WW2-Essex_Carrier.yaml +++ b/resources/layouts/naval/WW2-Essex_Carrier.yaml @@ -1,6 +1,6 @@ name: WW2 Essex Carrier tasks: - - HelicopterCarrier + - AircraftCarrier groups: - Carrier: # the word "Carrier" or "LHA" needs to be present in the group-name - name: WW2 Carrier Group 0