From 9deb731ca61d4a2fa16005d88a033b7f4af465e5 Mon Sep 17 00:00:00 2001 From: alanwatsonforster <68709385+alanwatsonforster@users.noreply.github.com> Date: Sun, 24 Sep 2023 22:49:13 -0600 Subject: [PATCH] Initial toy implementation of aircraft type. --- airpower/aircraft.py | 30 ++++++++++++++++-------------- airpower/aircrafttype.py | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 airpower/aircrafttype.py diff --git a/airpower/aircraft.py b/airpower/aircraft.py index 39ab6733..e1945b90 100644 --- a/airpower/aircraft.py +++ b/airpower/aircraft.py @@ -1,17 +1,17 @@ -from typing import ParamSpecArgs -import airpower.altitude as apaltitude -import airpower.azimuth as apazimuth -import airpower.draw as apdraw -import airpower.hex as aphex -import airpower.hexcode as aphexcode -import airpower.map as apmap -import airpower.turn as apturn +import airpower.aircrafttype as apaircrafttype +import airpower.altitude as apaltitude +import airpower.azimuth as apazimuth +import airpower.draw as apdraw +import airpower.hex as aphex +import airpower.hexcode as aphexcode +import airpower.map as apmap +import airpower.turn as apturn import math class aircraft: - def __init__(self, name, hexcode, azimuth, altitude, speed): + def __init__(self, name, aircrafttype, hexcode, azimuth, altitude, speed): x, y = aphexcode.toxy(hexcode) facing = apazimuth.tofacing(azimuth) @@ -29,7 +29,7 @@ def __init__(self, name, hexcode, azimuth, altitude, speed): self._flighttype = "LV" self._fpcarry = 0 self._apcarry = 0 - + self._aircrafttype = apaircrafttype.aircrafttype(aircrafttype) self._destroyed = False self._leftmap = False @@ -527,12 +527,14 @@ def _endmove(self): if self._maxturnrate == None: self._report("no turns.") - turnap = 0 + turnap = 0.0 else: self._report("maximum turn rate is %s." % self._maxturnrate) - # TODO: These hard-wired values are just for testing. - turndrag = { "EZ": 0.0, "TT": 0.0, "HT": 1.0, "BT": 2.0, } - turnap = -turndrag[self._maxturnrate] + if self._maxturnrate == "EZ": + turnap = 0.0 + else: + # TODO: Don't assume CL. + turnap = -self._aircrafttype.turndrag("CL")[self._maxturnrate] self._report("power APs = %+.1f." % self._powerap) self._report("turn APs = %+.1f and %+.1f." % (turnap, self._sustainedturnap)) diff --git a/airpower/aircrafttype.py b/airpower/aircrafttype.py new file mode 100644 index 00000000..76e30036 --- /dev/null +++ b/airpower/aircrafttype.py @@ -0,0 +1,18 @@ +class aircrafttype: + + def __init__(self, name): + self._name = name + + def turndrag(self, configuration): + if self._name == "F-80C": + return { + "CL" : { "TT": 0.0, "HT": 1.0, "BT": 1.0, }, + "1/2": { "TT": 0.0, "HT": 1.0, "BT": 1.0, }, + "DT" : { "TT": 0.0, "HT": 1.0, "BT": 2.0, }, + }[configuration] + elif self._name == "F-84E": + return { + "CL" : { "TT": 0.0, "HT": 1.0, "BT": 2.0, }, + "1/2": { "TT": 1.0, "HT": 2.0, "BT": 2.0, }, + "DT" : { "TT": 1.0, "HT": 2.0, "BT": 2.0, }, + }[configuration]