Mercurial > atc
changeset 21:4c026c5634f9
Cleaned up some FIXMEs (command parsing mostly)
Do some rounding on numbers
committer: Jeff Sipek <jeffpc@jeff.(none)> 1121309774 -0400
author | Jeff Sipek <jeffpc@jeff.(none)> |
---|---|
date | Thu, 14 Jul 2005 02:56:14 -0400 |
parents | 51e09ccbfd4e |
children | a6f6d5d822be |
files | atc_plane.py atc_single.py |
diffstat | 2 files changed, 31 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/atc_plane.py Thu Jul 14 02:24:58 2005 -0400 +++ b/atc_plane.py Thu Jul 14 02:56:14 2005 -0400 @@ -251,7 +251,7 @@ # "Head: " + str(int(self.vel["heading"])), # "AS: " + str(int(self.vel["speed"]*3.6))) strings = ( self.flightno, - "%03d %03d" % (int(self.vel["heading"]), int(self.vel["speed"]*3.6)), + "%03d %03d" % (int(round(self.vel["heading"])), int(round(self.vel["speed"]*3.6))), self.specs["name"]) for stri in strings:
--- a/atc_single.py Thu Jul 14 02:24:58 2005 -0400 +++ b/atc_single.py Thu Jul 14 02:56:14 2005 -0400 @@ -162,15 +162,26 @@ mess.pickup_kill = 1 return - flno = cmd_plane(cmd) - cmd = cmd_cmd(cmd) - print "plane = " + flno + ", cmd = " + cmd - for plane in planes: - if plane.flightno.upper() == flno.upper(): - print "Found match!" - plane.process(cmd) - break - cmd = "" + if (cmd.__len__()): + flno = cmd_plane(cmd) + com = cmd_cmd(cmd) + + flag = None + if (com!=None) and (flno!=None): + print "plane = " + flno + ", cmd = " + com + for plane in planes: + if plane.flightno.upper() == flno.upper(): + print "Found match!" + plane.process(com) + flag = 1 + break + + if (flag == None): + # either not the right syntax, or we + # didn't find the right plane + print "Error, could not process command" + + cmd = "" screen.blit(background, (0, 0)) @@ -189,11 +200,18 @@ pygame.display.flip() def cmd_plane(cmd): - return cmd.split(': ')[0] + parts = cmd.split(': ') + + if (parts.__len__()>1): + return parts[0] + return None def cmd_cmd(cmd): - # FIXME: what if no split happens? - return cmd.split(': ')[1] + parts = cmd.split(': ') + + if (parts.__len__()>1): + return parts[1] + return None if (__name__ == '__main__'): print "Don't do it!"