+ prout(_("Stardate %d.") % int(game.state.date))
+ skip(1)
+ prout(_("%d Klingons.") % (game.inkling + game.incom + game.inscom))
+ prout(_("An unknown number of Romulans."))
+ if game.state.nscrem:
+ prout(_("And one (GULP) Super-Commander."))
+ prout(_("%d stardates.") % int(game.intime))
+ proutn(_("%d starbases in ") % game.inbase)
+ for i in range(game.inbase):
+ proutn(`game.state.baseq[i]`)
+ proutn(" ")
+ skip(2)
+ proutn(_("The Enterprise is currently in Quadrant %s") % game.quadrant)
+ proutn(_(" Sector %s") % game.sector)
+ skip(2)
+ prout(_("Good Luck!"))
+ if game.state.nscrem:
+ prout(_(" YOU'LL NEED IT."))
+ waitfor()
+ newqad(False)
+ if game.nenhere - (thing == game.quadrant) - (game.tholian != None):
+ game.shldup = True
+ if game.neutz: # bad luck to start in a Romulan Neutral Zone
+ attack(torps_ok=False)
+
+def choose(needprompt):
+ # choose your game type
+ global thing
+ while True:
+ game.tourn = 0
+ game.thawed = False
+ game.skill = SKILL_NONE
+ game.length = 0
+ if needprompt: # Can start with command line options
+ proutn(_("Would you like a regular, tournament, or saved game? "))
+ scan()
+ if len(citem)==0: # Try again
+ continue
+ if isit("tournament"):
+ while scan() == IHEOL:
+ proutn(_("Type in tournament number-"))
+ if aaitem == 0:
+ chew()
+ continue # We don't want a blank entry
+ game.tourn = int(round(aaitem))
+ random.seed(aaitem)
+ if logfp:
+ logfp.write("# random.seed(%d)\n" % aaitem)
+ break
+ if isit("saved") or isit("frozen"):
+ if thaw():
+ continue
+ chew()
+ if game.passwd == None:
+ continue
+ if not game.alldone:
+ game.thawed = True # No plaque if not finished
+ report()
+ waitfor()
+ return True
+ if isit("regular"):
+ break
+ proutn(_("What is \"%s\"?"), citem)
+ chew()
+ while game.length==0 or game.skill==SKILL_NONE:
+ if scan() == IHALPHA:
+ if isit("short"):
+ game.length = 1
+ elif isit("medium"):
+ game.length = 2
+ elif isit("long"):
+ game.length = 4
+ elif isit("novice"):
+ game.skill = SKILL_NOVICE
+ elif isit("fair"):
+ game.skill = SKILL_FAIR
+ elif isit("good"):
+ game.skill = SKILL_GOOD
+ elif isit("expert"):
+ game.skill = SKILL_EXPERT
+ elif isit("emeritus"):
+ game.skill = SKILL_EMERITUS
+ else:
+ proutn(_("What is \""))
+ proutn(citem)
+ prout("\"?")
+ else:
+ chew()
+ if game.length==0:
+ proutn(_("Would you like a Short, Medium, or Long game? "))
+ elif game.skill == SKILL_NONE:
+ proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "))
+ # Choose game options -- added by ESR for SST2K
+ if scan() != IHALPHA:
+ chew()
+ proutn(_("Choose your game style (or just press enter): "))
+ scan()
+ if isit("plain"):
+ # Approximates the UT FORTRAN version.
+ game.options &=~ (OPTION_THOLIAN | OPTION_PLANETS | OPTION_THINGY | OPTION_PROBE | OPTION_RAMMING | OPTION_MVBADDY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
+ game.options |= OPTION_PLAIN
+ elif isit("almy"):
+ # Approximates Tom Almy's version.
+ game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
+ game.options |= OPTION_ALMY
+ elif isit("fancy"):
+ pass
+ elif len(citem):
+ proutn(_("What is \"%s\"?") % citem)
+ setpassword()
+ if game.passwd == "debug":
+ idebug = True
+ fputs("=== Debug mode enabled\n", sys.stdout)
+
+ # Use parameters to generate initial values of things
+ game.damfac = 0.5 * game.skill
+ game.state.rembase = randrange(BASEMIN, BASEMAX+1)
+ game.inbase = game.state.rembase
+ game.inplan = 0
+ if game.options & OPTION_PLANETS:
+ game.inplan += randrange(MAXUNINHAB/2, MAXUNINHAB+1)
+ if game.options & OPTION_WORLDS:
+ game.inplan += int(NINHAB)
+ game.state.nromrem = game.inrom = randrange(2 *game.skill)
+ game.state.nscrem = game.inscom = (game.skill > SKILL_FAIR)
+ game.state.remtime = 7.0 * game.length
+ game.intime = game.state.remtime
+ game.state.remkl = game.inkling = 2.0*game.intime*((game.skill+1 - 2*randreal())*game.skill*0.1+.15)
+ game.incom = int(game.skill + 0.0625*game.inkling*randreal())
+ game.state.remcom = min(10, game.incom)
+ game.incom = game.state.remcom
+ game.state.remres = (game.inkling+4*game.incom)*game.intime
+ game.inresor = game.state.remres
+ if game.inkling > 50:
+ game.state.rembase += 1
+ game.inbase = game.state.rembase
+ return False
+
+def dropin(iquad=None):
+ # drop a feature on a random dot in the current quadrant
+ w = coord()
+ while True:
+ w = randplace(QUADSIZE)
+ if game.quad[w.x][w.y] == IHDOT:
+ break
+ if iquad is not None:
+ game.quad[w.x][w.y] = iquad
+ return w
+
+def newcnd():
+ # update our alert status
+ game.condition = "green"
+ if game.energy < 1000.0:
+ game.condition = "yellow"
+ if game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons or game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans:
+ game.condition = "red"
+ if not game.alive:
+ game.condition="dead"
+
+def newkling():
+ # drop new Klingon into current quadrant
+ return enemy(IHK, loc=dropin(), power=randreal(300,450)+25.0*game.skill)
+
+def newqad(shutup):
+ # set up a new state of quadrant, for when we enter or re-enter it
+ w = coord()
+ game.justin = True
+ game.klhere = 0
+ game.comhere = False
+ game.ishere = False
+ game.irhere = 0
+ game.iplnet = 0
+ game.nenhere = 0
+ game.neutz = False
+ game.inorbit = False
+ game.landed = False
+ game.ientesc = False
+ game.iseenit = False
+ if game.iscate:
+ # Attempt to escape Super-commander, so tbeam back!
+ game.iscate = False
+ game.ientesc = True
+ q = game.state.galaxy[game.quadrant.x][game.quadrant.y]
+ # cope with supernova
+ if q.supernova:
+ return
+ game.klhere = q.klingons
+ game.irhere = q.romulans
+ game.nenhere = game.klhere + game.irhere
+ # Position Starship
+ game.quad[game.sector.x][game.sector.y] = game.ship
+ game.enemies = []
+ if q.klingons:
+ # Position ordinary Klingons
+ for i in range(game.klhere):
+ newkling()
+ # If we need a commander, promote a Klingon
+ for i in range(game.state.remcom):
+ if game.state.kcmdr[i] == game.quadrant:
+ e = game.enemies[game.klhere-1]
+ game.quad[e.kloc.x][e.kloc.y] = IHC
+ e.kpower = randreal(950,1350) + 50.0*game.skill
+ game.comhere = True
+ break
+ # If we need a super-commander, promote a Klingon
+ if game.quadrant == game.state.kscmdr:
+ e = game.enemies[0]
+ game.quad[e.kloc.x][e.kloc.y] = IHS
+ e.kpower = randreal(1175.0, 1575.0) + 125.0*game.skill
+ game.iscate = (game.state.remkl > 1)
+ game.ishere = True
+ # Put in Romulans if needed
+ for i in range(game.klhere, game.nenhere):
+ enemy(IHR, loc=dropin(), power=randreal(400.0,850.0)+50.0*game.skill)
+ # If quadrant needs a starbase, put it in
+ if q.starbase:
+ game.base = dropin(IHB)
+ # If quadrant needs a planet, put it in
+ if q.planet:
+ game.iplnet = q.planet
+ if not q.planet.inhabited:
+ game.plnet = dropin(IHP)
+ else:
+ game.plnet = dropin(IHW)
+ # Check for condition
+ newcnd()
+ # Check for RNZ
+ if game.irhere > 0 and game.klhere == 0:
+ game.neutz = True
+ if not damaged(DRADIO):
+ skip(1)
+ prout(_("LT. Uhura- \"Captain, an urgent message."))
+ prout(_(" I'll put it on audio.\" CLICK"))
+ skip(1)
+ prout(_("INTRUDER! YOU HAVE VIOLATED THE ROMULAN NEUTRAL ZONE."))
+ prout(_("LEAVE AT ONCE, OR YOU WILL BE DESTROYED!"))
+ if shutup==0:
+ # Put in THING if needed
+ if thing == game.quadrant:
+ enemy(symbol=IHQUEST, loc=dropin(),
+ power=randreal(6000,6500.0)+250.0*game.skill)
+ if not damaged(DSRSENS):
+ skip(1)
+ prout(_("Mr. Spock- \"Captain, this is most unusual."))
+ prout(_(" Please examine your short-range scan.\""))
+ # Decide if quadrant needs a Tholian; lighten up if skill is low
+ if game.options & OPTION_THOLIAN:
+ if (game.skill < SKILL_GOOD and withprob(0.02)) or \
+ (game.skill == SKILL_GOOD and withprob(0.05)) or \
+ (game.skill > SKILL_GOOD and withprob(0.08)):
+ w = coord()
+ while True:
+ w.x = withprob(0.5) * (QUADSIZE-1)
+ w.y = withprob(0.5) * (QUADSIZE-1)
+ if game.quad[w.x][w.y] == IHDOT:
+ break
+ game.tholian = enemy(symbol=IHT, loc=w,
+ power=randrange(100, 500) + 25.0*game.skill)
+ # Reserve unoccupied corners
+ if game.quad[0][0]==IHDOT:
+ game.quad[0][0] = 'X'
+ if game.quad[0][QUADSIZE-1]==IHDOT:
+ game.quad[0][QUADSIZE-1] = 'X'
+ if game.quad[QUADSIZE-1][0]==IHDOT:
+ game.quad[QUADSIZE-1][0] = 'X'
+ if game.quad[QUADSIZE-1][QUADSIZE-1]==IHDOT:
+ game.quad[QUADSIZE-1][QUADSIZE-1] = 'X'
+ game.enemies.sort(lambda x, y: cmp(x.kdist, y.kdist))
+ # And finally the stars
+ for i in range(q.stars):
+ dropin(IHSTAR)
+ # Put in a few black holes
+ for i in range(1, 3+1):
+ if withprob(0.5):
+ dropin(IHBLANK)
+ # Take out X's in corners if Tholian present
+ if game.tholian:
+ if game.quad[0][0]=='X':
+ game.quad[0][0] = IHDOT
+ if game.quad[0][QUADSIZE-1]=='X':
+ game.quad[0][QUADSIZE-1] = IHDOT
+ if game.quad[QUADSIZE-1][0]=='X':
+ game.quad[QUADSIZE-1][0] = IHDOT
+ if game.quad[QUADSIZE-1][QUADSIZE-1]=='X':
+ game.quad[QUADSIZE-1][QUADSIZE-1] = IHDOT
+
+def setpassword():
+ # set the self-destruct password
+ if game.options & OPTION_PLAIN:
+ while True:
+ chew()
+ proutn(_("Please type in a secret password- "))
+ scan()
+ game.passwd = citem
+ if game.passwd != None:
+ break
+ else:
+ game.passwd = ""
+ for i in range(3):
+ game.passwd += chr(ord('a')+randrange(26))
+
+# 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,
+ "SEED": 0,
+ "VISUAL": 0,
+}
+
+def ACCEPT(cmd): return (not commands[cmd] or (commands[cmd] & game.options))
+
+def listCommands():
+ # generate a list of legal commands
+ k = 0
+ proutn(_("LEGAL COMMANDS ARE:"))
+ for key in commands:
+ if ACCEPT(key):
+ if k % 5 == 0:
+ skip(1)
+ proutn("%-12s " % key)
+ k += 1
+ skip(1)
+
+def helpme():
+ # browse on-line help
+ # Give help on commands
+ key = scan()
+ while True:
+ if key == IHEOL:
+ setwnd(prompt_window)
+ proutn(_("Help on what command? "))
+ key = scan()
+ setwnd(message_window)
+ if key == IHEOL:
+ return
+ if citem in commands or citem == "ABBREV":
+ break
+ skip(1)
+ listCommands()
+ key = IHEOL
+ chew()
+ skip(1)
+ cmd = citem.upper()
+ try:
+ fp = open(SSTDOC, "r")
+ except IOError:
+ try:
+ fp = open(DOC_NAME, "r")
+ except IOError:
+ prout(_("Spock- \"Captain, that information is missing from the"))
+ proutn(_(" computer. You need to find "))
+ proutn(DOC_NAME)
+ prout(_(" and put it in the"))
+ proutn(_(" current directory or to "))
+ proutn(SSTDOC)
+ prout(".\"")
+ #
+ # This used to continue: "You need to find SST.DOC and put
+ # it in the current directory."
+ #
+ return
+ while True:
+ linebuf = fp.readline()
+ if linebuf == '':
+ prout(_("Spock- \"Captain, there is no information on that command.\""))
+ fp.close()
+ return
+ if linebuf[0] == '%' and linebuf[1] == '%' and linebuf[2] == ' ':
+ linebuf = linebuf[3:].strip()
+ if cmd == linebuf:
+ break
+ skip(1)
+ prout(_("Spock- \"Captain, I've found the following information:\""))
+ skip(1)
+ while linebuf in fp:
+ if "******" in linebuf:
+ break
+ proutn(linebuf)
+ fp.close()
+
+def makemoves():
+ # command-interpretation loop
+ v = 0
+ clrscr()
+ setwnd(message_window)
+ while True: # command loop
+ drawmaps(1)
+ while True: # get a command
+ hitme = False
+ game.justin = False
+ game.optime = 0.0
+ chew()
+ setwnd(prompt_window)
+ clrscr()
+ proutn("COMMAND> ")
+ if scan() == IHEOL:
+ if game.options & OPTION_CURSES:
+ makechart()
+ continue
+ game.ididit = False
+ clrscr()
+ setwnd(message_window)
+ clrscr()
+ candidates = filter(lambda x: x.startswith(citem.upper()),
+ commands)
+ if len(candidates) == 1:
+ cmd = candidates[0]
+ break
+ elif candidates and not (game.options & OPTION_PLAIN):
+ prout("Commands with that prefix: " + " ".join(candidates))
+ else:
+ listCommands()
+ continue
+ if cmd == "SRSCAN": # srscan
+ srscan()
+ elif cmd == "STATUS": # status
+ status()
+ elif cmd == "REQUEST": # status request
+ request()
+ elif cmd == "LRSCAN": # long range scan
+ lrscan(silent=False)
+ elif cmd == "PHASERS": # phasers
+ phasers()
+ if game.ididit:
+ hitme = True
+ elif cmd == "TORPEDO": # photon torpedos
+ photon()
+ if game.ididit:
+ hitme = True
+ elif cmd == "MOVE": # move under warp
+ warp(False)
+ elif cmd == "SHIELDS": # shields
+ doshield(shraise=False)
+ if game.ididit:
+ hitme = True
+ game.shldchg = False
+ elif cmd == "DOCK": # dock at starbase
+ dock(True)
+ if game.ididit:
+ attack(torps_ok=False)
+ elif cmd == "DAMAGES": # damage reports
+ damagereport()
+ elif cmd == "CHART": # chart
+ makechart()
+ elif cmd == "IMPULSE": # impulse
+ impulse()
+ elif cmd == "REST": # rest
+ os.wait()
+ if game.ididit:
+ hitme = True
+ elif cmd == "WARP": # warp
+ setwarp()
+ elif cmd == "SCORE": # score
+ score()
+ elif cmd == "SENSORS": # sensors
+ sensor()
+ elif cmd == "ORBIT": # orbit
+ orbit()
+ if game.ididit:
+ hitme = True
+ elif cmd == "TRANSPORT": # transport "beam"
+ beam()
+ elif cmd == "MINE": # mine
+ mine()
+ if game.ididit:
+ hitme = True
+ elif cmd == "CRYSTALS": # crystals
+ usecrystals()
+ if game.ididit:
+ hitme = True
+ elif cmd == "SHUTTLE": # shuttle
+ shuttle()
+ if game.ididit:
+ hitme = True
+ elif cmd == "PLANETS": # Planet list
+ survey()
+ elif cmd == "REPORT": # Game Report
+ report()
+ elif cmd == "COMPUTER": # use COMPUTER!
+ eta()
+ elif cmd == "COMMANDS":
+ listCommands()
+ elif cmd == "EMEXIT": # Emergency exit
+ clrscr() # Hide screen
+ freeze(True) # forced save
+ raise SysExit,1 # And quick exit
+ elif cmd == "PROBE":
+ probe() # Launch probe
+ if game.ididit:
+ hitme = True
+ elif cmd == "ABANDON": # Abandon Ship
+ abandon()
+ elif cmd == "DESTRUCT": # Self Destruct
+ selfdestruct()
+ elif cmd == "SAVE": # Save Game
+ freeze(False)
+ clrscr()
+ if game.skill > SKILL_GOOD:
+ prout(_("WARNING--Saved games produce no plaques!"))
+ elif cmd == "DEATHRAY": # Try a desparation measure
+ deathray()
+ if game.ididit:
+ hitme = True
+ elif cmd == "DEBUGCMD": # What do we want for debug???
+ debugme()
+ elif cmd == "MAYDAY": # Call for help
+ mayday()
+ if game.ididit:
+ hitme = True
+ elif cmd == "QUIT":
+ game.alldone = True # quit the game
+ elif cmd == "HELP":
+ helpme() # get help
+ while True:
+ if game.alldone:
+ break # Game has ended
+ if game.optime != 0.0:
+ events()
+ if game.alldone:
+ break # Events did us in
+ if game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova:
+ atover(False)
+ continue
+ if hitme and not game.justin:
+ attack(torps_ok=True)
+ if game.alldone:
+ break
+ if game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova:
+ atover(False)
+ hitme = True
+ continue
+ break
+ if game.alldone:
+ break
+ if idebug:
+ prout("=== Ending")
+
+def cramen(cmd):
+ # return an enemy
+ if cmd == IHR: s = _("Romulan")
+ elif cmd == IHK: s = _("Klingon")
+ elif cmd == IHC: s = _("Commander")
+ elif cmd == IHS: s = _("Super-commander")
+ elif cmd == IHSTAR: s = _("Star")
+ elif cmd == IHP: s = _("Planet")
+ elif cmd == IHB: s = _("Starbase")
+ elif cmd == IHBLANK: s = _("Black hole")
+ elif cmd == IHT: s = _("Tholian")
+ elif cmd == IHWEB: s = _("Tholian web")
+ elif cmd == IHQUEST: s = _("Stranger")
+ elif cmd == IHW: s = _("Inhabited World")
+ else: s = "Unknown??"
+ proutn(s)
+
+def crmena(stars, enemy, loctype, w):
+ # print an enemy and his location
+ if stars:
+ proutn("***")
+ cramen(enemy)
+ proutn(_(" at "))
+ buf = ""
+ if loctype == "quadrant":
+ buf = _("Quadrant ")
+ elif loctype == "sector":
+ buf = _("Sector ")
+ proutn(buf + `w`)
+
+def crmshp():
+ # print our ship name
+ if game.ship == IHE:
+ s = _("Enterprise")
+ elif game.ship == IHF:
+ s = _("Faerie Queene")
+ else:
+ s = "Ship???"
+ proutn(s)
+
+def stars():
+ # print a line of stars
+ prouts("******************************************************")
+ skip(1)
+
+def expran(avrage):
+ return -avrage*math.log(1e-7 + randreal())
+
+def randplace(size):
+ # choose a random location
+ w = coord()
+ w.x = randrange(size)
+ w.y = randrange(size)
+ return w
+
+def chew():
+ # Demand input for next scan
+ global inqueue
+ inqueue = None
+
+def chew2():
+ # return IHEOL next time
+ global inqueue
+ inqueue = []
+
+def scan():
+ # Get a token from the user
+ global inqueue, line, citem, aaitem
+ aaitem = 0.0
+ citem = ''
+
+ # Read a line if nothing here
+ if inqueue == None:
+ line = cgetline()
+ if curwnd==prompt_window:
+ clrscr()
+ setwnd(message_window)
+ clrscr()
+ # Skip leading white space
+ line = line.lstrip()
+ if line:
+ inqueue = line.split()
+ else:
+ inqueue = []
+ return IHEOL
+ elif not inqueue:
+ return IHEOL
+ # From here on in it's all looking at the queue
+ citem = inqueue.pop(0)
+ if citem == IHEOL:
+ return IHEOL
+ try:
+ aaitem = float(citem)
+ return IHREAL
+ except ValueError:
+ pass
+ # Treat as alpha
+ citem = citem.lower()
+ return IHALPHA
+
+def ja():
+ # yes-or-no confirmation
+ chew()
+ while True:
+ scan()
+ chew()
+ if citem == 'y':
+ return True
+ if citem == 'n':
+ return False
+ proutn(_("Please answer with \"y\" or \"n\": "))
+
+def huh():
+ # complain about unparseable input
+ chew()
+ skip(1)
+ prout(_("Beg your pardon, Captain?"))
+
+def isit(s):
+ # compares s to citem and returns true if it matches to the length of s
+ return s.startswith(citem)
+
+def debugme():
+ # access to the internals for debugging
+ proutn("Reset levels? ")
+ if ja() == True:
+ if game.energy < game.inenrg:
+ game.energy = game.inenrg
+ game.shield = game.inshld
+ game.torps = game.intorps
+ game.lsupres = game.inlsr
+ proutn("Reset damage? ")
+ if ja() == True:
+ for i in range(NDEVICES):
+ if game.damage[i] > 0.0:
+ game.damage[i] = 0.0
+ proutn("Toggle debug flag? ")
+ if ja() == True:
+ idebug = not idebug
+ if idebug:
+ prout("Debug output ON")
+ else:
+ prout("Debug output OFF")
+ proutn("Cause selective damage? ")
+ if ja() == True:
+ for i in range(NDEVICES):
+ proutn("Kill ")
+ proutn(device[i])
+ proutn("? ")
+ chew()
+ key = scan()
+ if key == IHALPHA and isit("y"):
+ game.damage[i] = 10.0
+ proutn("Examine/change events? ")
+ if ja() == True:
+ ev = event()
+ w = coord()
+ legends = {
+ FSNOVA: "Supernova ",
+ FTBEAM: "T Beam ",
+ FSNAP: "Snapshot ",
+ FBATTAK: "Base Attack ",
+ FCDBAS: "Base Destroy ",
+ FSCMOVE: "SC Move ",
+ FSCDBAS: "SC Base Destroy ",
+ FDSPROB: "Probe Move ",
+ FDISTR: "Distress Call ",
+ FENSLV: "Enslavement ",
+ FREPRO: "Klingon Build ",
+ }
+ for i in range(1, NEVENTS):
+ proutn(legends[i])
+ if is_scheduled(i):
+ proutn("%.2f" % (scheduled(i)-game.state.date))
+ if i == FENSLV or i == FREPRO:
+ ev = findevent(i)
+ proutn(" in %s" % ev.quadrant)
+ else:
+ proutn("never")
+ proutn("? ")
+ chew()
+ key = scan()
+ if key == 'n':
+ unschedule(i)
+ chew()
+ elif key == IHREAL:
+ ev = schedule(i, aaitem)
+ if i == FENSLV or i == FREPRO:
+ chew()
+ proutn("In quadrant- ")
+ key = scan()
+ # IHEOL says to leave coordinates as they are
+ if key != IHEOL:
+ if key != IHREAL:
+ prout("Event %d canceled, no x coordinate." % (i))
+ unschedule(i)
+ continue
+ w.x = int(round(aaitem))
+ key = scan()
+ if key != IHREAL:
+ prout("Event %d canceled, no y coordinate." % (i))
+ unschedule(i)
+ continue
+ w.y = int(round(aaitem))
+ ev.quadrant = w
+ chew()
+ proutn("Induce supernova here? ")
+ if ja() == True:
+ game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova = True
+ atover(True)
+
+if __name__ == '__main__':
+ try:
+ global line, thing, game, idebug
+ game = citem = aaitem = inqueue = None
+ line = ''
+ thing = coord()
+ thing.angry = 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)
+ raise SystemExit(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")
+ raise SystemExit, 1
+ # 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