Dan Albert a2e98f485c
Remove bingo estimates from FlightPlan.
This doesn't need to be a part of FlightPlan, and it's easier to test if
it isn't. Move it out and add the tests.

It's pretty misleading to allow this in the core of the flight plan code
anything. This is an extremely unreliable estimate for most aircraft so
it should be more clearly just for briefing purposes.
2023-10-07 23:08:25 +02:00

52 lines
1.8 KiB
Python

import pytest
from dcs import Point
from dcs.terrain import Terrain, Caucasus
from game.ato import FlightWaypoint
from game.ato.flightwaypointtype import FlightWaypointType
from game.dcs.aircrafttype import FuelConsumption
from game.missiongenerator.aircraft.bingoestimator import BingoEstimator
from game.utils import nautical_miles
@pytest.fixture(name="terrain")
def terrain_fixture() -> Terrain:
return Caucasus()
@pytest.fixture(name="waypoints")
def waypoints_fixture(terrain: Terrain) -> list[FlightWaypoint]:
return [
FlightWaypoint(
"", FlightWaypointType.NAV, Point(0, nautical_miles(d).meters, terrain)
)
for d in range(101)
]
def test_legacy_bingo_estimator(
waypoints: list[FlightWaypoint], terrain: Terrain
) -> None:
estimator = BingoEstimator(None, Point(0, 0, terrain), None, waypoints)
assert estimator.estimate_bingo() == 3000
assert estimator.estimate_joker() == estimator.estimate_bingo() + 1000
estimator = BingoEstimator(
None, Point(0, 0, terrain), Point(0, 5, terrain), waypoints
)
assert estimator.estimate_bingo() == 4000
assert estimator.estimate_joker() == estimator.estimate_bingo() + 1000
def test_fuel_consumption_based_bingo_estimator(
waypoints: list[FlightWaypoint], terrain: Terrain
) -> None:
consumption = FuelConsumption(100, 50, 10, 25, 1000)
estimator = BingoEstimator(consumption, Point(0, 0, terrain), None, waypoints)
assert estimator.estimate_bingo() == 2000
assert estimator.estimate_joker() == estimator.estimate_bingo() + 1000
estimator = BingoEstimator(
consumption, Point(0, 0, terrain), Point(0, 5, terrain), waypoints
)
assert estimator.estimate_bingo() == 2000
assert estimator.estimate_joker() == estimator.estimate_bingo() + 1000