From: Eric S. Raymond Date: Fri, 17 Feb 2012 02:46:10 +0000 (-0500) Subject: Merge branch 'master' of ssh://git.berlios.de/gitroot/sst X-Git-Tag: 2.2~115 X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=commitdiff_plain;h=b039f9f202f3a7774e5daa92f8cd0ed9940045a8;hp=-c Merge branch 'master' of ssh://git.berlios.de/gitroot/sst --- b039f9f202f3a7774e5daa92f8cd0ed9940045a8 diff --combined sst.py index 4940817,35d1433..bf13aa9 --- a/sst.py +++ b/sst.py @@@ -13,7 -13,7 +13,7 @@@ on how to modify (and how not to modify """ import os, sys, math, curses, time, readline, cPickle, random, copy, gettext, getpass -version="2.0" +version="2.1" docpath = (".", "../doc", "/usr/share/doc/sst") @@@ -915,7 -915,7 +915,7 @@@ def doshield(shraise) action = "SHUP" else: scanner.chew() - return + return if action == "SHUP": # raise shields if game.shldup: prout(_("Shields already up.")) @@@ -2664,7 -2664,6 +2664,6 @@@ def selfdestruct() prout(_("SELF-DESTRUCT-SEQUENCE-WILL-BE-ABORTED")) skip(1) scanner.next() - scanner.chew() if game.passwd != scanner.token: prouts(_("PASSWORD-REJECTED;")) skip(1) @@@ -2692,11 -2691,9 +2691,9 @@@ def kaboom() skip(1) if len(game.enemies) != 0: whammo = 25.0 * game.energy - l=1 - while l <= len(game.enemies): + for l in range(len(game.enemies)): if game.enemies[l].power*game.enemies[l].kdist <= whammo: deadkl(game.enemies[l].location, game.quad[game.enemies[l].location.i][game.enemies[l].location.j], game.enemies[l].location) - l += 1 finish(FDILITHIUM) def killrate(): @@@ -3161,16 -3158,11 +3158,11 @@@ def skip(i) "Skip i lines. Pause game if this would cause a scrolling event." for dummy in range(i): if game.options & OPTION_CURSES: - (y, x) = curwnd.getyx() - (my, mx) = curwnd.getmaxyx() - if curwnd == message_window and y >= my - 2: - pause_game() - clrscr() - else: - try: - curwnd.move(y+1, 0) - except curses.error: - pass + (y, x) = curwnd.getyx() + try: + curwnd.move(y+1, 0) + except curses.error: + pass else: global linecount linecount += 1 @@@ -3182,6 -3174,11 +3174,11 @@@ def proutn(line): "Utter a line with no following line feed." if game.options & OPTION_CURSES: + (y, x) = curwnd.getyx() + (my, mx) = curwnd.getmaxyx() + if curwnd == message_window and y >= my - 2: + pause_game() + clrscr() curwnd.addstr(line) curwnd.refresh() else: @@@ -5338,10 -5335,21 +5335,21 @@@ def setup() game.nkinks = game.nhelp = game.casual = game.abandoned = 0 game.iscate = game.resting = game.imine = game.icrystl = game.icraft = False game.isatb = game.state.nplankl = 0 - game.state.starkl = game.state.basekl = 0 + game.state.starkl = game.state.basekl = game.state.nworldkl = 0 game.iscraft = "onship" game.landed = False game.alive = True + + # the galaxy + game.state.galaxy = fill2d(GALSIZE, lambda i_unused, j_unused: Quadrant()) + # the starchart + game.state.chart = fill2d(GALSIZE, lambda i_unused, j_unused: Page()) + + game.state.planets = [] # Planet information + game.state.baseq = [] # Base quadrant coordinates + game.state.kcmdr = [] # Commander quadrant coordinates + game.statekscmdr = Coord() # Supercommander quadrant coordinates + # Starchart is functional but we've never seen it game.lastchart = FOREVER # Put stars in the galaxy @@@ -5499,6 -5507,8 +5507,8 @@@ if game.state.nscrem: prout(_(" YOU'LL NEED IT.")) waitfor() + clrscr() + setwnd(message_window) newqad() if len(game.enemies) - (thing == game.quadrant) - (game.tholian != None): game.shldup = True @@@ -5511,8 -5521,9 +5521,9 @@@ def choose() game.tourn = game.length = 0 game.thawed = False game.skill = SKILL_NONE - if not scanner.inqueue: # Can start with command line options - proutn(_("Would you like a regular, tournament, or saved game? ")) + scanner.chew() + # if not scanner.inqueue: # Can start with command line options + proutn(_("Would you like a regular, tournament, or saved game? ")) scanner.next() if scanner.sees("tournament"): while scanner.next() == "IHEOL": @@@ -5768,54 -5779,55 +5779,55 @@@ def setpassword() # Code from sst.c begins here - commands = { - "SRSCAN": OPTION_TTY, - "STATUS": OPTION_TTY, - "REQUEST": OPTION_TTY, - "LRSCAN": OPTION_TTY, - "PHASERS": 0, - "TORPEDO": 0, - "PHOTONS": 0, - "MOVE": 0, - "SHIELDS": 0, - "DOCK": 0, - "DAMAGES": 0, - "CHART": 0, - "IMPULSE": 0, - "REST": 0, - "WARP": 0, - "SCORE": 0, - "SENSORS": OPTION_PLANETS, - "ORBIT": OPTION_PLANETS, - "TRANSPORT": OPTION_PLANETS, - "MINE": OPTION_PLANETS, - "CRYSTALS": OPTION_PLANETS, - "SHUTTLE": OPTION_PLANETS, - "PLANETS": OPTION_PLANETS, - "REPORT": 0, - "COMPUTER": 0, - "COMMANDS": 0, - "EMEXIT": 0, - "PROBE": OPTION_PROBE, - "SAVE": 0, - "FREEZE": 0, # Synonym for SAVE - "ABANDON": 0, - "DESTRUCT": 0, - "DEATHRAY": 0, - "DEBUG": 0, - "MAYDAY": 0, - "SOS": 0, # Synonym for MAYDAY - "CALL": 0, # Synonym for MAYDAY - "QUIT": 0, - "HELP": 0, - } + commands = [ + ("SRSCAN", OPTION_TTY), + ("STATUS", OPTION_TTY), + ("REQUEST", OPTION_TTY), + ("LRSCAN", OPTION_TTY), + ("PHASERS", 0), + ("TORPEDO", 0), + ("PHOTONS", 0), + ("MOVE", 0), + ("SHIELDS", 0), + ("DOCK", 0), + ("DAMAGES", 0), + ("CHART", 0), + ("IMPULSE", 0), + ("REST", 0), + ("WARP", 0), + ("SCORE", 0), + ("SENSORS", OPTION_PLANETS), + ("ORBIT", OPTION_PLANETS), + ("TRANSPORT", OPTION_PLANETS), + ("MINE", OPTION_PLANETS), + ("CRYSTALS", OPTION_PLANETS), + ("SHUTTLE", OPTION_PLANETS), + ("PLANETS", OPTION_PLANETS), + ("REPORT", 0), + ("COMPUTER", 0), + ("COMMANDS", 0), + ("EMEXIT", 0), + ("PROBE", OPTION_PROBE), + ("SAVE", 0), + ("FREEZE", 0), # Synonym for SAVE + ("ABANDON", 0), + ("DESTRUCT", 0), + ("DEATHRAY", 0), + ("DEBUG", 0), + ("MAYDAY", 0), + ("SOS", 0), # Synonym for MAYDAY + ("CALL", 0), # Synonym for MAYDAY + ("QUIT", 0), + ("HELP", 0), + ("", 0), + ] def listCommands(): "Generate a list of legal commands." prout(_("LEGAL COMMANDS ARE:")) emitted = 0 - for key in commands: - if not commands[key] or (commands[key] & game.options): + for (key, opt) in commands: + if not opt or (opt & game.options): proutn("%-12s " % key) emitted += 1 if emitted % 5 == 4: @@@ -5833,7 -5845,8 +5845,8 @@@ def helpme() setwnd(message_window) if key == "IHEOL": return - if scanner.token.upper() in commands or scanner.token == "ABBREV": + cmds = map(lambda x: x[0], commands) + if scanner.token.upper() in cmds or scanner.token.upper() == "ABBREV": break skip(1) listCommands() @@@ -5877,8 -5890,6 +5890,6 @@@ def makemoves(): "Command-interpretation loop." - clrscr() - setwnd(message_window) while True: # command loop drawmaps(1) while True: # get a command @@@ -5898,16 -5909,19 +5909,19 @@@ clrscr() setwnd(message_window) clrscr() - candidates = filter(lambda x: x.startswith(scanner.token.upper()), - commands) - if len(candidates) == 1: - cmd = candidates[0] - break - elif candidates and not (game.options & OPTION_PLAIN): - prout("Commands with prefix '%s': %s" % (scanner.token, " ".join(candidates))) - else: + abandon_passed = False + for (cmd, opt) in commands: + # commands after ABANDON cannot be abbreviated + if cmd == "ABANDON": + abandon_passed = True + if cmd == scanner.token.upper() or (not abandon_passed \ + and cmd.startswith(scanner.token.upper())): + break; + if cmd == "": listCommands() continue + else: + break; if cmd == "SRSCAN": # srscan srscan() elif cmd == "STATUS": # status @@@ -6355,5 -6369,3 +6369,5 @@@ if __name__ == '__main__' if logfp: logfp.close() print "" + +# End.