X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.py;h=234d37ba9b1d324c4f72040d73241c15db7eda62;hp=ea8d7c6eaf1a5b1928e8461f8ffe59f50844b86b;hb=467b74d816d5376c9c6bd66f20cfe6f740d2ab8b;hpb=b51fd3a5d643134a0ff5a3b1ab1f5f4eaa4cb92b diff --git a/sst.py b/sst.py index ea8d7c6..234d37b 100755 --- a/sst.py +++ b/sst.py @@ -261,12 +261,12 @@ DDSP = 15 DCLOAK = 16 NDEVICES = 17 # Number of devices -SKILL_NONE = 0 -SKILL_NOVICE = 1 -SKILL_FAIR = 2 -SKILL_GOOD = 3 -SKILL_EXPERT = 4 -SKILL_EMERITUS = 5 +SKILL_NONE = 0 +SKILL_NOVICE = 1 +SKILL_FAIR = 2 +SKILL_GOOD = 3 +SKILL_EXPERT = 4 +SKILL_EMERITUS = 5 def damaged(dev): return (game.damage[dev] != 0.0) @@ -274,8 +274,8 @@ def communicating(): return not damaged(DRADIO) or game.condition=="docked" # Define future events -FSPY = 0 # Spy event happens always (no future[] entry) - # can cause SC to tractor beam Enterprise +FSPY = 0 # Spy event happens always (no future[] entry) + # can cause SC to tractor beam Enterprise FSNOVA = 1 # Supernova FTBEAM = 2 # Commander tractor beams Enterprise FSNAP = 3 # Snapshot for time warp @@ -284,10 +284,10 @@ FCDBAS = 5 # Commander destroys base FSCMOVE = 6 # Supercommander moves (might attack base) FSCDBAS = 7 # Supercommander destroys base FDSPROB = 8 # Move deep space probe -FDISTR = 9 # Emit distress call from an inhabited world -FENSLV = 10 # Inhabited word is enslaved */ -FREPRO = 11 # Klingons build a ship in an enslaved system -NEVENTS = 12 +FDISTR = 9 # Emit distress call from an inhabited world +FENSLV = 10 # Inhabited word is enslaved */ +FREPRO = 11 # Klingons build a ship in an enslaved system +NEVENTS = 12 # Abstract out the event handling -- underlying data structures will change # when we implement stateful events @@ -319,7 +319,9 @@ class Enemy: else: self.location = Coord() self.kdist = self.kavgd = None - game.enemies.remove(self) + # Guard prevents failure on Tholian or thingy + if self in game.enemies: + game.enemies.remove(self) return motion def __repr__(self): return "<%s,%s.%f>" % (self.type, self.location, self.power) # For debugging @@ -709,7 +711,7 @@ def moveklings(): return tacmoves def movescom(iq, avoid): - "Commander movement helper." + "Supercommander movement helper." # Avoid quadrants with bases if we want to avoid Enterprise if not welcoming(iq) or (avoid and iq in game.state.baseq): return False @@ -934,6 +936,7 @@ def cloak(): key = scanner.nexttok() if key == "IHREAL": + huh() return action = None @@ -1113,23 +1116,23 @@ def doshield(shraise): def randdevice(): "Choose a device to damage, at random." weights = ( - 105, # DSRSENS: short range scanners 10.5% - 105, # DLRSENS: long range scanners 10.5% - 120, # DPHASER: phasers 12.0% - 120, # DPHOTON: photon torpedoes 12.0% - 25, # DLIFSUP: life support 2.5% - 65, # DWARPEN: warp drive 6.5% - 70, # DIMPULS: impulse engines 6.5% - 145, # DSHIELD: deflector shields 14.5% - 30, # DRADIO: subspace radio 3.0% - 45, # DSHUTTL: shuttle 4.5% - 15, # DCOMPTR: computer 1.5% - 20, # NAVCOMP: navigation system 2.0% - 75, # DTRANSP: transporter 7.5% + 105, # DSRSENS: short range scanners 10.5% + 105, # DLRSENS: long range scanners 10.5% + 120, # DPHASER: phasers 12.0% + 120, # DPHOTON: photon torpedoes 12.0% + 25, # DLIFSUP: life support 2.5% + 65, # DWARPEN: warp drive 6.5% + 70, # DIMPULS: impulse engines 6.5% + 135, # DSHIELD: deflector shields 13.5% + 30, # DRADIO: subspace radio 3.0% + 45, # DSHUTTL: shuttle 4.5% + 15, # DCOMPTR: computer 1.5% + 20, # NAVCOMP: navigation system 2.0% + 75, # DTRANSP: transporter 7.5% 20, # DSHCTRL: high-speed shield controller 2.0% - 10, # DDRAY: death ray 1.0% - 30, # DDSP: deep-space probes 3.0% - 0, # DCLOAK: the cloaking device 0.0 + 10, # DDRAY: death ray 1.0% + 30, # DDSP: deep-space probes 3.0% + 10, # DCLOAK: the cloaking device 1.0 ) assert(sum(weights) == 1000) idx = randrange(1000) @@ -1801,9 +1804,6 @@ def hittem(hits): skip(1) kk = 0 for wham in hits: - if not kk < len(game.enemies): - # Should never happen. - break if wham == 0: continue dustfac = randreal(0.9, 1.0) @@ -2749,7 +2749,7 @@ def nova(nov): deadkl(neighbor, iquad, neighbor) continue # neighbor loop # Else enemy gets flung by the blast wave - newc = neighbor + neighbor - hits[-1] + newc = neighbor + neighbor - start proutn(crmena(True, iquad, "sector", neighbor) + _(" damaged")) if not newc.valid_sector(): # can't leave quadrant @@ -3280,24 +3280,9 @@ def plaque(): winner = cgetline() # The 38 below must be 64 for 132-column paper nskip = 38 - len(winner)/2 - fp.write("\n\n\n\n") - # --------DRAW ENTERPRISE PICTURE. - fp.write(" EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n" ) - fp.write(" EEE E : : : E\n" ) - fp.write(" EE EEE E : : NCC-1701 : E\n") - fp.write("EEEEEEEEEEEEEEEE EEEEEEEEEEEEEEE : : : E\n") - fp.write(" E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n") - fp.write(" EEEEEEEEE EEEEEEEEEEEEE E E\n") - fp.write(" EEEEEEE EEEEE E E E E\n") - fp.write(" EEE E E E E\n") - fp.write(" E E E E\n") - fp.write(" EEEEEEEEEEEEE E E\n") - fp.write(" EEE : EEEEEEE EEEEEEEE\n") - fp.write(" :E : EEEE E\n") - fp.write(" .-E -:----- E\n") - fp.write(" :E : E\n") - fp.write(" EE : EEEEEEEE\n") - fp.write(" EEEEEEEEEEEEEEEEEEEEEEE\n") + # This is where the ASCII art picture was emitted. + # It got garbled somewhere in the chain of transmission to the Almy version. + # We should restore it if we can find old enough FORTRAN sources. fp.write("\n\n\n") fp.write(_(" U. S. S. ENTERPRISE\n")) fp.write("\n\n\n\n") @@ -3889,7 +3874,7 @@ def dock(verbose): prout(_("%d captured Klingons transferred to base") % (game.brigcapacity-game.brigfree)) game.kcaptured += game.brigcapacity-game.brigfree game.brigfree = game.brigcapacity - if not damaged(DRADIO) and \ + if communicating() and \ ((is_scheduled(FCDBAS) or game.isatb == 1) and not game.iseenit): # get attack report from base prout(_("Lt. Uhura- \"Captain, an important message from the starbase:\"")) @@ -4024,8 +4009,12 @@ def getcourse(isprobe): key = scanner.nexttok() if key == "IHREAL": delta.i = scanner.real - else: + elif key == "IHEOL": delta.i = 0 + scanner.push("\n") + else: + huh() + raise TrekError # Check for zero movement if delta.i == 0 and delta.j == 0: scanner.chew() @@ -5256,7 +5245,7 @@ def chart(): scanner.chew() if (game.options & OPTION_AUTOSCAN): lrscan(silent=True) - if not damaged(DRADIO): + if communicating(): rechart() if game.lastchart < game.state.date and game.condition == "docked": prout(_("Spock- \"I revised the Star Chart from the starbase's records.\"")) @@ -5392,7 +5381,7 @@ def srscan(): prout(_(" [Using Base's sensors]")) else: prout(_(" Short-range scan")) - if goodScan and not damaged(DRADIO): + if goodScan and communicating(): game.state.chart[game.quadrant.i][game.quadrant.j].klingons = game.state.galaxy[game.quadrant.i][game.quadrant.j].klingons game.state.chart[game.quadrant.i][game.quadrant.j].starbase = game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase game.state.chart[game.quadrant.i][game.quadrant.j].stars = game.state.galaxy[game.quadrant.i][game.quadrant.j].stars @@ -5966,7 +5955,7 @@ def choose(): 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.state.remkl = game.inkling = int(2.0*game.intime*((game.skill+1 - 2*randreal())*game.skill*0.1+.15)) game.incom = min(MINCMDR, int(game.skill + 0.0625*game.inkling*randreal())) game.state.remres = (game.inkling+4*game.incom)*game.intime game.inresor = game.state.remres @@ -6174,6 +6163,7 @@ commands = [ ("QUIT", 0), ("HELP", 0), ("SCORE", 0), + ("CURSES", 0), ("", 0), ] @@ -6286,7 +6276,8 @@ def makemoves(): huh() else: break - prout("COMMAND> %s" % cmd) + if game.options & OPTION_CURSES: + prout("COMMAND> %s" % cmd) if cmd == "SRSCAN": # srscan srscan() elif cmd == "STATUS": # status @@ -6393,6 +6384,9 @@ def makemoves(): helpme() # get help elif cmd == "SCORE": score() # see current score + elif cmd == "CURSES": + game.options |= (OPTION_CURSES | OPTION_COLOR) + iostart() while True: if game.alldone: break # Game has ended