moveklings()
# if no enemies remain after movement, we're done
- if game.nenhere==0 or (game.nenhere==1 and iqhere and not iqengry):
+ if game.nenhere==0 or (game.nenhere==1 and thing == game.quadrant and not iqengry):
return
# set up partial hits if attack happens during shield status change
game.ithere = False
elif type == IHQUEST:
# Killed a Thingy
- global iqhere, iqengry
- iqhere = iqengry = False
+ global iqengry
+ iqengry = False
invalidate(thing)
else:
# Some type of a Klingon
if game.options & OPTION_CURSES:
curwnd.attron(curses.A_REVERSE)
-def commandhook(cmd, before):
- pass
-
#
# Things past this point have policy implications.
#
setwnd(report_window)
report_window.clear()
report_window.move(0, 0)
- status(0)
+ status()
setwnd(lrscan_window)
lrscan_window.clear()
lrscan_window.move(0, 0)
skip(1)
setwnd(status_window)
else:
- proutn(" " * NSYM - len(tx))
- vproutn(data)
+ proutn(" " * (NSYM - len(txt)))
+ proutn(data)
skip(1)
if game.options & OPTION_CURSES:
setwnd(report_window)
else:
proutn(" ")
if game.state.galaxy[i][j].supernova:
- strcpy(buf, "***")
+ show = "***"
elif not game.state.galaxy[i][j].charted and game.state.galaxy[i][j].starbase:
- strcpy(buf, ".1.")
+ show = ".1."
elif game.state.galaxy[i][j].charted:
- sprintf(buf, "%3d" % (game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars))
+ show = "%3d" % (game.state.chart[i][j].klingons*100 + game.state.chart[i][j].starbase * 10 + game.state.chart[i][j].stars)
else:
- strcpy(buf, "...")
- proutn(buf)
+ show = "..."
+ proutn(show)
if (game.options & OPTION_SHOWME) and i == game.quadrant.x and j == game.quadrant.y:
proutn(">")
else:
else:
proutn("- ")
-def status(req):
+def status(req=0):
# print status report lines
if not req or req == 1:
prstat(_("Stardate"), _("%.1f, Time Left %.2f") \
% (game.state.date, game.state.remtime))
- elif not req or req == 2:
+ if not req or req == 2:
if game.condition != "docked":
newcnd()
dam = 0
if game.damage[t]>0:
dam += 1
prstat(_("Condition"), _("%s, %i DAMAGES") % (game.condition.upper(), dam))
- elif not req or req == 3:
+ if not req or req == 3:
prstat(_("Position"), "%s , %s" % (game.quadrant, game.sector))
- elif not req or req == 4:
+ if not req or req == 4:
if damaged(DLIFSUP):
if game.condition == "docked":
- sprintf(s, _("DAMAGED, Base provides"))
+ s = _("DAMAGED, Base provides")
else:
- sprintf(s, _("DAMAGED, reserves=%4.2f") % game.lsupres)
+ s = _("DAMAGED, reserves=%4.2f") % game.lsupres
else:
- sprintf(s, _("ACTIVE"))
+ s = _("ACTIVE")
prstat(_("Life Support"), s)
- elif not req or req == 5:
- prstat(_("Warp Factor"), "%.1f" % (game.warpfac))
- elif not req or req == 6:
+ if not req or req == 5:
+ prstat(_("Warp Factor"), "%.1f" % game.warpfac)
+ if not req or req == 6:
extra = ""
if game.icrystl and (game.options & OPTION_SHOWME):
extra = _(" (have crystals)")
- prstat(_("Energy"), "%.2f%s" % game.energy, extra)
- elif not req or req == 7:
+ prstat(_("Energy"), "%.2f%s" % (game.energy, extra))
+ if not req or req == 7:
prstat(_("Torpedoes"), "%d" % (game.torps))
- elif not req or req == 8:
+ if not req or req == 8:
if damaged(DSHIELD):
- strcpy(s, _("DAMAGED,"))
+ s = _("DAMAGED,")
elif game.shldup:
- strcpy(s, _("UP,"))
+ s = _("UP,")
else:
- strcpy(s, _("DOWN,"))
+ s = _("DOWN,")
data = _(" %d%% %.1f units") \
% (int((100.0*game.shield)/game.inshld + 0.5), game.shield)
- prstat(_("Shields"), s)
- elif not req or req == 9:
+ prstat(_("Shields"), s+data)
+ if not req or req == 9:
prstat(_("Klingons Left"), "%d" \
% (game.state.remkl + game.state.remcom + game.state.nscrem))
- elif not req or req == 10:
+ if not req or req == 10:
if game.options & OPTION_WORLDS:
plnet = game.state.galaxy[game.quadrant.x][game.quadrant.y].planet
if plnet != NOPLANET and game.state.planets[plnet].inhabited:
if not game.state.galaxy[w.x][w.y].supernova and \
game.state.galaxy[w.x][w.y].klingons + klump <= MAXKLQUAD:
break
- game.state.galaxy[w.x][w.y].klingons += klump
+ game.state.galaxy[w.x][w.y].klingons += int(klump)
if krem <= 0:
break
# Position Klingon Commander Ships
prout(_(" YOU'LL NEED IT."))
waitfor()
newqad(False)
- if game.nenhere - iqhere-game.ithere:
+ if game.nenhere - (thing == game.quadrant) - game.ithere:
game.shldup = True
if game.neutz: # bad luck to start in a Romulan Neutral Zone
attack(False)
game.landed = False
game.ientesc = False
game.ithere = False
- global iqhere, iqengry
- iqhere = False
+ global iqengry
iqengry = False
game.iseenit = False
if game.iscate:
w = dropin(IHQUEST)
thing = randplace(GALSIZE)
game.nenhere += 1
- global iqhere
- iqhere = True
game.ks[game.nenhere] = w
game.kdist[game.nenhere] = game.kavgd[game.nenhere] = \
distance(game.sector, w)
def sortklings():
# sort Klingons by distance from us
# The author liked bubble sort. So we will use it. :-(
- if game.nenhere-iqhere-game.ithere < 2:
+ if game.nenhere-(thing==game.quadrant)-game.ithere < 2:
return
while True:
sw = False
k = 0
proutn(_("LEGAL COMMANDS ARE:"))
for key in commands:
- if ACCEPT(cmd):
+ if ACCEPT(key):
if k % 5 == 0:
skip(1)
proutn("%-12s " % key)
clrscr()
setwnd(message_window)
clrscr()
- cmd = citem.upper()
- if cmd not in commands:
+ candidates = filter(lambda x: x.startswith(citem.upper()),
+ commands)
+ if len(candidates) == 1:
+ cmd = candidates[0]
+ break
+ else:
listCommands()
continue
- commandhook(commands[i].name, True)
if cmd == "SRSCAN": # srscan
srscan()
elif cmd == "STATUS": # status
- status(0)
+ status()
elif cmd == "REQUEST": # status request
request()
elif cmd == "LRSCAN": # long range scan
# elif cmd == "VISUAL":
# visual() # perform visual scan
#endif
- commandhook(commands[i].name, False)
while True:
if game.alldone:
break # Game has ended
atover(True)
if __name__ == '__main__':
- global line, thing, game, idebug, iqhere, iqengry
+ global line, thing, game, idebug, iqengry
game = citem = aaitem = inqueue = None
line = ''
thing = coord()
- iqhere = iqengry = False
+ iqengry = False
game = gamestate()
idebug = 0
setwnd(fullscreen_window)
clrscr()
prelim()
- setup(needprompt=not line)
+ setup(needprompt=not inqueue)
if game.alldone:
score()
game.alldone = False