Skip to content

Commit

Permalink
Factored out position code.
Browse files Browse the repository at this point in the history
  • Loading branch information
alanwatsonforster committed Sep 29, 2023
1 parent a9d5c44 commit 114078c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
14 changes: 14 additions & 0 deletions airpower/aircraft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ def __str__(self):
s += "%-16s: %s\n" % (x[0], x[1])
return s

def position(self):

if apmap.isonmap(self._x, self._y):
sheet = apmap.tosheet(self._x, self._y)
hexcode = aphexcode.fromxy(self._x, self._y)
else:
sheet = "--"
hexcode = "----"
azimuth = apazimuth.fromfacing(self._facing)
altitude = self._altitude
altitudeband = self._altitudeband
return "%2s %-9s %-3s %2d %2s" % (sheet, hexcode, azimuth, altitude, altitudeband)


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

def checkforterraincollision(self):
Expand Down
13 changes: 1 addition & 12 deletions airpower/aircraft/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,7 @@ def _logbreak(self):

def _logposition(self, s, t):

if apmap.isonmap(self._x, self._y):
sheet = apmap.tosheet(self._x, self._y)
hexcode = aphexcode.fromxy(self._x, self._y)
else:
sheet = "--"
hexcode = "----"
azimuth = apazimuth.fromfacing(self._facing)
altitude = self._altitude
altitudeband = self._altitudeband
position = "%2s %-9s %-3s %2d %2s" % (sheet, hexcode, azimuth, altitude, altitudeband)

self._log("%-5s : %-16s : %s" % (s, t, position))
self._log("%-5s : %-16s : %s" % (s, t, self.position()))

def _logevent(self, s):
self._log("%-5s : %s" % ("", s))

0 comments on commit 114078c

Please sign in to comment.