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

42 lines
1.1 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING
from uuid import UUID
from pydantic import BaseModel
from game.missiongenerator.frontlineconflictdescription import (
FrontLineConflictDescription,
)
from game.server.leaflet import LeafletPoint
if TYPE_CHECKING:
from game import Game
from game.theater import FrontLine, ConflictTheater
class FrontLineJs(BaseModel):
id: UUID
extents: list[LeafletPoint]
class Config:
title = "FrontLine"
@staticmethod
def for_front_line(theater: ConflictTheater, front_line: FrontLine) -> FrontLineJs:
bounds = FrontLineConflictDescription.frontline_bounds(front_line, theater)
return FrontLineJs(
id=front_line.id,
extents=[
LeafletPoint.from_pydcs(bounds.left_position),
LeafletPoint.from_pydcs(bounds.right_position),
],
)
@staticmethod
def all_in_game(game: Game) -> list[FrontLineJs]:
return [
FrontLineJs.for_front_line(game.theater, f)
for f in game.theater.conflicts()
]