Bingo & Joker Fuel for Flight Plans (#480)

Add bingo and joker fuel information to the kneeboard.
This commit is contained in:
Ignacio Muñoz Fernandez 2020-11-29 23:53:15 +01:00 committed by GitHub
parent 45ce28f9bf
commit 66ee5f5392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 17 deletions

View File

@ -293,12 +293,19 @@ class FlightData:
#: Map of radio frequencies to their assigned radio and channel, if any.
frequency_to_channel_map: Dict[RadioFrequency, ChannelAssignment]
#: Bingo fuel value in lbs.
bingo_fuel: Optional[int]
joker_fuel: Optional[int]
def __init__(self, package: Package, flight_type: FlightType,
units: List[FlyingUnit], size: int, friendly: bool,
departure_delay: timedelta, departure: RunwayData,
arrival: RunwayData, divert: Optional[RunwayData],
waypoints: List[FlightWaypoint],
intra_flight_channel: RadioFrequency) -> None:
intra_flight_channel: RadioFrequency,
bingo_fuel: Optional[int],
joker_fuel: Optional[int]) -> None:
self.package = package
self.flight_type = flight_type
self.units = units
@ -311,6 +318,8 @@ class FlightData:
self.waypoints = waypoints
self.intra_flight_channel = intra_flight_channel
self.frequency_to_channel_map = {}
self.bingo_fuel = bingo_fuel
self.joker_fuel = joker_fuel
self.callsign = create_group_callsign_from_unit(self.units[0])
@property
@ -777,7 +786,9 @@ class AircraftConflictGenerator:
divert=divert,
# Waypoints are added later, after they've had their TOTs set.
waypoints=[],
intra_flight_channel=channel
intra_flight_channel=channel,
bingo_fuel=flight.flight_plan.bingo_fuel,
joker_fuel=flight.flight_plan.joker_fuel
))
# Special case so Su 33 carrier take off

View File

@ -28,7 +28,7 @@ from game.theater import (
TheaterGroundObject,
)
from game.theater.theatergroundobject import EwrGroundObject
from game.utils import nm_to_meter
from game.utils import nm_to_meter, meter_to_nm
from .closestairfields import ObjectiveDistanceCache
from .flight import Flight, FlightType, FlightWaypoint, FlightWaypointType
from .traveltime import GroundSpeed, TravelTime
@ -69,6 +69,8 @@ class FlightPlan:
"""A list of all waypoints in the flight plan, in order."""
return list(self.iter_waypoints())
def iter_waypoints(self) -> Iterator[FlightWaypoint]:
"""Iterates over all waypoints in the flight plan, in order."""
raise NotImplementedError
@ -114,6 +116,38 @@ class FlightPlan:
failed to generate. Nevertheless, we have to defend against it.
"""
raise NotImplementedError
@cached_property
def bingo_fuel(self) -> int:
"""Bingo fuel value for the FlightPlan
"""
distance_to_arrival = meter_to_nm(self.max_distance_from(self.flight.arrival))
bingo = 1000 # Minimum Emergency Fuel
bingo += 500 # Visual Traffic
bingo += 15 * distance_to_arrival
# TODO: Per aircraft tweaks.
if self.flight.divert is not None:
bingo += 10 * meter_to_nm(self.max_distance_from(self.flight.divert))
return round(bingo / 100) * 100
@cached_property
def joker_fuel(self) -> int:
"""Joker fuel value for the FlightPlan
"""
return self.bingo_fuel + 1000
def max_distance_from(self, cp: ControlPoint) -> int:
"""Returns the farthest waypoint of the flight plan from a ControlPoint.
:arg cp The ControlPoint to measure distance from.
"""
if not self.waypoints:
return 0
return max([cp.position.distance_to_point(w.position) for w in self.waypoints])
@property
def tot_offset(self) -> timedelta:

View File

@ -230,28 +230,37 @@ class BriefingPage(KneeboardPage):
"#", "Action", "Alt", "Dist", "GSPD", "Time", "Departure"
])
writer.heading("Comm Ladder")
comms = []
flight_plan_builder
writer.table([
["{}lbs".format(self.flight.bingo_fuel), "{}lbs".format(self.flight.joker_fuel)]
], ['Bingo', 'Joker'])
# Package Section
writer.heading("Comm ladder")
comm_ladder = []
for comm in self.comms:
comms.append([comm.name, self.format_frequency(comm.freq)])
writer.table(comms, headers=["Name", "UHF"])
comm_ladder.append([comm.name, '', '', '', self.format_frequency(comm.freq)])
writer.heading("AWACS")
awacs = []
for a in self.awacs:
awacs.append([a.callsign, self.format_frequency(a.freq)])
writer.table(awacs, headers=["Callsign", "UHF"])
writer.heading("Tankers")
tankers = []
comm_ladder.append([
a.callsign,
'AWACS',
'',
'',
self.format_frequency(a.freq)
])
for tanker in self.tankers:
tankers.append([
comm_ladder.append([
tanker.callsign,
"Tanker",
tanker.variant,
str(tanker.tacan),
self.format_frequency(tanker.freq),
])
writer.table(tankers, headers=["Callsign", "Type", "TACAN", "UHF"])
])
writer.table(comm_ladder, headers=["Callsign","Task", "Type", "TACAN", "FREQ"])
writer.heading("JTAC")
jtacs = []