- logfp = open("/usr/tmp/sst-input.log", "w")
- except IOError:
- sys.stderr.write("sst: warning, can't open logfile\n")
- if logfp:
- #setlinebuf(logfp)
- logfp.write("seed %d\n" % (seed))
- random.seed(seed)
-
- iostart()
- if arguments:
- inqueue = arguments
- else:
- inqueue = None
-
- while True: # Play a game
- setwnd(fullscreen_window)
- clrscr()
- prelim()
- setup(needprompt=not inqueue)
- if game.alldone:
- score()
- game.alldone = False
- else:
- makemoves()
- skip(1)
- stars()
- skip(1)
-
- if game.tourn and game.alldone:
- proutn(_("Do you want your score recorded?"))
- if ja() == True:
- chew2()
- freeze(False)
- proutn(_("Do you want to play again? "))
- if not ja():
- break
- skip(1)
- prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
- raise SysExit, 0
+ global line, thing, game, idebug, iqengry
+ game = citem = aaitem = inqueue = None
+ line = ''
+ thing = coord()
+ iqengry = False
+ game = gamestate()
+ idebug = 0
+ game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_PLAIN | OPTION_ALMY)
+ # Disable curses mode until the game logic is working.
+ # if os.getenv("TERM"):
+ # game.options |= OPTION_CURSES | OPTION_SHOWME
+ # else:
+ game.options |= OPTION_TTY
+ seed = int(time.time())
+ (options, arguments) = getopt.getopt(sys.argv[1:], "r:tx")
+ for (switch, val) in options:
+ if switch == '-r':
+ try:
+ replayfp = open(val, "r")
+ except IOError:
+ sys.stderr.write("sst: can't open replay file %s\n" % val)
+ raise SystemExit, 1
+ try:
+ line = replayfp.readline().strip()
+ (leader, key, seed) = line.split()
+ seed = eval(seed)
+ sys.stderr.write("sst2k: seed set to %s\n" % seed)
+ line = replayfp.readline().strip()
+ arguments += line.split()[2:]
+ except ValueError:
+ sys.stderr.write("sst: replay file %s is ill-formed\n"% val)
+ os.exit(1)
+ game.options |= OPTION_TTY
+ game.options &=~ OPTION_CURSES
+ elif switch == '-t':
+ game.options |= OPTION_TTY
+ game.options &=~ OPTION_CURSES
+ elif switch == '-x':
+ idebug = True
+ else:
+ sys.stderr.write("usage: sst [-t] [-x] [startcommand...].\n")
+ os.exit(0)
+ # where to save the input in case of bugs
+ try:
+ logfp = open("/usr/tmp/sst-input.log", "w")
+ except IOError:
+ sys.stderr.write("sst: warning, can't open logfile\n")
+ if logfp:
+ logfp.write("# seed %s\n" % seed)
+ logfp.write("# options %s\n" % " ".join(arguments))
+ random.seed(seed)
+ iostart()
+ if arguments:
+ inqueue = arguments
+ else:
+ inqueue = None
+ while True: # Play a game
+ setwnd(fullscreen_window)
+ clrscr()
+ prelim()
+ setup(needprompt=not inqueue)
+ if game.alldone:
+ score()
+ game.alldone = False
+ else:
+ makemoves()
+ skip(1)
+ stars()
+ skip(1)
+ if game.tourn and game.alldone:
+ proutn(_("Do you want your score recorded?"))
+ if ja() == True:
+ chew2()
+ freeze(False)
+ chew()
+ proutn(_("Do you want to play again? "))
+ if not ja():
+ break
+ skip(1)
+ prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
+ raise SystemExit, 0
+ except KeyboardInterrupt:
+ print""
+ pass