Move pydcs helper function out of db.

This commit is contained in:
Dan Albert
2022-02-18 18:10:02 -08:00
parent b4742ad54c
commit 4f64329f25
8 changed files with 32 additions and 34 deletions

0
game/dcs/__init__.py Normal file
View File

20
game/dcs/helpers.py Normal file
View File

@@ -0,0 +1,20 @@
from typing import Optional, Type
from dcs.helicopters import helicopter_map
from dcs.planes import plane_map
from dcs.ships import ship_map
from dcs.unittype import UnitType
from dcs.vehicles import vehicle_map
def unit_type_from_name(name: str) -> Optional[Type[UnitType]]:
if name in vehicle_map:
return vehicle_map[name]
elif name in plane_map:
return plane_map[name]
elif name in ship_map:
return ship_map[name]
if name in helicopter_map:
return helicopter_map[name]
else:
return None