mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
A lot of the dependency versions we have pinned don't have wheels for Python 3.12. Update almost all of them so we can upgrade Python. The few that weren't upgraded here are black and mypy, since those will be a bit invasive, and Pillow, which has an API change I don't want to deal with right now (I've got a commit on another machine that has already done the migration, so I'll do it later).
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from game.server.leaflet import LeafletPoint, LeafletPoly, ShapelyUtil
|
|
from game.sim.combat import FrozenCombat
|
|
from game.sim.combat.aircombat import AirCombat
|
|
from game.sim.combat.atip import AtIp
|
|
from game.sim.combat.defendingsam import DefendingSam
|
|
from game.theater import ConflictTheater
|
|
|
|
|
|
class FrozenCombatJs(BaseModel):
|
|
id: UUID
|
|
flight_position: LeafletPoint | None
|
|
target_positions: list[LeafletPoint] | None
|
|
footprint: list[LeafletPoly] | None
|
|
|
|
class Config:
|
|
title = "FrozenCombat"
|
|
|
|
@staticmethod
|
|
def for_combat(combat: FrozenCombat, theater: ConflictTheater) -> FrozenCombatJs:
|
|
if isinstance(combat, AirCombat):
|
|
return FrozenCombatJs(
|
|
id=combat.id,
|
|
flight_position=None,
|
|
target_positions=None,
|
|
footprint=ShapelyUtil.polys_to_leaflet(combat.footprint, theater),
|
|
)
|
|
if isinstance(combat, AtIp):
|
|
return FrozenCombatJs(
|
|
id=combat.id,
|
|
flight_position=LeafletPoint.from_pydcs(combat.flight.position()),
|
|
target_positions=[
|
|
LeafletPoint.from_pydcs(combat.flight.package.target.position)
|
|
],
|
|
footprint=None,
|
|
)
|
|
if isinstance(combat, DefendingSam):
|
|
return FrozenCombatJs(
|
|
id=combat.id,
|
|
flight_position=LeafletPoint.from_pydcs(combat.flight.position()),
|
|
target_positions=[
|
|
LeafletPoint.from_pydcs(sam.position) for sam in combat.air_defenses
|
|
],
|
|
footprint=None,
|
|
)
|
|
raise NotImplementedError(f"Unhandled FrozenCombat type: {combat.__class__}")
|