From d7e62d0b0b06980da6ffd0cf7e22b32241a8b7f8 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 6 Mar 2022 23:44:15 -0800 Subject: [PATCH] Remove another hand written API model. There are still two more of these that don't show up in openapi.json because they don't show up in HTTP routes (only in the websocket): * GameUpdateEvents * FrozenCombat I'm not sure if there's a way to forcibly include those in the openapi.json, if I should add a no-op API to force it to happen, or if I should just ignore it. For now I'm going with option 3. --- client/src/api/actions.ts | 2 +- client/src/api/game.ts | 21 --------------------- client/src/api/gamestate.ts | 4 ++-- client/src/api/liberationApi.ts | 2 +- game/server/game/models.py | 2 +- 5 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 client/src/api/game.ts diff --git a/client/src/api/actions.ts b/client/src/api/actions.ts index 003ad2bc..3edbaeef 100644 --- a/client/src/api/actions.ts +++ b/client/src/api/actions.ts @@ -1,4 +1,4 @@ -import Game from "./game"; +import { Game } from "./liberationApi"; import { createAction } from "@reduxjs/toolkit"; export const gameLoaded = createAction("game/loaded"); diff --git a/client/src/api/game.ts b/client/src/api/game.ts deleted file mode 100644 index 63c88285..00000000 --- a/client/src/api/game.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { - ControlPoint, - Flight, - FrontLine, - NavMeshes, - SupplyRoute, - Tgo, - ThreatZoneContainer, -} from "./liberationApi"; -import { LatLngLiteral } from "leaflet"; - -export default interface Game { - control_points: ControlPoint[]; - tgos: Tgo[]; - supply_routes: SupplyRoute[]; - front_lines: FrontLine[]; - flights: Flight[]; - threat_zones: ThreatZoneContainer; - navmeshes: NavMeshes; - map_center: LatLngLiteral | null; -} diff --git a/client/src/api/gamestate.ts b/client/src/api/gamestate.ts index 25fe3f48..84937f0e 100644 --- a/client/src/api/gamestate.ts +++ b/client/src/api/gamestate.ts @@ -1,7 +1,7 @@ import { AppDispatch } from "../app/store"; import { gameLoaded, gameUnloaded } from "./actions"; import backend from "./backend"; -import Game from "./game"; +import { Game } from "./liberationApi"; export default function reloadGameState( dispatch: AppDispatch, @@ -17,7 +17,7 @@ export default function reloadGameState( } const game = response.data as Game; if (ignoreRecenter) { - game.map_center = null; + game.map_center = undefined; } dispatch(gameLoaded(game)); }); diff --git a/client/src/api/liberationApi.ts b/client/src/api/liberationApi.ts index cef3113d..295554ab 100644 --- a/client/src/api/liberationApi.ts +++ b/client/src/api/liberationApi.ts @@ -443,7 +443,7 @@ export type Game = { flights: Flight[]; threat_zones: ThreatZoneContainer; navmeshes: NavMeshes; - map_center: LatLng; + map_center?: LatLng; }; export type MapZones = { inclusion: LatLng[][]; diff --git a/game/server/game/models.py b/game/server/game/models.py index 3ac7ad36..ec7c0e47 100644 --- a/game/server/game/models.py +++ b/game/server/game/models.py @@ -25,7 +25,7 @@ class GameJs(BaseModel): flights: list[FlightJs] threat_zones: ThreatZoneContainerJs navmeshes: NavMeshesJs - map_center: LeafletPoint + map_center: LeafletPoint | None class Config: title = "Game"