Move frozen combat handling out of MapModel.

This commit is contained in:
Dan Albert
2022-02-19 13:50:59 -08:00
parent 2168143fea
commit 09457d8aab
17 changed files with 140 additions and 136 deletions

View File

@@ -5,6 +5,7 @@ from uuid import UUID
from pydantic import BaseModel
from game.server.combat.models import FrozenCombatJs
from game.server.leaflet import LeafletLatLon
if TYPE_CHECKING:
@@ -14,6 +15,8 @@ if TYPE_CHECKING:
class GameUpdateEventsJs(BaseModel):
updated_flights: dict[UUID, LeafletLatLon]
new_combats: list[FrozenCombatJs] = []
updated_combats: list[FrozenCombatJs] = []
@classmethod
def from_events(cls, events: GameUpdateEvents, game: Game) -> GameUpdateEventsJs:
@@ -21,5 +24,12 @@ class GameUpdateEventsJs(BaseModel):
updated_flights={
f[0].id: game.theater.point_to_ll(f[1]).as_list()
for f in events.updated_flights
}
},
new_combats=[
FrozenCombatJs.for_combat(c, game.theater) for c in events.new_combats
],
updated_combats=[
FrozenCombatJs.for_combat(c, game.theater)
for c in events.updated_combats
],
)