return "%s - %s" % (self.i+1, self.j+1)
__repr__ = __str__
+class Thingy(Coord):
+ "Do not anger the Space Thingy!"
+ def __init__(self):
+ Coord.__init__(self)
+ self.angered = False
+ def angry(self):
+ self.angered = True
+
class Planet:
def __init__(self):
self.name = None # string-valued if inhabited
def movebaddy(enemy):
"Tactical movement for the bad guys."
- goto = Coord(); look = Coord()
+ goto = Coord()
+ look = Coord()
irun = False
# This should probably be just (game.quadrant in game.state.kcmdr) + (game.state.kscmdr==game.quadrant)
if game.skill >= SKILL_EXPERT:
dist1 = enemy.kdist
mdist = int(dist1 + 0.5) # Nearest integer distance
# If SC, check with spy to see if should hi-tail it
- if enemy.type=='S' and \
+ if enemy.type == 'S' and \
(enemy.power <= 500.0 or (game.condition=="docked" and not damaged(DPHOTON))):
irun = True
motion = -QUADSIZE
if success:
goto = look
if game.idebug:
- proutn(`goto`)
+ proutn(repr(goto))
else:
break # done early
if game.idebug:
for enemy in game.enemies:
if enemy.type == 'C':
movebaddy(enemy)
- if game.state.kscmdr==game.quadrant:
+ if game.state.kscmdr == game.quadrant:
for enemy in game.enemies:
if enemy.type == 'S':
movebaddy(enemy)
game.state.galaxy[game.state.kscmdr.i][game.state.kscmdr.j].klingons -= 1
game.state.kscmdr = iq
game.state.galaxy[game.state.kscmdr.i][game.state.kscmdr.j].klingons += 1
- if game.state.kscmdr==game.quadrant:
+ if game.state.kscmdr == game.quadrant:
# SC has scooted, remove him from current quadrant
game.iscate = False
game.isatb = 0
def supercommander():
"Move the Super Commander."
- iq = Coord(); sc = Coord(); ibq = Coord(); idelta = Coord()
+ iq = Coord()
+ sc = Coord()
+ ibq = Coord()
+ idelta = Coord()
basetbl = []
if game.idebug:
prout("== SUPERCOMMANDER")
game.tholian.move(here)
# check to see if all holes plugged
for i in range(QUADSIZE):
- if game.quad[0][i]!='#' and game.quad[0][i]!='T':
+ if game.quad[0][i] != '#' and game.quad[0][i] != 'T':
return
- if game.quad[QUADSIZE-1][i]!='#' and game.quad[QUADSIZE-1][i]!='T':
+ if game.quad[QUADSIZE-1][i] != '#' and game.quad[QUADSIZE-1][i] != 'T':
return
- if game.quad[i][0]!='#' and game.quad[i][0]!='T':
+ if game.quad[i][0] != '#' and game.quad[i][0] != 'T':
return
- if game.quad[i][QUADSIZE-1]!='#' and game.quad[i][QUADSIZE-1]!='T':
+ if game.quad[i][QUADSIZE-1] != '#' and game.quad[i][QUADSIZE-1] != 'T':
return
# All plugged up -- Tholian splits
- game.quad[game.tholian.location.i][game.tholian.location.j]='#'
+ game.quad[game.tholian.location.i][game.tholian.location.j] = '#'
dropin(' ')
prout(crmena(True, 'T', "sector", game.tholian) + _(" completes web."))
game.tholian.move(None)
prout(_("Shields raising uses up last of energy."))
finish(FNRG)
return
- game.ididit=True
+ game.ididit = True
return
elif action == "SHDN":
if not game.shldup:
prout(_("Shields already down."))
return
- game.shldup=False
- game.shldchg=True
+ game.shldup = False
+ game.shldchg = True
prout(_("Shields lowered."))
game.ididit = True
return
# Loop to move a single torpedo
setwnd(message_window)
for step in range(1, QUADSIZE*2):
- if not track.next(): break
+ if not track.next():
+ break
w = track.sector()
if not w.valid_sector():
break
- iquad=game.quad[w.i][w.j]
+ iquad = game.quad[w.i][w.j]
tracktorpedo(w, step, number, nburst, iquad)
if iquad == '.':
continue
if game.quad[bumpto.i][bumpto.j] == ' ':
finish(FHOLE)
return hit
- if game.quad[bumpto.i][bumpto.j]!='.':
+ if game.quad[bumpto.i][bumpto.j] != '.':
# can't move into object
return hit
game.sector = bumpto
else:
prout(_(" damaged-- displaced by blast to Sector %s ")%bumpto)
enemy.location = bumpto
- game.quad[w.i][w.j]='.'
- game.quad[bumpto.i][bumpto.j]=iquad
+ game.quad[w.i][w.j] = '.'
+ game.quad[bumpto.i][bumpto.j] = iquad
for enemy in game.enemies:
enemy.kdist = enemy.kavgd = (game.sector-enemy.location).distance()
sortenemies()
# 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
+ thing.angry()
return None
elif iquad == ' ': # Black hole
skip(1)
prout(_(" damaged."))
if damaged(DSHIELD) and game.shldup:
prout(_("***Shields knocked down."))
- game.shldup=False
+ game.shldup = False
def attack(torps_ok):
# bad guy attacks us
return
attempt = False
ihurt = False
- hitmax=0.0; hittot=0.0; chgfac=1.0
+ hitmax = 0.0
+ hittot = 0.0
+ chgfac = 1.0
where = "neither"
if game.idebug:
prout("=== ATTACK!")
if (((game.quadrant in game.state.kcmdr or game.state.kscmdr == game.quadrant) and not game.justin) or game.skill == SKILL_EMERITUS) and torps_ok:
moveklings()
# if no enemies remain after movement, we're done
- if len(game.enemies) == 0 or (len(game.enemies) == 1 and thing == game.quadrant and not thing.angry):
+ if len(game.enemies) == 0 or (len(game.enemies) == 1 and thing == game.quadrant and not thing.angered):
return
# set up partial hits if attack happens during shield status change
pfac = 1.0/game.inshld
r *= 0.25
if enemy.power < 500:
r *= 0.25
- if enemy.type == 'T' or (enemy.type == '?' and not thing.angry):
+ if enemy.type == 'T' or (enemy.type == '?' and not thing.angered):
continue
# different enemies have different probabilities of throwing a torp
usephasers = not torps_ok or \
huh()
return None
delta = Coord()
- # FIXME: C code this was translated from is wacky -- why the sign reversal?
+ # C code this was translated from is wacky -- why the sign reversal?
delta.j = (w.j - game.sector.j)
delta.i = (game.sector.i - w.i)
if delta == Coord(0, 0):
else:
proutn(_("Very small hit on "))
ienm = game.quad[w.i][w.j]
- if ienm=='?':
- thing.angry = True
+ if ienm == '?':
+ thing.angry()
proutn(crmena(False, ienm, "sector", w))
skip(1)
if kpow == 0:
kk -= 1 # don't do the increment
continue
else: # decide whether or not to emasculate klingon
- if kpow>0 and withprob(0.9) and kpow <= randreal(0.4, 0.8)*kpini:
+ if kpow > 0 and withprob(0.9) and kpow <= randreal(0.4, 0.8)*kpini:
prout(_("***Mr. Spock- \"Captain, the vessel at Sector %s")%w)
prout(_(" has just lost its firepower.\""))
game.enemies[kk].power = -kpow
try:
global line, thing, game
game = None
- thing = Coord()
- thing.angry = False
+ thing = Thingy()
game = Gamestate()
game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_PLAIN | OPTION_ALMY)
if os.getenv("TERM"):