X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.py;h=724674ad24f9f51e5ca2c08dcb221fcdeb65397b;hp=f731668af5e908420807f0ec6549521219a70e2c;hb=abf770449f233ca6c9f3941b1083cff3ac74f87a;hpb=a4c1b79ca0ab92629a0dfa6c6e180bd5d9971e58 diff --git a/sst.py b/sst.py index f731668..724674a 100755 --- a/sst.py +++ b/sst.py @@ -386,7 +386,7 @@ class Gamestate: # He says the existing expression is prone to divide-by-zero errors # after killing the last klingon when score is shown -- perhaps also # if the only remaining klingon is SCOM. - game.state.remtime = game.state.remres/(game.state.remkl + 4*len(game.state.kcmdr)) + self.state.remtime = self.state.remres/(self.state.remkl + 4*len(self.state.kcmdr)) FWON = 0 FDEPLETE = 1 @@ -1099,7 +1099,8 @@ def torpedo(origin, bearing, dispersion, number, nburst): if iquad == '.': continue # hit something - if not damaged(DSRSENS) or game.condition == "docked": + setwnd(message_window) + if not damaged(DSRSENS) or game.condition == "docked": skip(1) # start new line after text track if iquad in ('E', 'F'): # Hit our ship skip(1) @@ -1662,7 +1663,8 @@ def hittem(hits): "Register a phaser hit on Klingons and Romulans." w = Coord() skip(1) - for (kk, wham) in enumerate(hits): + kk = 0 + for wham in hits: if wham == 0: continue dustfac = randreal(0.9, 1.0) @@ -2492,7 +2494,7 @@ def nova(nov): if iquad == 'P': game.state.nplankl += 1 else: - game.state.worldkl += 1 + game.state.nworldkl += 1 prout(crmena(True, 'B', "sector", neighbor) + _(" destroyed.")) game.iplnet.pclass = "destroyed" game.iplnet = None @@ -3184,7 +3186,8 @@ def pause_game(): global linecount sys.stdout.write('\n') proutn(prompt) - raw_input() + if not replayfp: + raw_input() sys.stdout.write('\n' * rows) linecount = 0 @@ -3213,6 +3216,9 @@ def proutn(line): if curwnd == message_window and y >= my - 2: pause_game() clrscr() + # Uncomment this to debug curses problems + if logfp: + logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(line))) curwnd.addstr(line) curwnd.refresh() else: @@ -3262,8 +3268,31 @@ def setwnd(wnd): "Change windows -- OK for this to be a no-op in tty mode." global curwnd if game.options & OPTION_CURSES: + # Uncomment this to debug curses problems + if logfp: + if wnd == fullscreen_window: + legend = "fullscreen" + elif wnd == srscan_window: + legend = "srscan" + elif wnd == report_window: + legend = "report" + elif wnd == status_window: + legend = "status" + elif wnd == lrscan_window: + legend = "lrscan" + elif wnd == message_window: + legend = "message" + elif wnd == prompt_window: + legend = "prompt" + else: + legend = "unknown" + logfp.write("#curses: setwnd(%s)\n" % legend) curwnd = wnd - curses.curs_set(wnd == fullscreen_window or wnd == message_window or wnd == prompt_window) + # Some curses implementations get confused when you try this. + try: + curses.curs_set(wnd in (fullscreen_window, message_window, prompt_window)) + except curses.error: + pass def clreol(): "Clear to end of line -- can be a no-op in tty mode" @@ -6318,6 +6347,7 @@ if __name__ == '__main__': game.options |= OPTION_TTY seed = int(time.time()) (options, arguments) = getopt.getopt(sys.argv[1:], "r:s:txV") + replay = False for (switch, val) in options: if switch == '-r': try: @@ -6327,11 +6357,12 @@ if __name__ == '__main__': raise SystemExit, 1 try: line = replayfp.readline().strip() - (leader, key, seed) = line.split() + (leader, __, seed) = line.split() seed = eval(seed) sys.stderr.write("sst2k: seed set to %s\n" % seed) line = replayfp.readline().strip() arguments += line.split()[2:] + replay = True except ValueError: sys.stderr.write("sst: replay file %s is ill-formed\n"% val) raise SystemExit(1) @@ -6380,6 +6411,8 @@ if __name__ == '__main__': game.alldone = False else: makemoves() + if replay: + break skip(1) stars() skip(1)