Skip to content

Commit

Permalink
Initial toy implementation of aircraft type.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Sep 25, 2023
1 parent 591c71f commit 9deb731
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
30 changes: 16 additions & 14 deletions airpower/aircraft.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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))
Expand Down
18 changes: 18 additions & 0 deletions airpower/aircrafttype.py
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 9deb731

Please sign in to comment.