Skip to content

Commit

Permalink
Check free descent.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Oct 1, 2023
1 parent bb8eac2 commit 70587c1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions airpower/aircraft/_normalflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,25 @@ def checkaltitudechange():

# See rule 8.2.1.
if altitudechange != 1 and altitudechange != 2:
raise RuntimeError("attempt to dive levels per VFP while the flight type is SC.")
raise RuntimeError("attempt to dive levels per VFP while the flight type is SC." % altitudechange)

elif flighttype == "UD":

# See rule 8.2.2.
if altitudechange != 1:
raise RuntimeError("attempt to dive %d levels per unloaded HFP while the flight type is UL.")
raise RuntimeError("attempt to dive %d levels per unloaded HFP while the flight type is UL." % altitudechange)

elif flighttype == "VD":

# See rule 8.2.3.
if altitudechange != 2 or altitudechange != 3:
raise RuntimeError("attempt to dive %d levels per VFP while the flight type is VD.")
raise RuntimeError("attempt to dive %d levels per VFP while the flight type is VD." % altitudechange)

elif flighttype == "LVL":

# See rule 8.2.4.
if altitudechange != 1:
raise RuntimeError("attempt to descend of %d level while flight type is LVL.")
raise RuntimeError("attempt to descend %d levels while flight type is LVL." % altitudechange)

else:

Expand Down Expand Up @@ -700,6 +700,15 @@ def checkfp():
raise RuntimeError("too many VFPs.")

# TODO: check unloaded HFPs.

def checkfreedescent():

# See rule 8.2.4.

if self._flighttype == "LVL":
altitudechange = self._altitude - self._lastaltitude
if altitudechange < -1:
raise RuntimeError("free descent cannot only be taken once per move.")

def reportturn():

Expand Down Expand Up @@ -803,6 +812,7 @@ def determinealtitudeap():

reportfp()
checkfp()
checkfreedescent()
reportturn()
determinealtitudeap()

Expand Down

0 comments on commit 70587c1

Please sign in to comment.