Dan Albert 7bc35ef7f4 Update most Python dependencies.
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).
2023-11-30 20:24:28 -08:00

47 lines
1.2 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from uuid import UUID
from pydantic import BaseModel
from game.server.leaflet import LeafletPoint
if TYPE_CHECKING:
from game import Game
from game.theater import ControlPoint
class ControlPointJs(BaseModel):
id: UUID
name: str
blue: bool
position: LeafletPoint
mobile: bool
destination: LeafletPoint | None
sidc: str
class Config:
title = "ControlPoint"
@staticmethod
def for_control_point(control_point: ControlPoint) -> ControlPointJs:
destination = None
if control_point.target_position is not None:
destination = control_point.target_position.latlng()
return ControlPointJs(
id=control_point.id,
name=control_point.name,
blue=control_point.captured,
position=LeafletPoint.from_pydcs(control_point.position),
mobile=control_point.moveable and control_point.captured,
destination=destination,
sidc=str(control_point.sidc()),
)
@staticmethod
def all_in_game(game: Game) -> list[ControlPointJs]:
return [
ControlPointJs.for_control_point(cp) for cp in game.theater.controlpoints
]