Describe non-airport "runways" better.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/3290.
This commit is contained in:
Dan Albert
2023-12-21 16:03:23 -08:00
parent ef69275f34
commit dcf23c655d
3 changed files with 37 additions and 15 deletions

View File

@@ -271,15 +271,15 @@ class RunwayStatus:
def needs_repair(self) -> bool:
return self.damaged and self.repair_turns_remaining is None
def __str__(self) -> str:
def describe(self) -> str:
if not self.damaged:
return "Runway operational"
return "operational"
turns_remaining = self.repair_turns_remaining
if turns_remaining is None:
return "Runway damaged"
return "damaged"
return f"Runway repairing, {turns_remaining} turns remaining"
return f"repairing, {turns_remaining} turns remaining"
@total_ordering
@@ -915,6 +915,10 @@ class ControlPoint(MissionTarget, SidcDescribable, ABC):
def runway_status(self) -> RunwayStatus:
...
@abstractmethod
def describe_runway_status(self) -> str | None:
"""Description of the runway status suitable for UI use."""
@property
def runway_can_be_repaired(self) -> bool:
return self.runway_status.needs_repair
@@ -1157,6 +1161,9 @@ class Airfield(ControlPoint):
def runway_status(self) -> RunwayStatus:
return self._runway_status
def describe_runway_status(self) -> str:
return f"Runway {self.runway_status.describe()}"
def damage_runway(self) -> None:
self.runway_status.damage()
@@ -1275,6 +1282,9 @@ class NavalControlPoint(ControlPoint, ABC):
def runway_status(self) -> RunwayStatus:
return RunwayStatus(damaged=not self.runway_is_operational())
def describe_runway_status(self) -> str:
return f"Flight deck {self.runway_status.describe()}"
@property
def runway_can_be_repaired(self) -> bool:
return False
@@ -1428,6 +1438,9 @@ class OffMapSpawn(ControlPoint):
def runway_status(self) -> RunwayStatus:
return RunwayStatus()
def describe_runway_status(self) -> str:
return f"Off-map airport {self.runway_status.describe()}"
@property
def can_deploy_ground_units(self) -> bool:
return False
@@ -1474,6 +1487,11 @@ class Fob(ControlPoint):
def runway_status(self) -> RunwayStatus:
return RunwayStatus()
def describe_runway_status(self) -> str | None:
if not self.has_helipads:
return None
return f"FARP {self.runway_status.describe()}"
def mission_types(self, for_player: bool) -> Iterator[FlightType]:
from game.ato import FlightType