def distance(self, other=None):
if not other: other = coord(0, 0)
def distance(self, other=None):
if not other: other = coord(0, 0)
def bearing(self, other=None):
if not other: other = coord(0, 0)
def bearing(self, other=None):
if not other: other = coord(0, 0)
- s.x = self.x + randrange(-1, 2)
- s.y = self.y + randrange(-1, 2)
+ s.i = self.i + randrange(-1, 2)
+ s.j = self.j + randrange(-1, 2)
- return VALID_QUADRANT(iq.x,iq.y) and \
- not game.state.galaxy[iq.x][iq.y].supernova and \
- game.state.galaxy[iq.x][iq.y].klingons < MAXKLQUAD
+ return VALID_QUADRANT(iq.i,iq.j) and \
+ not game.state.galaxy[iq.i][iq.j].supernova and \
+ game.state.galaxy[iq.i][iq.j].klingons < MAXKLQUAD
def tryexit(enemy, look, irun):
"A bad guy attempts to bug out."
iq = coord()
def tryexit(enemy, look, irun):
"A bad guy attempts to bug out."
iq = coord()
- iq.x = game.quadrant.x+(look.x+(QUADSIZE-1))/QUADSIZE - 1
- iq.y = game.quadrant.y+(look.y+(QUADSIZE-1))/QUADSIZE - 1
+ iq.i = game.quadrant.i+(look.i+(QUADSIZE-1))/QUADSIZE - 1
+ iq.j = game.quadrant.j+(look.j+(QUADSIZE-1))/QUADSIZE - 1
- game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons -= 1
- game.state.galaxy[iq.x][iq.y].klingons += 1
+ game.state.galaxy[game.quadrant.i][game.quadrant.j].klingons -= 1
+ game.state.galaxy[iq.i][iq.j].klingons += 1
proutn("NSTEPS = %d:" % nsteps)
# Compute preferred values of delta X and Y
m = game.sector - enemy.kloc
proutn("NSTEPS = %d:" % nsteps)
# Compute preferred values of delta X and Y
m = game.sector - enemy.kloc
- look.y = next.y + krawly
- krawly = -krawly
- elif (game.options & OPTION_RAMMING) and game.quad[look.x][look.y] != IHDOT:
+ look.j = next.j + krawlj
+ krawlj = -krawlj
+ elif (game.options & OPTION_RAMMING) and game.quad[look.i][look.j] != IHDOT:
(enemy.type == IHC or enemy.type == IHS):
collision(rammed=True, enemy=enemy)
return
(enemy.type == IHC or enemy.type == IHS):
collision(rammed=True, enemy=enemy)
return
- if krawlx != m.x and m.y != 0:
- look.x = next.x + krawlx
- krawlx = -krawlx
- elif krawly != m.y and m.x != 0:
- look.y = next.y + krawly
- krawly = -krawly
+ if krawli != m.i and m.j != 0:
+ look.i = next.i + krawli
+ krawli = -krawli
+ elif krawlj != m.j and m.i != 0:
+ look.j = next.j + krawlj
+ krawlj = -krawlj
if game.state.kscmdr==game.quadrant:
# SC has scooted, Remove him from current quadrant
game.iscate=False
if game.state.kscmdr==game.quadrant:
# SC has scooted, Remove him from current quadrant
game.iscate=False
if not game.iscate and avoid:
# compute move away from Enterprise
idelta = game.state.kscmdr-game.quadrant
if not game.iscate and avoid:
# compute move away from Enterprise
idelta = game.state.kscmdr-game.quadrant
- if game.tholian.kloc.x == 0 and game.tholian.kloc.y == 0:
- id.x = 0; id.y = QUADSIZE-1
- elif game.tholian.kloc.x == 0 and game.tholian.kloc.y == QUADSIZE-1:
- id.x = QUADSIZE-1; id.y = QUADSIZE-1
- elif game.tholian.kloc.x == QUADSIZE-1 and game.tholian.kloc.y == QUADSIZE-1:
- id.x = QUADSIZE-1; id.y = 0
- elif game.tholian.kloc.x == QUADSIZE-1 and game.tholian.kloc.y == 0:
- id.x = 0; id.y = 0
+ if game.tholian.kloc.i == 0 and game.tholian.kloc.j == 0:
+ id.i = 0; id.j = QUADSIZE-1
+ elif game.tholian.kloc.i == 0 and game.tholian.kloc.j == QUADSIZE-1:
+ id.i = QUADSIZE-1; id.j = QUADSIZE-1
+ elif game.tholian.kloc.i == QUADSIZE-1 and game.tholian.kloc.j == QUADSIZE-1:
+ id.i = QUADSIZE-1; id.j = 0
+ elif game.tholian.kloc.i == QUADSIZE-1 and game.tholian.kloc.j == 0:
+ id.i = 0; id.j = 0
dropin(IHBLANK)
prout(crmena(True, IHT, "sector", game.tholian) + _(" completes web."))
game.tholian.move(None)
dropin(IHBLANK)
prout(crmena(True, IHT, "sector", game.tholian) + _(" completes web."))
game.tholian.move(None)
angle = (15.0-ac)*0.5235988
bullseye = (15.0 - course)*0.5235988
delta = coord(-math.sin(angle), math.cos(angle))
angle = (15.0-ac)*0.5235988
bullseye = (15.0 - course)*0.5235988
delta = coord(-math.sin(angle), math.cos(angle))
w = coord(0, 0); jw = coord(0, 0)
if not damaged(DSRSENS) or game.condition=="docked":
setwnd(srscan_window)
w = coord(0, 0); jw = coord(0, 0)
if not damaged(DSRSENS) or game.condition=="docked":
setwnd(srscan_window)
setwnd(message_window)
# Loop to move a single torpedo
for step in range(1, 15+1):
setwnd(message_window)
# Loop to move a single torpedo
for step in range(1, 15+1):
tracktorpedo(origin, w, step, number, nburst, iquad)
if iquad==IHDOT:
continue
tracktorpedo(origin, w, step, number, nburst, iquad)
if iquad==IHDOT:
continue
if withprob(0.05):
prout(crmena(True, iquad, "sector", w) + _(" uses anti-photon device;"))
prout(_(" torpedo neutralized."))
return None
if withprob(0.05):
prout(crmena(True, iquad, "sector", w) + _(" uses anti-photon device;"))
prout(_(" torpedo neutralized."))
return None
skip(1)
prout(_("***STARBASE DESTROYED.."))
game.state.baseq = filter(lambda x: x != game.quadrant, game.state.baseq)
skip(1)
prout(_("***STARBASE DESTROYED.."))
game.state.baseq = filter(lambda x: x != game.quadrant, game.state.baseq)
- game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase -= 1
- game.state.chart[game.quadrant.x][game.quadrant.y].starbase -= 1
+ game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase -= 1
+ game.state.chart[game.quadrant.i][game.quadrant.j].starbase -= 1
game.state.basekl += 1
newcnd()
return None
elif iquad == IHP: # Hit a planet
prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nplankl += 1
game.state.basekl += 1
newcnd()
return None
elif iquad == IHP: # Hit a planet
prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nplankl += 1
elif iquad == IHW: # Hit an inhabited world -- very bad!
prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nworldkl += 1
elif iquad == IHW: # Hit an inhabited world -- very bad!
prout(crmena(True, iquad, "sector", w) + _(" destroyed."))
game.state.nworldkl += 1
prout(_(" displaced by blast to Sector %s ") % jw)
for ll in range(len(game.enemies)):
game.enemies[ll].kdist = game.enemies[ll].kavgd = (game.sector-game.enemies[ll].kloc).distance()
prout(_(" displaced by blast to Sector %s ") % jw)
for ll in range(len(game.enemies)):
game.enemies[ll].kdist = game.enemies[ll].kavgd = (game.sector-game.enemies[ll].kloc).distance()
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!
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!
prout(_("%d torpedoes left.") % game.torps)
scanner.chew()
proutn(_("Number of torpedoes to fire- "))
continue # Go back around to get a number
prout(_("%d torpedoes left.") % game.torps)
scanner.chew()
proutn(_("Number of torpedoes to fire- "))
continue # Go back around to get a number
if game.shldup or game.condition == "docked":
dispersion *= 1.0 + 0.0001*game.shield
torpedo(game.sector, course[i], dispersion, number=i, nburst=n)
if game.shldup or game.condition == "docked":
dispersion *= 1.0 + 0.0001*game.shield
torpedo(game.sector, course[i], dispersion, number=i, nburst=n)
if ienm==IHQUEST:
thing.angry = True
proutn(crmena(False, ienm, "sector", w))
if ienm==IHQUEST:
thing.angry = True
proutn(crmena(False, ienm, "sector", w))
# (That was Tom Almy talking about the C code, I think -- ESR)
while automode=="NOTSET":
key=scanner.next()
# (That was Tom Almy talking about the C code, I think -- ESR)
while automode=="NOTSET":
key=scanner.next()
not game.sector.distance(aim)<2**0.5 and ienm in (IHC, IHS):
prout(cramen(ienm) + _(" can't be located without short range scan."))
scanner.chew()
not game.sector.distance(aim)<2**0.5 and ienm in (IHC, IHS):
prout(cramen(ienm) + _(" can't be located without short range scan."))
scanner.chew()
scanner.chew()
if itarg and k > kz:
irec=(abs(game.enemies[k].kpower)/(PHASEFAC*math.pow(0.9,game.enemies[k].kdist))) * randreal(1.01, 1.06) + 1.0
scanner.chew()
if itarg and k > kz:
irec=(abs(game.enemies[k].kpower)/(PHASEFAC*math.pow(0.9,game.enemies[k].kdist))) * randreal(1.01, 1.06) + 1.0
proutn(") ")
proutn(_("units to fire at %s- ") % crmena(False, ienm, "sector", aim))
key = scanner.next()
proutn(") ")
proutn(_("units to fire at %s- ") % crmena(False, ienm, "sector", aim))
key = scanner.next()
# Not perfect, but will have to do
# Handle case where base is in same quadrant as starship
if game.battle == game.quadrant:
# Not perfect, but will have to do
# Handle case where base is in same quadrant as starship
if game.battle == game.quadrant:
- game.state.chart[game.battle.x][game.battle.y].starbase = False
- game.quad[game.base.x][game.base.y] = IHDOT
+ game.state.chart[game.battle.i][game.battle.j].starbase = False
+ game.quad[game.base.i][game.base.j] = IHDOT
game.state.baseq = filter(lambda x: x != game.battle, game.state.baseq)
if game.isatb == 2:
# reinstate a commander's base attack
game.state.baseq = filter(lambda x: x != game.battle, game.state.baseq)
if game.isatb == 2:
# reinstate a commander's base attack
return
elif evcode == FSPY: # Check with spy to see if SC should tractor beam
if game.state.nscrem == 0 or \
return
elif evcode == FSPY: # Check with spy to see if SC should tractor beam
if game.state.nscrem == 0 or \
for ibq in game.state.baseq:
for cmdr in game.state.kcmdr:
if ibq == cmdr and ibq != game.quadrant and ibq != game.state.kscmdr:
for ibq in game.state.baseq:
for cmdr in game.state.kcmdr:
if ibq == cmdr and ibq != game.quadrant and ibq != game.state.kscmdr:
- raise "foundit"
- except "foundit":
- # no match found -- try later
- schedule(FBATTAK, expran(0.3*game.intime))
- unschedule(FCDBAS)
- continue
+ raise ibq
+ else:
+ # no match found -- try later
+ schedule(FBATTAK, expran(0.3*game.intime))
+ unschedule(FCDBAS)
+ continue
+ except coord:
+ pass
schedule(FCDBAS, randreal(1.0, 4.0))
if game.isatb: # extra time if SC already attacking
postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date)
schedule(FCDBAS, randreal(1.0, 4.0))
if game.isatb: # extra time if SC already attacking
postpone(FCDBAS, scheduled(FSCDBAS)-game.state.date)
game.probey += game.probeiny
i = (int)(game.probex/QUADSIZE +0.05)
j = (int)(game.probey/QUADSIZE + 0.05)
game.probey += game.probeiny
i = (int)(game.probex/QUADSIZE +0.05)
j = (int)(game.probey/QUADSIZE + 0.05)
# not already under attack, which is not
# supernova'ed, and which has some Klingons in it
w = randplace(GALSIZE)
# not already under attack, which is not
# supernova'ed, and which has some Klingons in it
w = randplace(GALSIZE)
if not (game.quadrant == w or q.planet == None or \
not q.planet.inhabited or \
q.supernova or q.status!="secure" or q.klingons<=0):
if not (game.quadrant == w or q.planet == None or \
not q.planet.inhabited or \
q.supernova or q.status!="secure" or q.klingons<=0):
# got one!! Schedule its enslavement
ev = schedule(FENSLV, expran(game.intime))
ev.quadrant = w
# got one!! Schedule its enslavement
ev = schedule(FENSLV, expran(game.intime))
ev.quadrant = w
# tell the captain about it if we can
if communicating():
prout(_("Uhura- Captain, %s in Quadrant %s reports it is under attack") \
# tell the captain about it if we can
if communicating():
prout(_("Uhura- Captain, %s in Quadrant %s reports it is under attack") \
# explicitly retrieve and restore the x and y.
ev = schedule(FREPRO, expran(1.0 * game.intime))
# see if current distress call still active
# explicitly retrieve and restore the x and y.
ev = schedule(FREPRO, expran(1.0 * game.intime))
# see if current distress call still active
if game.klhere >= MAXKLQUAD:
try:
# this quadrant not ok, pick an adjacent one
if game.klhere >= MAXKLQUAD:
try:
# this quadrant not ok, pick an adjacent one
- for i in range(w.x - 1, w.x + 2):
- for j in range(w.y - 1, w.y + 2):
+ for i in range(w.i - 1, w.i + 2):
+ for j in range(w.j - 1, w.j + 2):
newc = coord(); neighbor = coord(); bump = coord(0, 0)
if withprob(0.05):
# Wow! We've supernova'ed
newc = coord(); neighbor = coord(); bump = coord(0, 0)
if withprob(0.05):
# Wow! We've supernova'ed
prout(crmena(False, IHSTAR, "sector", nov) + _(" novas."))
prout(crmena(False, IHSTAR, "sector", nov) + _(" novas."))
- for offset.x in range(-1, 1+1):
- for offset.y in range(-1, 1+1):
- if offset.y==0 and offset.x==0:
+ for offset.i in range(-1, 1+1):
+ for offset.j in range(-1, 1+1):
+ if offset.j==0 and offset.i==0:
# Empty space ends reaction
if iquad in (IHDOT, IHQUEST, IHBLANK, IHT, IHWEB):
pass
elif iquad == IHSTAR: # Affect another star
if withprob(0.05):
# This star supernovas
# Empty space ends reaction
if iquad in (IHDOT, IHQUEST, IHBLANK, IHT, IHWEB):
pass
elif iquad == IHSTAR: # Affect another star
if withprob(0.05):
# This star supernovas
game.state.starkl += 1
proutn(crmena(True, IHSTAR, "sector", neighbor))
prout(_(" novas."))
game.state.starkl += 1
proutn(crmena(True, IHSTAR, "sector", neighbor))
prout(_(" novas."))
game.state.baseq = filter(lambda x: x!= game.quadrant, game.state.baseq)
game.base.invalidate()
game.state.basekl += 1
newcnd()
prout(crmena(True, IHB, "sector", neighbor) + _(" destroyed."))
game.state.baseq = filter(lambda x: x!= game.quadrant, game.state.baseq)
game.base.invalidate()
game.state.basekl += 1
newcnd()
prout(crmena(True, IHB, "sector", neighbor) + _(" destroyed."))
elif iquad in (IHE, IHF): # Buffet ship
prout(_("***Starship buffeted by nova."))
if game.shldup:
elif iquad in (IHE, IHF): # Buffet ship
prout(_("***Starship buffeted by nova."))
if game.shldup:
break
newc = neighbor + neighbor - hits[mm]
proutn(crmena(True, iquad, "sector", neighbor) + _(" damaged"))
break
newc = neighbor + neighbor - hits[mm]
proutn(crmena(True, iquad, "sector", neighbor) + _(" damaged"))
if iquad1 == IHBLANK:
proutn(_(", blasted into ") + crmena(False, IHBLANK, "sector", newc))
skip(1)
if iquad1 == IHBLANK:
proutn(_(", blasted into ") + crmena(False, IHBLANK, "sector", newc))
skip(1)
- # Scheduled supernova -- select star
- # logic changed here so that we won't favor quadrants in top
- # left of universe
- for nq.x in range(GALSIZE):
- for nq.y in range(GALSIZE):
- stars += game.state.galaxy[nq.x][nq.y].stars
+ nq = coord()
+ for nq.i in range(GALSIZE):
+ for nq.j in range(GALSIZE):
+ stars += game.state.galaxy[nq.i][nq.j].stars
- for nq.x in range(GALSIZE):
- for nq.y in range(GALSIZE):
- num -= game.state.galaxy[nq.x][nq.y].stars
+ for nq.i in range(GALSIZE):
+ for nq.j in range(GALSIZE):
+ num -= game.state.galaxy[nq.i][nq.j].stars
- num = randrange(game.state.galaxy[nq.x][nq.y].stars) + 1
- for ns.x in range(QUADSIZE):
- for ns.y in range(QUADSIZE):
- if game.quad[ns.x][ns.y]==IHSTAR:
+ num = randrange(game.state.galaxy[nq.i][nq.j].stars) + 1
+ for ns.i in range(QUADSIZE):
+ for ns.j in range(QUADSIZE):
+ if game.quad[ns.i][ns.j]==IHSTAR:
- # destroy any Klingons in supernovaed quadrant
- kldead = game.state.galaxy[nq.x][nq.y].klingons
- game.state.galaxy[nq.x][nq.y].klingons = 0
+ # destroy any Klingons in supernovaed quadrant
+ kldead = game.state.galaxy[nq.i][nq.j].klingons
+ game.state.galaxy[nq.i][nq.j].klingons = 0
# Destroy any base in supernovaed quadrant
game.state.baseq = filter(lambda x: x != nq, game.state.baseq)
# If starship caused supernova, tally up destruction
# Destroy any base in supernovaed quadrant
game.state.baseq = filter(lambda x: x != nq, game.state.baseq)
# If starship caused supernova, tally up destruction
- if induced:
- game.state.starkl += game.state.galaxy[nq.x][nq.y].stars
- game.state.basekl += game.state.galaxy[nq.x][nq.y].starbase
+ if w != None:
+ game.state.starkl += game.state.galaxy[nq.i][nq.j].stars
+ game.state.basekl += game.state.galaxy[nq.i][nq.j].starbase
game.state.nplankl += npdead
# mark supernova in galaxy and in star chart
if game.quadrant == nq or communicating():
game.state.nplankl += npdead
# mark supernova in galaxy and in star chart
if game.quadrant == nq or communicating():
# If supernova destroys last Klingons give special message
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0 and not nq == game.quadrant:
skip(2)
# If supernova destroys last Klingons give special message
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0 and not nq == game.quadrant:
skip(2)
- deadkl(game.enemies[l].kloc, game.quad[game.enemies[l].kloc.x][game.enemies[l].kloc.y], game.enemies[l].kloc)
+ deadkl(game.enemies[l].kloc, game.quad[game.enemies[l].kloc.i][game.enemies[l].kloc.j], game.enemies[l].kloc)
def put_srscan_sym(w, sym):
"Emit symbol for short-range scan."
def put_srscan_sym(w, sym):
"Emit symbol for short-range scan."
if game.enemies:
for enemy in game.enemies:
finald = (w-enemy.kloc).distance()
enemy.kavgd = 0.5 * (finald + enemy.kdist)
enemy.kdist = finald
game.enemies.sort(lambda x, y: cmp(x.kdist, y.kdist))
if game.enemies:
for enemy in game.enemies:
finald = (w-enemy.kloc).distance()
enemy.kavgd = 0.5 * (finald + enemy.kdist)
enemy.kdist = finald
game.enemies.sort(lambda x, y: cmp(x.kdist, y.kdist))
game.dist = game.dist*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1
game.optime = scheduled(FTBEAM) - game.state.date + 1e-5
# Move within the quadrant
game.dist = game.dist*(scheduled(FTBEAM)-game.state.date)/game.optime + 0.1
game.optime = scheduled(FTBEAM) - game.state.date + 1e-5
# Move within the quadrant
# Leaving quadrant -- allow final enemy attack
# Don't do it if being pushed by Nova
if len(game.enemies) != 0 and not novapush:
# Leaving quadrant -- allow final enemy attack
# Don't do it if being pushed by Nova
if len(game.enemies) != 0 and not novapush:
- x = (QUADSIZE*game.quadrant.x)+game.sector.x
- y = (QUADSIZE*game.quadrant.y)+game.sector.y
- w.x = int(round(x+10.0*game.dist*bigger*deltax))
- w.y = int(round(y+10.0*game.dist*bigger*deltay))
+ x = (QUADSIZE*game.quadrant.i)+game.sector.i
+ y = (QUADSIZE*game.quadrant.j)+game.sector.j
+ w.i = int(round(x+10.0*game.dist*bigger*deltax))
+ w.j = int(round(y+10.0*game.dist*bigger*deltay))
- game.quadrant.x = w.x/QUADSIZE
- game.quadrant.y = w.y/QUADSIZE
- game.sector.x = w.x - (QUADSIZE*game.quadrant.x)
- game.sector.y = w.y - (QUADSIZE*game.quadrant.y)
+ game.quadrant.i = w.i/QUADSIZE
+ game.quadrant.j = w.j/QUADSIZE
+ game.sector.i = w.i - (QUADSIZE*game.quadrant.i)
+ game.sector.j = w.j - (QUADSIZE*game.quadrant.j)
break
if isprobe and akey != -1:
# For probe launch, use pre-scanned value first time
break
if isprobe and akey != -1:
# For probe launch, use pre-scanned value first time
prout(_("Ensign Chekov- \"Course laid in, Captain.\""))
# the actual deltas get computed here
delta = coord()
prout(_("Ensign Chekov- \"Course laid in, Captain.\""))
# the actual deltas get computed here
delta = coord()
- delta.x = dquad.y-game.quadrant.y + 0.1*(dsect.x-game.sector.y)
- delta.y = game.quadrant.x-dquad.x + 0.1*(game.sector.x-dsect.y)
+ delta.i = dquad.j-game.quadrant.j + 0.1*(dsect.j-game.sector.j)
+ delta.j = game.quadrant.i-dquad.i + 0.1*(game.sector.i-dsect.i)
break
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0:
finish(FWON) # Snova killed remaining enemy.
break
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)==0:
finish(FWON) # Snova killed remaining enemy.
# slow mode, so let Kirk know how many probes there are left
if game.nprobes == 1:
prout(_("1 probe left."))
# slow mode, so let Kirk know how many probes there are left
if game.nprobes == 1:
prout(_("1 probe left."))
proutn(_("Arm NOVAMAX warhead? "))
game.isarmed = ja()
if not getcourse(isprobe=True, akey=key):
proutn(_("Arm NOVAMAX warhead? "))
game.isarmed = ja()
if not getcourse(isprobe=True, akey=key):
- game.probex = game.quadrant.x*QUADSIZE + game.sector.x - 1 # We will use better packing than original
- game.probey = game.quadrant.y*QUADSIZE + game.sector.y - 1
+ game.probex = game.quadrant.i*QUADSIZE + game.sector.i - 1 # We will use better packing than original
+ game.probey = game.quadrant.j*QUADSIZE + game.sector.j - 1
game.probec = game.quadrant
schedule(FDSPROB, 0.01) # Time to move one sector
prout(_("Ensign Chekov- \"The deep space probe is launched, Captain.\""))
game.probec = game.quadrant
schedule(FDSPROB, 0.01) # Time to move one sector
prout(_("Ensign Chekov- \"The deep space probe is launched, Captain.\""))
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()
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()
# Dispose of crew
if not (game.options & OPTION_WORLDS) and not damaged(DTRANSP):
prout(_("Remainder of ship's complement beam down"))
# Dispose of crew
if not (game.options & OPTION_WORLDS) and not damaged(DTRANSP):
prout(_("Remainder of ship's complement beam down"))
# Set up quadrant and position FQ adjacient to base
if not game.quadrant == game.state.baseq[nb]:
game.quadrant = game.state.baseq[nb]
# Set up quadrant and position FQ adjacient to base
if not game.quadrant == game.state.baseq[nb]:
game.quadrant = game.state.baseq[nb]
- if VALID_SECTOR(game.sector.x, game.sector.y) and \
- game.quad[game.sector.x][game.sector.y] == IHDOT:
+ if VALID_SECTOR(game.sector.i, game.sector.j) and \
+ game.quad[game.sector.i][game.sector.j] == IHDOT:
game.state.crew = FULLCREW
prout(_("Starfleet puts you in command of another ship,"))
prout(_("the Faerie Queene, which is antiquated but,"))
game.state.crew = FULLCREW
prout(_("Starfleet puts you in command of another ship,"))
prout(_("the Faerie Queene, which is antiquated but,"))
- deadkl(game.enemies[1].kloc, game.quad[game.enemies[1].kloc.x][game.enemies[1].kloc.y],game.enemies[1].kloc)
+ deadkl(game.enemies[1].kloc, game.quad[game.enemies[1].kloc.i][game.enemies[1].kloc.j],game.enemies[1].kloc)
prout(_("Ensign Chekov- \"Congratulations, Captain!\""))
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem) == 0:
finish(FWON)
prout(_("Ensign Chekov- \"Congratulations, Captain!\""))
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem) == 0:
finish(FWON)
def sectscan(goodScan, i, j):
"Light up an individual dot in a sector."
def sectscan(goodScan, i, j):
"Light up an individual dot in a sector."
if (game.quad[i][j]==IHMATER0) or (game.quad[i][j]==IHMATER1) or (game.quad[i][j]==IHMATER2) or (game.quad[i][j]==IHE) or (game.quad[i][j]==IHF):
if game.condition == "red": textcolor("red")
elif game.condition == "green": textcolor("green")
if (game.quad[i][j]==IHMATER0) or (game.quad[i][j]==IHMATER1) or (game.quad[i][j]==IHMATER2) or (game.quad[i][j]==IHE) or (game.quad[i][j]==IHF):
if game.condition == "red": textcolor("red")
elif game.condition == "green": textcolor("green")
if plnet and plnet.inhabited:
prstat(_("Major system"), plnet.name)
else:
if plnet and plnet.inhabited:
prstat(_("Major system"), plnet.name)
else:
def request():
"Request specified status data, a historical relic from slow TTYs."
requests = ("da","co","po","ls","wa","en","to","sh","kl","sy", "ti")
def request():
"Request specified status data, a historical relic from slow TTYs."
requests = ("da","co","po","ls","wa","en","to","sh","kl","sy", "ti")
- game.state.chart[game.quadrant.x][game.quadrant.y].klingons = game.state.galaxy[game.quadrant.x][game.quadrant.y].klingons
- game.state.chart[game.quadrant.x][game.quadrant.y].starbase = game.state.galaxy[game.quadrant.x][game.quadrant.y].starbase
- game.state.chart[game.quadrant.x][game.quadrant.y].stars = game.state.galaxy[game.quadrant.x][game.quadrant.y].stars
- game.state.galaxy[game.quadrant.x][game.quadrant.y].charted = True
+ 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
+ game.state.galaxy[game.quadrant.i][game.quadrant.j].charted = True
- w1.x = int(scanner.real-0.5)
- if scanner.next() == IHREAL:
- w2.y = int(scanner.real-0.5)
- if scanner.next() != IHREAL:
+ w1.i = int(scanner.real-0.5)
+ if scanner.next() == "IHREAL":
+ w2.j = int(scanner.real-0.5)
+ if scanner.next() != "IHREAL":
- game.dist = math.sqrt((w1.y-game.quadrant.y+0.1*(w2.y-game.sector.y))**2+
- (w1.x-game.quadrant.x+0.1*(w2.x-game.sector.x))**2)
+ game.dist = math.sqrt((w1.j-game.quadrant.j+0.1*(w2.j-game.sector.j))**2+
+ (w1.i-game.quadrant.i+0.1*(w2.i-game.sector.i))**2)
(scheduled(FCDBAS)<ttime+game.state.date and game.battle == w1):
prout(_("The starbase there will be destroyed by then."))
proutn(_("New warp factor to try? "))
(scheduled(FCDBAS)<ttime+game.state.date and game.battle == w1):
prout(_("The starbase there will be destroyed by then."))
proutn(_("New warp factor to try? "))
- if not game.state.galaxy[w.x][w.y].supernova and \
- game.state.galaxy[w.x][w.y].klingons + klump <= MAXKLQUAD:
+ if not game.state.galaxy[w.i][w.j].supernova and \
+ game.state.galaxy[w.i][w.j].klingons + klump <= MAXKLQUAD:
game.state.kcmdr.append(w)
# Locate planets in galaxy
for i in range(game.inplan):
while True:
w = randplace(GALSIZE)
game.state.kcmdr.append(w)
# Locate planets in galaxy
for i in range(game.inplan):
while True:
w = randplace(GALSIZE)
# Initialize times for extraneous events
schedule(FSNOVA, expran(0.5 * game.intime))
schedule(FTBEAM, expran(1.5 * (game.intime / len(game.state.kcmdr))))
# Initialize times for extraneous events
schedule(FSNOVA, expran(0.5 * game.intime))
schedule(FTBEAM, expran(1.5 * (game.intime / len(game.state.kcmdr))))
elif game.skill == SKILL_NONE:
proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "))
# Choose game options -- added by ESR for SST2K
elif game.skill == SKILL_NONE:
proutn(_("Are you a Novice, Fair, Good, Expert, or Emeritus player? "))
# Choose game options -- added by ESR for SST2K
for cmdr in game.state.kcmdr:
if cmdr == game.quadrant:
e = game.enemies[game.klhere-1]
for cmdr in game.state.kcmdr:
if cmdr == game.quadrant:
e = game.enemies[game.klhere-1]
e.kpower = randreal(950,1350) + 50.0*game.skill
break
# If we need a super-commander, promote a Klingon
if game.quadrant == game.state.kscmdr:
e = game.enemies[0]
e.kpower = randreal(950,1350) + 50.0*game.skill
break
# If we need a super-commander, promote a Klingon
if game.quadrant == game.state.kscmdr:
e = game.enemies[0]
e.kpower = randreal(1175.0, 1575.0) + 125.0*game.skill
game.iscate = (game.state.remkl > 1)
# Put in Romulans if needed
e.kpower = randreal(1175.0, 1575.0) + 125.0*game.skill
game.iscate = (game.state.remkl > 1)
# Put in Romulans if needed
- w.x = withprob(0.5) * (QUADSIZE-1)
- w.y = withprob(0.5) * (QUADSIZE-1)
- if game.quad[w.x][w.y] == IHDOT:
+ w.i = withprob(0.5) * (QUADSIZE-1)
+ w.j = withprob(0.5) * (QUADSIZE-1)
+ if game.quad[w.i][w.j] == IHDOT:
break
game.tholian = enemy(type=IHT, loc=w,
power=randrange(100, 500) + 25.0*game.skill)
break
game.tholian = enemy(type=IHT, loc=w,
power=randrange(100, 500) + 25.0*game.skill)
"Generate a list of legal commands."
proutn(_("LEGAL COMMANDS ARE:"))
for (k, key) in enumerate(commands):
"Generate a list of legal commands."
proutn(_("LEGAL COMMANDS ARE:"))
for (k, key) in enumerate(commands):
ev = schedule(i, scanner.real)
if i == FENSLV or i == FREPRO:
scanner.chew()
proutn("In quadrant- ")
key = scanner.next()
ev = schedule(i, scanner.real)
if i == FENSLV or i == FREPRO:
scanner.chew()
proutn("In quadrant- ")
key = scanner.next()