2024-05-18 21:13:32 +02:00

56 lines
1.8 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from pydantic import BaseModel
from game.server.controlpoints.models import ControlPointJs
from game.server.flights.models import FlightJs
from game.server.frontlines.models import FrontLineJs
from game.server.iadsnetwork.models import IadsNetworkJs
from game.server.leaflet import LeafletPoint
from game.server.mapzones.models import (
ThreatZoneContainerJs,
UnculledZoneJs,
MapZonesJs,
)
from game.server.navmesh.models import NavMeshesJs
from game.server.supplyroutes.models import SupplyRouteJs
from game.server.tgos.models import TgoJs
if TYPE_CHECKING:
from game import Game
class GameJs(BaseModel):
control_points: list[ControlPointJs]
tgos: list[TgoJs]
supply_routes: list[SupplyRouteJs]
front_lines: list[FrontLineJs]
flights: list[FlightJs]
iads_network: IadsNetworkJs
threat_zones: ThreatZoneContainerJs
navmeshes: NavMeshesJs
map_center: LeafletPoint | None
unculled_zones: list[UnculledZoneJs]
map_zones: MapZonesJs
class Config:
title = "Game"
@staticmethod
def from_game(game: Game) -> GameJs:
return GameJs(
control_points=ControlPointJs.all_in_game(game),
tgos=TgoJs.all_in_game(game),
supply_routes=SupplyRouteJs.all_in_game(game),
front_lines=FrontLineJs.all_in_game(game),
flights=FlightJs.all_in_game(game, with_waypoints=True),
iads_network=IadsNetworkJs.from_network(game.theater.iads_network),
threat_zones=ThreatZoneContainerJs.for_game(game),
navmeshes=NavMeshesJs.from_game(game),
map_center=game.theater.terrain.map_view_default.position.latlng(),
unculled_zones=UnculledZoneJs.from_game(game),
map_zones=MapZonesJs.from_game(game),
)