diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index ef4eed07..cec70fc0 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -8,7 +8,20 @@ from abc import ABC, abstractmethod from dataclasses import dataclass, field from enum import Enum from functools import total_ordering -from typing import Any, Dict, Iterator, List, Optional, Set, TYPE_CHECKING, Type, Union +from typing import ( + Any, + Dict, + Iterator, + List, + Optional, + Set, + TYPE_CHECKING, + Type, + Union, + Sequence, + Iterable, + Tuple, +) from dcs.mapping import Point from dcs.ships import ( @@ -306,8 +319,8 @@ class ControlPoint(MissionTarget, ABC): # TODO: Should be Airbase specific. self.has_frontline = has_frontline self.connected_points: List[ControlPoint] = [] - self.convoy_routes: Dict[ControlPoint, List[Point]] = {} - self.shipping_lanes: Dict[ControlPoint, List[Point]] = {} + self.convoy_routes: Dict[ControlPoint, Tuple[Point, ...]] = {} + self.shipping_lanes: Dict[ControlPoint, Tuple[Point, ...]] = {} self.base: Base = Base() self.cptype = cptype # TODO: Should be Airbase specific. @@ -445,16 +458,18 @@ class ControlPoint(MissionTarget, ABC): def convoy_origin_for(self, destination: ControlPoint) -> Point: return self.convoy_route_to(destination)[0] - def convoy_route_to(self, destination: ControlPoint) -> List[Point]: + def convoy_route_to(self, destination: ControlPoint) -> Sequence[Point]: return self.convoy_routes[destination] - def create_convoy_route(self, to: ControlPoint, waypoints: List[Point]) -> None: + def create_convoy_route(self, to: ControlPoint, waypoints: Iterable[Point]) -> None: self.connected_points.append(to) self.stances[to.id] = CombatStance.DEFENSIVE - self.convoy_routes[to] = waypoints + self.convoy_routes[to] = tuple(waypoints) - def create_shipping_lane(self, to: ControlPoint, waypoints: List[Point]) -> None: - self.shipping_lanes[to] = waypoints + def create_shipping_lane( + self, to: ControlPoint, waypoints: Iterable[Point] + ) -> None: + self.shipping_lanes[to] = tuple(waypoints) @abstractmethod def runway_is_operational(self) -> bool: diff --git a/game/theater/frontline.py b/game/theater/frontline.py index 97ef6a9b..225980d1 100644 --- a/game/theater/frontline.py +++ b/game/theater/frontline.py @@ -52,7 +52,7 @@ class FrontLine(MissionTarget): self.blue_cp = blue_point self.red_cp = red_point try: - route = blue_point.convoy_route_to(red_point) + route = list(blue_point.convoy_route_to(red_point)) except KeyError: # Some campaigns are air only and the mission generator currently relies on # *some* "front line" being drawn between these two. In this case there will diff --git a/game/transfers.py b/game/transfers.py index b531fce4..4bdff773 100644 --- a/game/transfers.py +++ b/game/transfers.py @@ -4,7 +4,17 @@ import logging from collections import defaultdict from dataclasses import dataclass, field from functools import singledispatchmethod -from typing import Dict, Generic, Iterator, List, Optional, TYPE_CHECKING, Type, TypeVar +from typing import ( + Dict, + Generic, + Iterator, + List, + Optional, + TYPE_CHECKING, + Type, + TypeVar, + Sequence, +) from dcs.mapping import Point from dcs.unittype import FlyingType, VehicleType @@ -363,7 +373,7 @@ class CargoShip(MultiGroupTransport): yield from super().mission_types(for_player) @property - def route(self) -> List[Point]: + def route(self) -> Sequence[Point]: return self.origin.shipping_lanes[self.destination] def description(self) -> str: