Skip to content

Commit

Permalink
Use I, N, M, and AB for power settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Sep 26, 2023
1 parent 7e9f433 commit 8795fb1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions airpower/aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, name, aircrafttype, hexcode, azimuth, altitude, speed):
self._altitudecarry = 0
self._speed = speed
self._flighttype = "LV"
self._powersetting = "NOR"
self._powersetting = "N"
self._fpcarry = 0
self._apcarry = 0
self._aircrafttype = apaircrafttype.aircrafttype(aircrafttype)
Expand Down Expand Up @@ -465,27 +465,27 @@ def _startmovepower(self, power):
lastpowersetting = self._lastpowersetting

# TODO: Don't assume CL.
powerapMIL = self._aircrafttype.power("CL", "MIL")
powerapAB = self._aircrafttype.power("CL", "AB")
powerapM = self._aircrafttype.power("CL", "M")
powerapAB = self._aircrafttype.power("CL", "AB")

if power == "IDLE":
powersetting = "IDLE"
if power == "I":
powersetting = "I"
powerap = 0
elif power == "NOR" or power == 0:
powersetting = "NOR"
elif power == "N" or power == 0:
powersetting = "N"
powerap = 0
elif power == "MIL":
powersetting = "MIL"
powerap = powerapMIL
elif power == "M":
powersetting = "M"
powerap = powerapM
elif power == "AB" and powerapAB == None:
raise ValueError("aircraft does not have AB.")
elif power == "AB":
powersetting = "AB"
powerap = powerapAB
elif not isinstance(power, (int, float)) or power < 0 or power % 0.5 != 0:
raise ValueError("invalid power %r" % power)
elif power <= powerapMIL:
powersetting = "MIL"
elif power <= powerapM:
powersetting = "M"
powerap = power
elif powerapAB != None and power <= powerapAB:
powersetting = "AB"
Expand All @@ -496,19 +496,19 @@ def _startmovepower(self, power):
self._log("power setting is %s." % powersetting)

# See rule 6.1.
if powersetting == "IDLE":
speedchange = self._aircrafttype.power("CL", "IDLE")
if powersetting == "I":
speedchange = self._aircrafttype.power("CL", "I")
# This keeps the speed non-negative. See rule 6.2.
speedchange = min(speedchange, self._speed)
self._log("reducing speed by %.1f as the power setting is IDLE." % speedchange)
self._speed -= speedchange

# See rule 6.1.
if lastpowersetting == "IDLE" and powersetting == "AB" and not self._aircrafttype.hasproperty("RPR"):
if lastpowersetting == "I" and powersetting == "AB" and not self._aircrafttype.hasproperty("RPR"):
self._log("risk of flame-out as power setting has increased from IDLE to AB.")

# See rule 6.1.
if (powersetting == "IDLE" or powersetting == "NOR") and self._speed > self._aircrafttype.cruisespeed():
if (powersetting == "I" or powersetting == "N") and self._speed > self._aircrafttype.cruisespeed():
self._log("insufficient power above cruise speed.")
powerap -= 1.0

Expand Down
8 changes: 4 additions & 4 deletions airpower/aircrafttypes/F-80C.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "F-80C",
"origin": "TSOH",
"powertable": {
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 },
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 },
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 },
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0 }
"CL" : { "I": 0.5, "N": 0.0, "M": 1.0, "SPBR": 0.5 },
"1/2" : { "I": 0.5, "N": 0.0, "M": 1.0, "SPBR": 0.5 },
"DT" : { "I": 0.5, "N": 0.0, "M": 1.0, "SPBR": 0.5 },
"FUEL": { "I": 0.0, "N": 0.5, "M": 1.0 }
},
"maneuvertable": {
"LR/DR": { "HFP": 1.0, "DP": 1.5 },
Expand Down
8 changes: 4 additions & 4 deletions airpower/aircrafttypes/F-84E.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "F-84E",
"origin": "TSOH",
"powertable": {
"CL" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 1.0, "SPBR": 0.5 },
"1/2" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 0.5 },
"DT" : { "IDLE": 0.5, "NOR": 0.0, "MIL": 0.5, "SPBR": 1.0 },
"FUEL": { "IDLE": 0.0, "NOR": 0.5, "MIL": 1.0 }
"CL" : { "I": 0.5, "N": 0.0, "M": 1.0, "SPBR": 0.5 },
"1/2" : { "I": 0.5, "N": 0.0, "M": 0.5, "SPBR": 0.5 },
"DT" : { "I": 0.5, "N": 0.0, "M": 0.5, "SPBR": 1.0 },
"FUEL": { "I": 0.0, "N": 0.5, "M": 1.0 }
},
"maneuvertable": {
"LR/DR": { "HFP": 1.0, "DP": 1.5 },
Expand Down

0 comments on commit 8795fb1

Please sign in to comment.