mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove useless wrappers from db.py.
This commit is contained in:
parent
758feab413
commit
36f74ae0a9
10
game/db.py
10
game/db.py
@ -21,7 +21,7 @@ from dcs.ships import (
|
|||||||
Stennis,
|
Stennis,
|
||||||
ship_map,
|
ship_map,
|
||||||
)
|
)
|
||||||
from dcs.unittype import ShipType, UnitType, VehicleType
|
from dcs.unittype import ShipType, UnitType
|
||||||
from dcs.vehicles import (
|
from dcs.vehicles import (
|
||||||
vehicle_map,
|
vehicle_map,
|
||||||
)
|
)
|
||||||
@ -161,14 +161,6 @@ def unit_type_from_name(name: str) -> Optional[Type[UnitType]]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def vehicle_type_from_name(name: str) -> Type[VehicleType]:
|
|
||||||
return vehicle_map[name]
|
|
||||||
|
|
||||||
|
|
||||||
def ship_type_from_name(name: str) -> Type[ShipType]:
|
|
||||||
return ship_map[name]
|
|
||||||
|
|
||||||
|
|
||||||
def country_id_from_name(name: str) -> int:
|
def country_id_from_name(name: str) -> int:
|
||||||
for k, v in country_dict.items():
|
for k, v in country_dict.items():
|
||||||
if v.name == name:
|
if v.name == name:
|
||||||
|
|||||||
@ -11,41 +11,44 @@ import logging
|
|||||||
import random
|
import random
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import (
|
from typing import (
|
||||||
|
Any,
|
||||||
Dict,
|
Dict,
|
||||||
|
Generic,
|
||||||
Iterator,
|
Iterator,
|
||||||
|
List,
|
||||||
Optional,
|
Optional,
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
Type,
|
Type,
|
||||||
List,
|
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Any,
|
|
||||||
Generic,
|
|
||||||
Union,
|
Union,
|
||||||
)
|
)
|
||||||
|
|
||||||
from dcs import Mission, Point, unitgroup
|
from dcs import Mission, Point, unitgroup
|
||||||
from dcs.action import SceneryDestructionZone, DoScript
|
from dcs.action import DoScript, SceneryDestructionZone
|
||||||
from dcs.condition import MapObjectIsDead
|
from dcs.condition import MapObjectIsDead
|
||||||
from dcs.country import Country
|
from dcs.country import Country
|
||||||
from dcs.point import StaticPoint
|
from dcs.point import StaticPoint
|
||||||
|
from dcs.ships import ship_map
|
||||||
from dcs.statics import Fortification, fortification_map, warehouse_map
|
from dcs.statics import Fortification, fortification_map, warehouse_map
|
||||||
from dcs.task import (
|
from dcs.task import (
|
||||||
ActivateBeaconCommand,
|
ActivateBeaconCommand,
|
||||||
ActivateICLSCommand,
|
ActivateICLSCommand,
|
||||||
EPLRS,
|
EPLRS,
|
||||||
OptAlarmState,
|
|
||||||
FireAtPoint,
|
FireAtPoint,
|
||||||
|
OptAlarmState,
|
||||||
)
|
)
|
||||||
from dcs.translation import String
|
from dcs.translation import String
|
||||||
from dcs.triggers import TriggerStart, TriggerZone, Event, TriggerOnce
|
from dcs.triggers import Event, TriggerOnce, TriggerStart, TriggerZone
|
||||||
from dcs.unit import Ship, Unit, Vehicle, InvisibleFARP
|
from dcs.unit import InvisibleFARP, Ship, Unit, Vehicle
|
||||||
from dcs.unitgroup import ShipGroup, StaticGroup, VehicleGroup
|
from dcs.unitgroup import ShipGroup, StaticGroup, VehicleGroup
|
||||||
from dcs.unittype import StaticType, ShipType, VehicleType
|
from dcs.unittype import ShipType, StaticType, VehicleType
|
||||||
from dcs.vehicles import vehicle_map
|
from dcs.vehicles import vehicle_map
|
||||||
|
|
||||||
from game import db
|
from game import db
|
||||||
from game.data.building_data import FORTIFICATION_UNITS, FORTIFICATION_UNITS_ID
|
from game.data.building_data import FORTIFICATION_UNITS, FORTIFICATION_UNITS_ID
|
||||||
from game.db import unit_type_from_name, ship_type_from_name, vehicle_type_from_name
|
from game.db import unit_type_from_name
|
||||||
|
from game.radio.radios import RadioFrequency, RadioRegistry
|
||||||
|
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
||||||
from game.theater import ControlPoint, TheaterGroundObject
|
from game.theater import ControlPoint, TheaterGroundObject
|
||||||
from game.theater.theatergroundobject import (
|
from game.theater.theatergroundobject import (
|
||||||
BuildingGroundObject,
|
BuildingGroundObject,
|
||||||
@ -53,15 +56,13 @@ from game.theater.theatergroundobject import (
|
|||||||
FactoryGroundObject,
|
FactoryGroundObject,
|
||||||
GenericCarrierGroundObject,
|
GenericCarrierGroundObject,
|
||||||
LhaGroundObject,
|
LhaGroundObject,
|
||||||
ShipGroundObject,
|
|
||||||
MissileSiteGroundObject,
|
MissileSiteGroundObject,
|
||||||
SceneryGroundObject,
|
SceneryGroundObject,
|
||||||
|
ShipGroundObject,
|
||||||
)
|
)
|
||||||
from game.unitmap import UnitMap
|
from game.unitmap import UnitMap
|
||||||
from game.utils import Heading, feet, knots, mps
|
from game.utils import Heading, feet, knots, mps
|
||||||
from game.radio.radios import RadioFrequency, RadioRegistry
|
|
||||||
from gen.runways import RunwayData
|
from gen.runways import RunwayData
|
||||||
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game import Game
|
from game import Game
|
||||||
@ -106,7 +107,7 @@ class GenericGroundObjectGenerator(Generic[TgoT]):
|
|||||||
logging.warning(f"Found empty group in {self.ground_object}")
|
logging.warning(f"Found empty group in {self.ground_object}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
unit_type = vehicle_type_from_name(group.units[0].type)
|
unit_type = vehicle_map[group.units[0].type]
|
||||||
vg = self.m.vehicle_group(
|
vg = self.m.vehicle_group(
|
||||||
self.country,
|
self.country,
|
||||||
group.name,
|
group.name,
|
||||||
@ -410,7 +411,7 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator[GenericCarrierGroundO
|
|||||||
self._register_unit_group(group, ship_group)
|
self._register_unit_group(group, ship_group)
|
||||||
|
|
||||||
def get_carrier_type(self, group: ShipGroup) -> Type[ShipType]:
|
def get_carrier_type(self, group: ShipGroup) -> Type[ShipType]:
|
||||||
return ship_type_from_name(group.units[0].type)
|
return ship_map[group.units[0].type]
|
||||||
|
|
||||||
def configure_carrier(
|
def configure_carrier(
|
||||||
self, group: ShipGroup, atc_channel: RadioFrequency
|
self, group: ShipGroup, atc_channel: RadioFrequency
|
||||||
@ -561,7 +562,7 @@ class ShipObjectGenerator(GenericGroundObjectGenerator[ShipGroundObject]):
|
|||||||
if not group.units:
|
if not group.units:
|
||||||
logging.warning(f"Found empty group in {self.ground_object}")
|
logging.warning(f"Found empty group in {self.ground_object}")
|
||||||
continue
|
continue
|
||||||
self.generate_group(group, ship_type_from_name(group.units[0].type))
|
self.generate_group(group, ship_map[group.units[0].type])
|
||||||
|
|
||||||
def generate_group(
|
def generate_group(
|
||||||
self, group_def: ShipGroup, first_unit_type: Type[ShipType]
|
self, group_def: ShipGroup, first_unit_type: Type[ShipType]
|
||||||
|
|||||||
@ -10,6 +10,7 @@ from dcs.mapping import Point
|
|||||||
from dcs.triggers import TriggerZone
|
from dcs.triggers import TriggerZone
|
||||||
from dcs.unit import Unit
|
from dcs.unit import Unit
|
||||||
from dcs.unitgroup import ShipGroup, VehicleGroup
|
from dcs.unitgroup import ShipGroup, VehicleGroup
|
||||||
|
from dcs.vehicles import vehicle_map
|
||||||
|
|
||||||
from .. import db
|
from .. import db
|
||||||
from ..data.radar_db import LAUNCHER_TRACKER_PAIRS, TELARS, TRACK_RADARS
|
from ..data.radar_db import LAUNCHER_TRACKER_PAIRS, TELARS, TRACK_RADARS
|
||||||
@ -526,7 +527,7 @@ class SamGroundObject(IadsGroundObject):
|
|||||||
max_telar_range = meters(0)
|
max_telar_range = meters(0)
|
||||||
launchers = set()
|
launchers = set()
|
||||||
for unit in group.units:
|
for unit in group.units:
|
||||||
unit_type = db.vehicle_type_from_name(unit.type)
|
unit_type = vehicle_map[unit.type]
|
||||||
if unit_type in TRACK_RADARS:
|
if unit_type in TRACK_RADARS:
|
||||||
live_trs.add(unit_type)
|
live_trs.add(unit_type)
|
||||||
elif unit_type in TELARS:
|
elif unit_type in TELARS:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user