mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Migrate IP placement to WaypointSolver.
This commit is contained in:
@@ -4,7 +4,7 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from game import Game
|
||||
from game.ato import Flight
|
||||
from game.flightplan import HoldZoneGeometry, IpZoneGeometry, JoinZoneGeometry
|
||||
from game.flightplan import HoldZoneGeometry, JoinZoneGeometry
|
||||
from ..leaflet import LeafletLine, LeafletPoly, ShapelyUtil
|
||||
|
||||
|
||||
@@ -59,42 +59,6 @@ class HoldZonesJs(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class IpZonesJs(BaseModel):
|
||||
home_bubble: LeafletPoly = Field(alias="homeBubble")
|
||||
ipBubble: LeafletPoly = Field(alias="ipBubble")
|
||||
permissibleZone: LeafletPoly = Field(alias="permissibleZone")
|
||||
safeZones: list[LeafletPoly] = Field(alias="safeZones")
|
||||
preferred_threatened_zones: list[LeafletPoly] = Field(
|
||||
alias="preferredThreatenedZones"
|
||||
)
|
||||
tolerable_threatened_lines: list[LeafletLine] = Field(
|
||||
alias="tolerableThreatenedLines"
|
||||
)
|
||||
|
||||
class Config:
|
||||
title = "IpZones"
|
||||
|
||||
@classmethod
|
||||
def for_flight(cls, flight: Flight, game: Game) -> IpZonesJs:
|
||||
target = flight.package.target
|
||||
home = flight.departure
|
||||
geometry = IpZoneGeometry(target.position, home.position, game.blue)
|
||||
return IpZonesJs(
|
||||
homeBubble=ShapelyUtil.poly_to_leaflet(geometry.home_bubble, game.theater),
|
||||
ipBubble=ShapelyUtil.poly_to_leaflet(geometry.ip_bubble, game.theater),
|
||||
permissibleZone=ShapelyUtil.poly_to_leaflet(
|
||||
geometry.permissible_zone, game.theater
|
||||
),
|
||||
safeZones=ShapelyUtil.polys_to_leaflet(geometry.safe_zones, game.theater),
|
||||
preferredThreatenedZones=ShapelyUtil.polys_to_leaflet(
|
||||
geometry.preferred_threatened_zones, game.theater
|
||||
),
|
||||
tolerableThreatenedLines=ShapelyUtil.lines_to_leaflet(
|
||||
geometry.tolerable_threatened_lines, game.theater
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class JoinZonesJs(BaseModel):
|
||||
home_bubble: LeafletPoly = Field(alias="homeBubble")
|
||||
target_bubble: LeafletPoly = Field(alias="targetBubble")
|
||||
|
||||
@@ -4,7 +4,7 @@ from fastapi import APIRouter, Depends
|
||||
|
||||
from game import Game
|
||||
from game.server import GameContext
|
||||
from .models import HoldZonesJs, IpZonesJs, JoinZonesJs
|
||||
from .models import HoldZonesJs, JoinZonesJs
|
||||
|
||||
router: APIRouter = APIRouter(prefix="/debug/waypoint-geometries")
|
||||
|
||||
@@ -18,13 +18,6 @@ def hold_zones(
|
||||
return HoldZonesJs.for_flight(game.db.flights.get(flight_id), game)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/ip/{flight_id}", operation_id="get_debug_ip_zones", response_model=IpZonesJs
|
||||
)
|
||||
def ip_zones(flight_id: UUID, game: Game = Depends(GameContext.require)) -> IpZonesJs:
|
||||
return IpZonesJs.for_flight(game.db.flights.get(flight_id), game)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/join/{flight_id}", operation_id="get_debug_join_zones", response_model=JoinZonesJs
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user