X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fsst.py;h=74dcbaa3aee8ab27ce8b09f73e4e642330a0c2ca;hp=635816e42e1cc910418ef1b450d86eaf104ac906;hb=29d86fb395ca01e4a4f65f02d67f5823a4ebba11;hpb=645f1a528a6490187abf34a044ffa50d8f137157 diff --git a/src/sst.py b/src/sst.py index 635816e..74dcbaa 100644 --- a/src/sst.py +++ b/src/sst.py @@ -180,7 +180,7 @@ more: the LRSCAN command is no longer needed. (Controlled by OPTION_AUTOSCAN and turned off if game type is "plain" or "almy".) """ -import os,sys,math,curses,time,atexit,readline,cPickle,random,getopt,copy +import os, sys, math, curses, time, readline, cPickle, random, copy SSTDOC = "/usr/share/doc/sst/sst.doc" DOC_NAME = "sst.doc" @@ -256,7 +256,7 @@ class coord: return math.sqrt((self.i - other.i)**2 + (self.j - other.j)**2) def bearing(self, other=None): if not other: other = coord(0, 0) - return 1.90985*math.atan2(self.i-other.i, self.j-other.j) + return 1.90985*math.atan2(self.j-other.j, self.i-other.i) def sgn(self): s = coord() if self.i == 0: @@ -1057,11 +1057,11 @@ def movetholian(): for i in range(QUADSIZE): if game.quad[0][i]!=IHWEB and game.quad[0][i]!=IHT: return - if game.quad[QUADSIZE][i]!=IHWEB and game.quad[QUADSIZE][i]!=IHT: + if game.quad[QUADSIZE-1][i]!=IHWEB and game.quad[QUADSIZE-1][i]!=IHT: return if game.quad[i][0]!=IHWEB and game.quad[i][0]!=IHT: return - if game.quad[i][QUADSIZE]!=IHWEB and game.quad[i][QUADSIZE]!=IHT: + if game.quad[i][QUADSIZE-1]!=IHWEB and game.quad[i][QUADSIZE-1]!=IHT: return # All plugged up -- Tholian splits game.quad[game.tholian.kloc.i][game.tholian.kloc.j]=IHWEB @@ -1330,7 +1330,7 @@ def torpedo(origin, course, dispersion, number, nburst): shoved = True elif iquad in (IHC, IHS, IHR, IHK): # Hit a regular enemy # find the enemy - if withprob(0.05): + if iquad in (IHC, IHS) and withprob(0.05): prout(crmena(True, iquad, "sector", w) + _(" uses anti-photon device;")) prout(_(" torpedo neutralized.")) return None @@ -1725,7 +1725,7 @@ def targetcheck(w): prout(_(" the Captain's psychological profile.\"")) scanner.chew() return None - return 1.90985932*math.atan2(delta.j, delta.i) + return delta.bearing() def photon(): "Launch photon torpedo." @@ -3432,7 +3432,7 @@ def prouts(line): time.sleep(0.03) proutn(c) if game.options & OPTION_CURSES: - wrefresh(curwnd) + curwnd.refresh() else: sys.stdout.flush() if not replayfp or replayfp.closed: @@ -3926,8 +3926,8 @@ def getcourse(isprobe, akey): prout(_("Ensign Chekov- \"Course laid in, Captain.\"")) # the actual deltas get computed here delta = coord() - delta.i = dquad.j-game.quadrant.j + 0.1*(dsect.j-game.sector.j) - delta.j = game.quadrant.i-dquad.i + 0.1*(game.sector.i-dsect.i) + delta.j = dquad.j-game.quadrant.j + 0.1*(dsect.j-game.sector.j) + delta.i = game.quadrant.i-dquad.i + 0.1*(game.sector.i-dsect.i) else: # manual while key == "IHEOL": proutn(_("X and Y displacements- ")) @@ -6064,12 +6064,14 @@ commands = { def listCommands(): "Generate a list of legal commands." - proutn(_("LEGAL COMMANDS ARE:")) - for (k, key) in enumerate(commands): + prout(_("LEGAL COMMANDS ARE:")) + emitted = 0 + for key in commands: if not commands[key] or (commands[key] & game.options): - if k % 5 == 0: + proutn("%-12s " % key) + emitted += 1 + if emitted % 5 == 4: skip(1) - proutn("%-12s " % key) skip(1) def helpme(): @@ -6515,6 +6517,7 @@ def debugme(): atover(True) if __name__ == '__main__': + import getopt, socket try: global line, thing, game, idebug game = None @@ -6566,6 +6569,8 @@ if __name__ == '__main__': if logfp: logfp.write("# seed %s\n" % seed) logfp.write("# options %s\n" % " ".join(arguments)) + logfp.write("# recorded by %s@%s on %s\n" % \ + (os.getenv("LOGNAME"),socket.gethostname(),time.ctime())) random.seed(seed) scanner = sstscanner() map(scanner.append, arguments)