X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.py;h=409ba7aa0bac2375f04a4129c186902ebff14e1f;hp=db33c54e20577b40474f92ac7474d1c4c6782073;hb=ec92d2ec2b1f960e6930f86125d81e4ec2f084ab;hpb=97dc6b2ea8dcb30579e2e1fa9ba6cdcc7bc13dd3 diff --git a/sst.py b/sst.py index db33c54..409ba7a 100755 --- a/sst.py +++ b/sst.py @@ -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) @@ -2605,7 +2608,7 @@ def wait(): if key != "IHEOL": break proutn(_("How long? ")) - scanner.chew() + scanner.chew() if key != "IHREAL": huh() return @@ -2746,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 @@ -3277,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") @@ -3445,8 +3433,8 @@ def proutn(proutntline): pause_game() clrscr() # Uncomment this to debug curses problems - if logfp: - logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(proutntline))) + #if logfp: + # logfp.write("#curses: at %s proutn(%s)\n" % ((y, x), repr(proutntline))) curwnd.addstr(proutntline) curwnd.refresh() else: @@ -3518,7 +3506,7 @@ def setwnd(wnd): legend = "prompt" else: legend = "unknown" - logfp.write("#curses: setwnd(%s)\n" % legend) + #logfp.write("#curses: setwnd(%s)\n" % legend) curwnd = wnd # Some curses implementations get confused when you try this. try: @@ -3722,8 +3710,6 @@ def imove(icourse=None, noattack=False): # check for edge of galaxy kinks = 0 while True: - - kink = False if icourse.final.i < 0: icourse.final.i = -icourse.final.i @@ -4013,15 +3999,20 @@ def getcourse(isprobe): iprompt = True key = scanner.nexttok() itemp = "verbose" - if key != "IHREAL": + if key == "IHREAL": + delta.j = scanner.real + else: huh() raise TrekError - delta.j = scanner.real key = scanner.nexttok() - if key != "IHREAL": + if key == "IHREAL": + delta.i = scanner.real + elif key == "IHEOL": + delta.i = 0 + scanner.push("\n") + else: huh() raise TrekError - delta.i = scanner.real # Check for zero movement if delta.i == 0 and delta.j == 0: scanner.chew() @@ -5217,7 +5208,8 @@ def lrscan(silent): if not silent and game.state.galaxy[x][y].supernova: proutn(" ***") elif not silent: - proutn(" %3d" % (game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars)) + cn = " %3d" % (game.state.chart[x][y].klingons*100 + game.state.chart[x][y].starbase * 10 + game.state.chart[x][y].stars) + proutn(((3 - len(cn)) * '.') + cn) if not silent: prout(" ") @@ -5962,7 +5954,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 @@ -6109,6 +6101,9 @@ def newqad(): game.quad[QUADSIZE-1][0] = '.' if game.quad[QUADSIZE-1][QUADSIZE-1]=='X': game.quad[QUADSIZE-1][QUADSIZE-1] = '.' + # This should guarantee that replay games don't lose info about the chart + if (game.options & OPTION_AUTOSCAN) or replayfp: + lrscan(silent=True) def setpassword(): "Set the self-destruct password." @@ -6170,6 +6165,7 @@ commands = [ ("QUIT", 0), ("HELP", 0), ("SCORE", 0), + ("CURSES", 0), ("", 0), ] @@ -6390,6 +6386,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