Skip to content

Commit

Permalink
Keep track of GLOC checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Oct 9, 2023
1 parent 25fd679 commit 2cc397c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions airpower/aircraft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def __init__(self, name, aircraftdata, hexcode, azimuth, altitude, speed, config
self._turnfp = 0
self._fpcarry = 0
self._apcarry = 0
self._gloccheck = 0
self._aircraftdata = apaircraftdata.aircraftdata(aircraftdata)
self._destroyed = False
self._leftmap = False
Expand Down Expand Up @@ -132,6 +133,7 @@ def __str__(self):
["configuration", self._configuration],
["fpcarry" , self._fpcarry],
["apcarry" , self._apcarry],
["gloccheck" , self._gloccheck],
["altitudecarry", self._altitudecarry],
["destroyed" , self._destroyed],
["leftmap" , self._leftmap],
Expand Down Expand Up @@ -200,6 +202,7 @@ def _restore(self, i):
self._turnfp, \
self._fpcarry, \
self._apcarry, \
self._gloccheck, \
self._destroyed, \
self._leftmap, \
self._turnsstalled, \
Expand Down Expand Up @@ -230,6 +233,7 @@ def _save(self, i):
self._turnfp, \
self._fpcarry, \
self._apcarry, \
self._gloccheck, \
self._destroyed, \
self._leftmap, \
self._turnsstalled, \
Expand Down
9 changes: 9 additions & 0 deletions airpower/aircraft/_normalflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ def doturn(sense, facingchange):
self._facing = (self._facing - facingchange) % 360

self._turnfp = 0

if self._turnrate == "ET" and self._altitude <= 25:
self._gloccheck += 1
self._log("- risk of GLOC (check %d in cycle)." % self._gloccheck)

########################################

Expand Down Expand Up @@ -1074,6 +1078,11 @@ def reportturn():
if self._maxturnrate != None:
self._log("- turned at %s rate." % self._maxturnrate)

# See rule 7.6.
if self._gloccheck > 0 and self._maxturnrate != "ET" and self._maxturnrate != "BT":
self._log("- GLOC cycle ended.")
self._gloccheck = 0

if self._turnfp > 0 and self._turnrate != None:
self._log("- finished turning %s at %s rate with %d FPs carried." % (self._bank, self._turnrate, self._turnfp))
elif self._bank == None:
Expand Down

0 comments on commit 2cc397c

Please sign in to comment.