Essex as AircraftCarrier hack (#541)

This commit is contained in:
Drexyl 2025-07-20 04:21:33 +10:00 committed by GitHub
parent f1eb514295
commit c15b4ac83f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -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:

View File

@ -1,6 +1,6 @@
name: WW2Essex
tasks:
- HelicopterCarrier
- AircraftCarrier
units:
- USS Bennington (CV-20)
layouts:

View File

@ -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