def is_valid(self):
return self.x != None and self.y != None
def __eq__(self, other):
- return other != None and self.x == other.y and self.x == other.y
+ return other != None and self.x == other.x and self.y == other.y
def __add__(self, other):
- return coord(self.x+self.x, self.y+self.y)
+ return coord(self.x+other.x, self.y+other.y)
def __sub__(self, other):
return coord(self.x-other.x, self.y-other.y)
def __mul__(self, other):
def welcoming(iq):
"Would this quadrant welcome another Klingon?"
return VALID_QUADRANT(iq.x,iq.y) and \
- not game.state.galaxy[iq.x][iq.y].supernova or \
+ not game.state.galaxy[iq.x][iq.y].supernova and \
game.state.galaxy[iq.x][iq.y].klingons < MAXKLQUAD
-
def tryexit(enemy, look, irun):
"A bad guy attempts to bug out."
iq = coord()
# we know this if either short or long range sensors are working
if not damaged(DSRSENS) or not damaged(DLRSENS) or \
game.condition == "docked":
- crmena(True, enemy.type, "sector", enemy.kloc)
- prout(_(" escapes to Quadrant %s (and regains strength).") % q)
+ prout(crmena(True, enemy.type, "sector", enemy.kloc) + \
+ (_(" escapes to Quadrant %s (and regains strength).") % q))
# handle local matters related to escape
enemy.move(None)
game.klhere -= 1
skip(1)
if enemy.move(next):
if not damaged(DSRSENS) or game.condition == "docked":
- proutn("***")
- cramen(enemy.type)
- proutn(_(" from Sector %s") % enemy.kloc)
+ proutn(_("*** %s from Sector %s") % (cramen(enemy.type), enemy.kloc))
if enemy.kdist < dist1:
proutn(_(" advances to "))
else:
# All plugged up -- Tholian splits
game.quad[game.tholian.kloc.x][game.tholian.kloc.y]=IHWEB
dropin(IHBLANK)
- crmena(True, IHT, "sector", game.tholian)
- prout(_(" completes web."))
+ prout(crmena(True, IHT, "sector", game.tholian) + _(" completes web."))
game.tholian.move(None)
return
return
def randdevice():
- # choose a device to damage, at random.
- #
+ "Choose a device to damage, at random."
# Quoth Eric Allman in the code of BSD-Trek:
# "Under certain conditions you can get a critical hit. This
# sort of hit damages devices. The probability that a given
# We don't have a cloaking device. The shuttle got the allocation
# for the cloaking device, then we shaved a half-percent off
# everything to have some weight to give DSHCTRL/DDRAY/DDSP.
- #
weights = (
105, # DSRSENS: short range scanners 10.5%
105, # DLRSENS: long range scanners 10.5%
prout(_("***COLLISION IMMINENT."))
skip(2)
proutn("***")
- crmshp()
+ proutn(crmshp())
hardness = {IHR:1.5, IHC:2.0, IHS:2.5, IHT:0.5, IHQUEST:4.0}.get(enemy.type, 1.0)
if rammed:
proutn(_(" rammed by "))
else:
proutn(_(" rams "))
- crmena(False, enemy.type, "sector", enemy.kloc)
+ proutn(crmena(False, enemy.type, "sector", enemy.kloc))
if rammed:
proutn(_(" (original position)"))
skip(1)
deadkl(enemy.kloc, enemy.type, game.sector)
- proutn("***")
- crmshp()
- prout(_(" heavily damaged."))
+ proutn("***" + crmship() + " heavily damaged.")
icas = randrange(10, 30)
prout(_("***Sickbay reports %d casualties"), icas)
game.casual += icas
game.state.crew -= icas
- #
# In the pre-SST2K version, all devices got equiprobably damaged,
# which was silly. Instead, pick up to half the devices at
# random according to our weighting table,
- #
ncrits = randrange(NDEVICES/2)
for m in range(ncrits):
dev = randdevice()
finish(FWON)
return
-def torpedo(course, dispersion, origin, number, nburst):
+def torpedo(origin, course, dispersion, number, nburst):
"Let a photon torpedo fly"
- iquad = 0
shoved = False
ac = course + 0.25*dispersion
angle = (15.0-ac)*0.5235988
bullseye = (15.0 - course)*0.5235988
- deltax = -math.sin(angle);
- deltay = math.cos(angle);
+ delta = coord(-math.sin(angle), math.cos(angle))
+ bigger = max(abs(delta.x), abs(delta.y))
+ delta /= bigger
x = origin.x; y = origin.y
- w = coord(); jw = coord()
- w.x = w.y = jw.x = jw.y = 0
- bigger = max(math.fabs(deltax), math.fabs(deltay))
- deltax /= bigger
- deltay /= bigger
+ w = coord(0, 0); jw = coord(0, 0)
if not damaged(DSRSENS) or game.condition=="docked":
setwnd(srscan_window)
else:
setwnd(message_window)
# Loop to move a single torpedo
for step in range(1, 15+1):
- x += deltax
- w.x = int(x + 0.5)
- y += deltay
- w.y = int(y + 0.5)
+ x += delta.x
+ y += delta.y
+ w = coord(x, y).snaptogrid()
if not VALID_SECTOR(w.x, w.y):
break
iquad=game.quad[w.x][w.y]
skip(1); # start new line after text track
if iquad in (IHE, IHF): # Hit our ship
skip(1)
- proutn(_("Torpedo hits "))
- crmshp()
- prout(".")
+ prout(_("Torpedo hits %s.") % crmshp())
hit = 700.0 + randreal(100) - \
1000.0 * (w-origin).distance() * math.fabs(math.sin(bullseye-angle))
newcnd(); # we're blown out of dock
# can't move into object
return hit
game.sector = jw
- crmshp()
+ proutn(crmshp())
shoved = True
elif iquad in (IHC, IHS): # Hit a commander
if withprob(0.05):
- crmena(True, iquad, "sector", w)
- prout(_(" uses anti-photon device;"))
+ prout(crmena(True, iquad, "sector", w) + _(" uses anti-photon device;"))
prout(_(" torpedo neutralized."))
return None
elif iquad in (IHR, IHK): # Hit a regular enemy
# find the enemy
for enemy in game.enemies:
- if w == game.enemies[ll].kloc:
+ if w == enemy.kloc:
break
- kp = math.fabs(e.kpower)
+ kp = math.fabs(enemy.kpower)
h1 = 700.0 + randrange(100) - \
1000.0 * (w-origin).distance() * math.fabs(math.sin(bullseye-angle))
h1 = math.fabs(h1)
if enemy.kpower == 0:
deadkl(w, iquad, w)
return None
- crmena(True, iquad, "sector", w)
+ proutn(crmena(True, iquad, "sector", w))
# If enemy damaged but not destroyed, try to displace
ang = angle + 2.5*(randreal()-0.5)
temp = math.fabs(math.sin(ang))
newcnd()
return None
elif iquad == IHP: # Hit a planet
- crmena(True, iquad, "sector", w)
- prout(_(" destroyed."))
+ prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nplankl += 1
game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = None
game.iplnet.pclass = "destroyed"
finish(FDPLANET)
return None
elif iquad == IHW: # Hit an inhabited world -- very bad!
- crmena(True, iquad, "sector", w)
- prout(_(" destroyed."))
+ prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nworldkl += 1
game.state.galaxy[game.quadrant.x][game.quadrant.y].planet = None
game.iplnet.pclass = "destroyed"
if withprob(0.9):
nova(w)
else:
- crmena(True, IHSTAR, "sector", w)
- prout(_(" unaffected by photon blast."))
+ prout(crmena(True, IHSTAR, "sector", w) + _(" unaffected by photon blast."))
return None
elif iquad == IHQUEST: # Hit a thingy
if not (game.options & OPTION_THINGY) or withprob(0.3):
skip(1)
deadkl(w, iquad, w)
else:
- #
# Stas Sergeev added the possibility that
# you can shove the Thingy and piss it off.
# It then becomes an enemy and may fire at you.
- #
thing.angry = True
shoved = True
return None
elif iquad == IHBLANK: # Black hole
skip(1)
- crmena(True, IHBLANK, "sector", w)
- prout(_(" swallows torpedo."))
+ prout(crmena(True, IHBLANK, "sector", w) + _(" swallows torpedo."))
return None
elif iquad == IHWEB: # hit the web
skip(1)
game.tholian = None
return None
skip(1)
- crmena(True, IHT, "sector", w)
+ proutn(crmena(True, IHT, "sector", w))
if withprob(0.05):
prout(_(" survives photon blast."))
return None
else: # Problem!
skip(1)
proutn("Don't know how to handle torpedo collision with ")
- crmena(True, iquad, "sector", w)
+ proutn(crmena(True, iquad, "sector", w))
skip(1)
return None
break
def attack(torps_ok):
# bad guy attacks us
# torps_ok == False forces use of phasers in an attack
+ # game could be over at this point, check
+ if game.alldone:
+ return
attempt = False; ihurt = False;
hitmax=0.0; hittot=0.0; chgfac=1.0
where = "neither"
- # game could be over at this point, check
- if game.alldone:
- return
if idebug:
prout("=== ATTACK!")
# Tholian gets to move before attacking
hit = 0
proutn(_("***TORPEDO INCOMING"))
if not damaged(DSRSENS):
- proutn(_(" From "))
- crmena(False, enemy.type, where, enemy.kloc)
+ proutn(_(" From ") + crmena(False, enemy.type, where, enemy.kloc))
attempt = True
prout(" ")
dispersion = (randreal()+randreal())*0.5 - 0.5
dispersion += 0.002*enemy.kpower*dispersion
- hit = torpedo(course, dispersion, origin=enemy.kloc, number=1, nburst=1)
+ hit = torpedo(enemy.kloc, course, dispersion, number=1, nburst=1)
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0:
finish(FWON); # Klingons did themselves in!
if game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova or game.alldone:
ihurt = True
proutn(_("%d unit hit") % int(hit))
if (damaged(DSRSENS) and usephasers) or game.skill<=SKILL_FAIR:
- proutn(_(" on the "))
- crmshp()
+ proutn(_(" on the ") + crmshp())
if not damaged(DSRSENS) and usephasers:
- proutn(_(" from "))
- crmena(False, enemy.type, where, enemy.kloc)
+ prout(_(" from ") + crmena(False, enemy.type, where, enemy.kloc))
skip(1)
# Decide if hit is critical
if hit > hitmax:
def deadkl(w, type, mv):
"Kill a Klingon, Tholian, Romulan, or Thingy."
# Added mv to allow enemy to "move" before dying
- crmena(True, type, "sector", mv)
+ proutn(crmena(True, type, "sector", mv))
# Decide what kind of enemy it is and update appropriately
if type == IHR:
# chalk up a Romulan
if not VALID_SECTOR(w.x, w.y):
huh()
return None
- delta = 0.1*(w - game.sector)
- if delta.x==0 and delta.y== 0:
+ delta = coord()
+ # FIXME: C code this was translated from is wacky -- why the sign reversal?
+ delta.y = (w.y - game.sector.y);
+ delta.x = (game.sector.x - w.x);
+ if delta == coord(0, 0):
skip(1)
prout(_("Spock- \"Bridge to sickbay. Dr. McCoy,"))
prout(_(" I recommend an immediate review of"))
prout(_(" the Captain's psychological profile.\""))
scanner.chew()
return None
- return delta.bearing()
+ return 1.90985932*math.atan2(delta.y, delta.x)
def photon():
"Launch photon torpedo."
- course = [0.0] * MAXBURST
+ course = []
game.ididit = False
if damaged(DPHOTON):
prout(_("Photon tubes damaged."))
break
if game.shldup or game.condition == "docked":
dispersion *= 1.0 + 0.0001*game.shield
- torpedo(course[i], dispersion, origin=game.sector, number=i, nburst=n)
+ torpedo(game.sector, course[i], dispersion, number=i, nburst=n)
if game.alldone or game.state.galaxy[game.quadrant.x][game.quadrant.y].supernova:
return
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0:
ienm = game.quad[w.x][w.y]
if ienm==IHQUEST:
thing.angry = True
- crmena(False, ienm, "sector", w)
+ proutn(crmena(False, ienm, "sector", w))
skip(1)
if kpow == 0:
deadkl(w, ienm, w)
rpow = 0.0
if damaged(DSRSENS) and \
not game.sector.distance(aim)<2**0.5 and ienm in (IHC, IHS):
- cramen(ienm)
- prout(_(" can't be located without short range scan."))
+ prout(cramen(ienm) + _(" can't be located without short range scan."))
scanner.chew()
key = IHEOL
hits[k] = 0; # prevent overflow -- thanks to Alexei Voitenko
else:
proutn("??")
proutn(") ")
- proutn(_("units to fire at "))
- crmena(False, ienm, "sector", aim)
- proutn("- ")
+ proutn(_("units to fire at %s- ") % crmena(False, ienm, "sector", aim))
key = scanner.next()
if key == IHALPHA and scanner.sees("no"):
no = True
announce()
game.optime = (10.0/(7.5*7.5))*yank # 7.5 is yank rate (warp 7.5)
skip(1)
- proutn("***")
- crmshp()
- prout(_(" caught in long range tractor beam--"))
+ prout("***" + crmshp() + _(" caught in long range tractor beam--"))
# If Kirk & Co. screwing around on planet, handle
atover(True) # atover(true) is Grab
if game.alldone:
else:
game.quadrant = game.state.kcmdr[i]
game.sector = randplace(QUADSIZE)
- crmshp()
- prout(_(" is pulled to Quadrant %s, Sector %s") \
+ prout(crmshp() + _(" is pulled to Quadrant %s, Sector %s") \
% (game.quadrant, game.sector))
if game.resting:
prout(_("(Remainder of rest/repair period cancelled.)"))
game.shldchg = False
else:
prout(_("(Shields not currently useable.)"))
- newqad(False)
+ newqad()
# Adjust finish time to time of tractor beaming
fintim = game.state.date+game.optime
attack(torps_ok=False)
else:
continue # search for eligible quadrant failed
except "FOUNDIT":
- w.x = i
- w.y = j
+ w.x = i; w.y = j
# deliver the child
game.state.remkl += 1
q.klingons += 1
return
# handle initial nova
game.quad[nov.x][nov.y] = IHDOT
- crmena(False, IHSTAR, "sector", nov)
- prout(_(" novas."))
+ prout(crmena(False, IHSTAR, "sector", nov) + _(" novas."))
game.state.galaxy[game.quadrant.x][game.quadrant.y].stars -= 1
game.state.starkl += 1
# Set up queue to recursively trigger adjacent stars
hits.append(neighbor)
game.state.galaxy[game.quadrant.x][game.quadrant.y].stars -= 1
game.state.starkl += 1
- crmena(True, IHSTAR, "sector", neighbor)
+ proutn(crmena(True, IHSTAR, "sector", neighbor))
prout(_(" novas."))
game.quad[neighbor.x][neighbor.y] = IHDOT
kount += 1
game.state.nplankl += 1
else:
game.state.worldkl += 1
- crmena(True, iquad, "sector", neighbor)
- prout(_(" destroyed."))
+ prout(crmena(True, IHB, "sector", neighbor) + _(" destroyed."))
game.iplnet.pclass = "destroyed"
game.iplnet = None
game.plnet.invalidate()
game.base.invalidate()
game.state.basekl += 1
newcnd()
- crmena(True, IHB, "sector", neighbor)
- prout(_(" destroyed."))
+ prout(crmena(True, IHB, "sector", neighbor) + _(" destroyed."))
game.quad[neighbor.x][neighbor.y] = IHDOT
elif iquad in (IHE, IHF): # Buffet ship
prout(_("***Starship buffeted by nova."))
deadkl(neighbor, iquad, neighbor)
break
newc = neighbor + neighbor - hits[mm]
- crmena(True, iquad, "sector", neighbor)
- proutn(_(" damaged"))
+ proutn(crmena(True, iquad, "sector", neighbor) + _(" damaged"))
if not VALID_SECTOR(newc.x, newc.y):
# can't leave quadrant
skip(1)
break
iquad1 = game.quad[newc.x][newc.y]
if iquad1 == IHBLANK:
- proutn(_(", blasted into "))
- crmena(False, IHBLANK, "sector", newc)
+ proutn(_(", blasted into ") + crmena(False, IHBLANK, "sector", newc))
skip(1)
deadkl(neighbor, iquad, newc)
break
stars()
if game.ship==IHE:
prouts("***")
- prouts(_("********* Entropy of "))
- crmshp()
- prouts(_(" maximized *********"))
+ prouts(_("********* Entropy of %s maximized *********") % crmshp())
skip(1)
stars()
skip(1)
skip(1)
prout(_("Your starship is a derelict in space."))
elif ifin == FBATTLE:
- proutn(_("The "))
- crmshp()
- prout(_(" has been destroyed in battle."))
+ prout(_("The %s has been destroyed in battle.") % crmshp())
skip(1)
prout(_("Dulce et decorum est pro patria mori."))
elif ifin == FNEG3:
prout(_("That was a great shot."))
skip(1)
elif ifin == FSNOVAED:
- proutn(_("The "))
- crmshp()
- prout(_(" has been fried by a supernova."))
+ prout(_("The %s has been fried by a supernova.") % crmshp())
prout(_("...Not even cinders remain..."))
elif ifin == FABANDN:
prout(_("You have been captured by the Klingons. If you still"))
prout(_("Starbase was unable to re-materialize your starship."))
prout(_("Sic transit gloria mundi"))
elif ifin == FPHASER:
- proutn(_("The "))
- crmshp()
- prout(_(" has been cremated by its own phasers."))
+ prout(_("The %s has been cremated by its own phasers.") % crmshp())
elif ifin == FLOST:
prout(_("You and your landing party have been"))
prout(_("converted to energy, disipating through space."))
skip(1)
prout(_("They are very fond of \"Captain Kirk\" soup."))
skip(1)
- proutn(_("Without your leadership, the "))
- crmshp()
- prout(_(" is destroyed."))
+ prout(_("Without your leadership, the %s is destroyed.") % crmshp())
elif ifin == FDPLANET:
prout(_("You and your mining party perish."))
skip(1)
prout(_("The Galileo is instantly annihilated by the supernova."))
prout(_("You and your mining party are atomized."))
skip(1)
- proutn(_("Mr. Spock takes command of the "))
- crmshp()
- prout(_(" and"))
- prout(_("joins the Romulans, reigning terror on the Federation."))
+ prout(_("Mr. Spock takes command of the %s and") % crmshp())
+ prout(_("joins the Romulans, wreaking terror on the Federation."))
elif ifin == FPNOVA:
prout(_("You and your mining party are atomized."))
skip(1)
- proutn(_("Mr. Spock takes command of the "))
- crmshp()
- prout(_(" and"))
- prout(_("joins the Romulans, reigning terror on the Federation."))
+ prout(_("Mr. Spock takes command of the %s and") % crmshp())
+ prout(_("joins the Romulans, wreaking terror on the Federation."))
elif ifin == FSTRACTOR:
prout(_("The shuttle craft Galileo is also caught,"))
prout(_("and breaks up under the strain."))
skip(1)
prout(_("Your debris is scattered for millions of miles."))
- proutn(_("Without your leadership, the "))
- crmshp()
- prout(_(" is destroyed."))
+ prout(_("Without your leadership, the %s is destroyed.") % crmshp())
elif ifin == FDRAY:
prout(_("The mutants attack and kill Spock."))
prout(_("Your ship is captured by Klingons, and"))
def announce():
skip(1)
- if game.skill > SKILL_FAIR:
- prouts(_("[ANOUNCEMENT ARRIVING...]"))
- else:
- prouts(_("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]"))
+ prouts(_("[ANOUNCEMENT ARRIVING...]"))
skip(1)
def pause_game():
skip(1)
prout(_("Entering Quadrant %s.") % game.quadrant)
game.quad[game.sector.x][game.sector.y] = game.ship
- newqad(False)
+ newqad()
if game.skill>SKILL_NOVICE:
attack(torps_ok=False)
return
skip(1)
prouts(_("***RED ALERT! RED ALERT!"))
skip(1)
- proutn("***")
- crmshp()
+ proutn("***" + crmshp())
proutn(_(" pulled into black hole at Sector %s") % w)
#
# Getting pulled into a black hole was certain
else:
# something else
skip(1)
- crmshp()
+ proutn(crmshp())
if iquad == IHWEB:
prout(_(" encounters Tholian web at %s;") % w)
else:
prout(_("You must first leave standard orbit."))
return
if not game.base.is_valid() or abs(game.sector.x-game.base.x) > 1 or abs(game.sector.y-game.base.y) > 1:
- crmshp()
- prout(_(" not adjacent to base."))
+ prout(crmshp() + _(" not adjacent to base."))
return
game.condition = "docked"
if "verbose":
if key != IHREAL:
huh()
return False
- delta.x = scanner.real
+ delta.y = scanner.real
key = scanner.next()
if key != IHREAL:
huh()
return False
- delta.y = scanner.real
+ delta.x = scanner.real
# Check for zero movement
if delta.x == 0 and delta.y == 0:
scanner.chew()
bigger = math.fabs(deltax)
else:
bigger = math.fabs(deltay)
-
deltax /= bigger
deltay /= bigger
n = 10.0 * game.dist * bigger +0.5
if game.justin:
prouts(_("***RED ALERT! RED ALERT!"))
skip(1)
- proutn(_("The "))
- crmshp()
- prout(_(" has stopped in a quadrant containing"))
+ proutn(_("The %s has stopped in a quadrant containing") % crmshp())
prouts(_(" a supernova."))
skip(2)
- proutn(_("***Emergency automatic override attempts to hurl "))
- crmshp()
+ prout(_("***Emergency automatic override attempts to hurl ")+crmshp())
skip(1)
prout(_("safely out of quadrant."))
if not damaged(DRADIO):
# cheat to make sure no tractor beams occur during time warp
postpone(FTBEAM, game.optime)
game.damage[DRADIO] += game.optime
- newqad(False)
+ newqad()
events() # Stas Sergeev added this -- do pending events
def probe():
prout(_("Lt. Uhura- \"Captain, I'm not getting any response from Starbase.\""))
return
if game.landed:
- proutn(_("You must be aboard the "))
- crmshp()
- prout(".")
+ prout(_("You must be aboard the %s.") % crmshp())
return
# OK -- call for help from nearest starbase
game.nhelp += 1
ddist = xdist
# Since starbase not in quadrant, set up new quadrant
game.quadrant = ibq
- newqad(True)
+ newqad()
# dematerialize starship
game.quad[game.sector.x][game.sector.y]=IHDOT
- proutn(_("Starbase in Quadrant %s responds--") % game.quadrant)
- crmshp()
- prout(_(" dematerializes."))
- game.sector.x=0
+ proutn(_("Starbase in Quadrant %s responds--%s dematerializes") \
+ % (game.quadrant, crmshp()))
+ game.sector.invalidate()
for m in range(1, 5+1):
w = game.base.scatter()
- if VALID_SECTOR(ix,iy) and game.quad[ix][iy]==IHDOT:
+ if VALID_SECTOR(w.x,w.y) and game.quad[w.x][w.y]==IHDOT:
# found one -- finish up
game.sector = w
break
if m == 1: proutn(_("1st"))
elif m == 2: proutn(_("2nd"))
elif m == 3: proutn(_("3rd"))
- proutn(_(" attempt to re-materialize "))
- crmshp()
+ proutn(_(" attempt to re-materialize ") + crmshp())
game.quad[ix][iy]=(IHMATER0,IHMATER1,IHMATER2)[m-1]
textcolor("red")
warble()
game.state.crew)
game.casual += game.state.crew
game.abandoned += game.state.crew
-
# If at least one base left, give 'em the Faerie Queene
skip(1)
game.icrystl = False # crystals are lost
if not game.quadrant == game.state.baseq[nb]:
game.quadrant = game.state.baseq[nb]
game.sector.x = game.sector.y = 5
- newqad(True)
+ newqad()
while True:
# position next to base by trial and error
game.quad[game.sector.x][game.sector.y] = IHDOT
break # found a spot
game.sector.x=QUADSIZE/2
game.sector.y=QUADSIZE/2
- newqad(True)
+ newqad()
# Get new commission
game.quad[game.sector.x][game.sector.y] = game.ship = IHF
game.state.crew = FULLCREW
prout("There is no planet in this sector.")
return
if abs(game.sector.x-game.plnet.x)>1 or abs(game.sector.y-game.plnet.y)>1:
- crmshp()
- prout(_(" not adjacent to planet."))
+ prout(crmshp() + _(" not adjacent to planet."))
skip(1)
return
game.optime = randreal(0.02, 0.05)
shuttle()
return
if not game.inorbit:
- crmshp()
- prout(_(" not in standard orbit."))
+ prout(crmshp() + _(" not in standard orbit."))
return
if game.shldup:
prout(_("Impossible to transport through shields."))
prout(_("You've already mined enough crystals for this trip."))
return
if game.icrystl and game.cryprob == 0.05:
- proutn(_("With all those fresh crystals aboard the "))
- crmshp()
- skip(1)
+ prout(_("With all those fresh crystals aboard the ") + crmshp())
prout(_("there's no reason to mine more at this time."))
return
game.optime = randreal(0.1, 0.3)*(ord(game.iplnet.pclass)-ord("L"))
prout(_("Shuttle craft is now serving Big Macs."))
return
if not game.inorbit:
- crmshp()
- prout(_(" not in standard orbit."))
+ prout(crmshp() + _(" not in standard orbit."))
return
if (game.iplnet.known != "shuttle_down") and game.iscraft != "onship":
prout(_("Shuttle craft not currently available."))
scanner.chew()
skip(1)
return
-
# Code from setup.c begins here
unschedule(FENSLV)
unschedule(FREPRO)
# Place thing (in tournament game, we don't want one!)
+ # New in SST2K: never place the Thing near a starbase.
+ # This makes sense and avoids a special case in the old code.
global thing
if game.tourn is None:
- thing = randplace(GALSIZE)
+ while True:
+ thing = randplace(GALSIZE)
+ if thing not in game.state.baseq:
+ break
skip(2)
game.state.snap = False
if game.skill == SKILL_NOVICE:
if game.state.nscrem:
prout(_(" YOU'LL NEED IT."))
waitfor()
- newqad(False)
+ newqad()
if len(game.enemies) - (thing == game.quadrant) - (game.tholian != None):
game.shldup = True
if game.neutz: # bad luck to start in a Romulan Neutral Zone
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:
"Drop new Klingon into current quadrant."
return enemy(IHK, loc=dropin(), power=randreal(300,450)+25.0*game.skill)
-def newqad(shutup):
+def newqad():
"Set up a new state of quadrant, for when we enter or re-enter it."
- w = coord()
game.justin = True
- game.klhere = 0
- game.irhere = 0
- game.iplnet = 0
- game.neutz = False
- game.inorbit = False
- game.landed = False
- game.ientesc = False
- game.iseenit = False
+ game.iplnet = None
+ game.neutz = game.inorbit = game.landed = False
+ game.ientesc = game.iseenit = False
# Create a blank quadrant
game.quad = fill2d(QUADSIZE, lambda i, j: IHDOT)
if game.iscate:
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(type=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.\""))
+ # Put in THING if needed
+ if thing == game.quadrant:
+ enemy(type=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 \
"HELP": 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):
+ for (k, key) in enumerate(commands):
+ if not commands[cmd] or (commands[key] & game.options):
if k % 5 == 0:
skip(1)
proutn("%-12s " % key)
- k += 1
skip(1)
def helpme():
def makemoves():
"Command-interpretation loop."
- v = 0
clrscr()
setwnd(message_window)
while True: # command loop
if idebug:
prout("=== Ending")
-def cramen(cmd):
+def cramen(type):
"Emit the name of an enemy or feature."
- 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")
+ if type == IHR: s = _("Romulan")
+ elif type == IHK: s = _("Klingon")
+ elif type == IHC: s = _("Commander")
+ elif type == IHS: s = _("Super-commander")
+ elif type == IHSTAR: s = _("Star")
+ elif type == IHP: s = _("Planet")
+ elif type == IHB: s = _("Starbase")
+ elif type == IHBLANK: s = _("Black hole")
+ elif type == IHT: s = _("Tholian")
+ elif type == IHWEB: s = _("Tholian web")
+ elif type == IHQUEST: s = _("Stranger")
+ elif type == IHW: s = _("Inhabited World")
else: s = "Unknown??"
- proutn(s)
+ return s
def crmena(stars, enemy, loctype, w):
- "Emit the name of an enemy and his location."
- if stars:
- proutn("***")
- cramen(enemy)
- proutn(_(" at "))
+ "Emit the name of an enemy and his location."
buf = ""
+ if stars:
+ buf += "***"
+ buf += cramen(enemy) + _(" at ")
if loctype == "quadrant":
- buf = _("Quadrant ")
+ buf += _("Quadrant ")
elif loctype == "sector":
- buf = _("Sector ")
- proutn(buf + `w`)
+ buf += _("Sector ")
+ return buf + `w`
def crmshp():
"Emit our ship name."
- if game.ship == IHE:
- s = _("Enterprise")
- elif game.ship == IHF:
- s = _("Faerie Queene")
- else:
- s = "Ship???"
- proutn(s)
+ return{IHE:_("Enterprise"),IHF:_("Faerie Queene")}.get(game.ship,"Ship???")
def stars():
"Emit a line of stars"
proutn("Cause selective damage? ")
if ja() == True:
for i in range(NDEVICES):
- proutn("Kill ")
- proutn(device[i])
- proutn("? ")
+ proutn("Kill %s?" % device[i])
scanner.chew()
key = scanner.next()
if key == IHALPHA and scanner.sees("y"):