projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Most of the 2to3 translation. All regression tests pass.
[super-star-trek.git]
/
sst.py
diff --git
a/sst.py
b/sst.py
index be11f15c853c298f27afbc93229ccf3bef7191ac..6ccccff7a90b484bb48d313a9e71d1f6fcb37f44 100755
(executable)
--- a/
sst.py
+++ b/
sst.py
@@
-11,7
+11,7
@@
Stas Sergeev, and Eric S. Raymond.
See the doc/HACKING file in the distribution for designers notes and advice
on how to modify (and how not to modify!) this code.
"""
See the doc/HACKING file in the distribution for designers notes and advice
on how to modify (and how not to modify!) this code.
"""
-import os, sys, math, curses, time, readline,
cP
ickle, random, copy, gettext, getpass
+import os, sys, math, curses, time, readline,
p
ickle, random, copy, gettext, getpass
version = "2.1"
version = "2.1"
@@
-1173,12
+1173,12
@@
def torpedo(origin, bearing, dispersion, number, nburst):
break
else:
prout("Internal error, no enemy where expected!")
break
else:
prout("Internal error, no enemy where expected!")
- raise SystemExit
, 1
+ raise SystemExit
(1)
return None
elif iquad == 'B': # Hit a base
skip(1)
prout(_("***STARBASE DESTROYED.."))
return None
elif iquad == 'B': # Hit a base
skip(1)
prout(_("***STARBASE DESTROYED.."))
- game.state.baseq =
filter(lambda x: x != game.quadrant, game.state.baseq)
+ game.state.baseq =
[x for x in game.state.baseq if x != game.quadrant]
game.quad[w.i][w.j] = '.'
game.base.invalidate()
game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase = False
game.quad[w.i][w.j] = '.'
game.base.invalidate()
game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase = False
@@
-2099,7
+2099,7
@@
def events():
game.state.chart[game.battle.i][game.battle.j].starbase = False
# Remove Starbase from galaxy
game.state.galaxy[game.battle.i][game.battle.j].starbase = False
game.state.chart[game.battle.i][game.battle.j].starbase = False
# Remove Starbase from galaxy
game.state.galaxy[game.battle.i][game.battle.j].starbase = False
- game.state.baseq =
filter(lambda x: x != game.battle, game.state.baseq)
+ game.state.baseq =
[x for x in game.state.baseq if x != game.battle]
if game.isatb == 2:
# reinstate a commander's base attack
game.battle = hold
if game.isatb == 2:
# reinstate a commander's base attack
game.battle = hold
@@
-2523,7
+2523,7
@@
def nova(nov):
game.quad[neighbor.i][neighbor.j] = '.'
elif iquad == 'B': # Destroy base
game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase = False
game.quad[neighbor.i][neighbor.j] = '.'
elif iquad == 'B': # Destroy base
game.state.galaxy[game.quadrant.i][game.quadrant.j].starbase = False
- game.state.baseq =
filter(lambda x: x!= game.quadrant, game.state.baseq)
+ game.state.baseq =
[x for x in game.state.baseq if x!= game.quadrant]
game.base.invalidate()
game.state.basekl += 1
newcnd()
game.base.invalidate()
game.state.basekl += 1
newcnd()
@@
-2673,7
+2673,7
@@
def supernova(w):
game.state.planets[loop].pclass = "destroyed"
npdead += 1
# Destroy any base in supernovaed quadrant
game.state.planets[loop].pclass = "destroyed"
npdead += 1
# Destroy any base in supernovaed quadrant
- game.state.baseq =
filter(lambda x: x != nq, game.state.baseq)
+ game.state.baseq =
[x for x in game.state.baseq if x != nq]
# If starship caused supernova, tally up destruction
if w != None:
game.state.starkl += game.state.galaxy[nq.i][nq.j].stars
# If starship caused supernova, tally up destruction
if w != None:
game.state.starkl += game.state.galaxy[nq.i][nq.j].stars
@@
-3205,7
+3205,7
@@
def pause_game():
sys.stdout.write('\n')
proutn(prompt)
if not replayfp:
sys.stdout.write('\n')
proutn(prompt)
if not replayfp:
-
raw_
input()
+ input()
sys.stdout.write('\n' * rows)
linecount = 0
sys.stdout.write('\n' * rows)
linecount = 0
@@
-3277,7
+3277,7
@@
def cgetline():
elif line[0] != "#":
break
else:
elif line[0] != "#":
break
else:
- line =
raw_input(
) + "\n"
+ line =
eval(input()
) + "\n"
if logfp:
logfp.write(line)
return line
if logfp:
logfp.write(line)
return line
@@
-3612,7
+3612,7
@@
def imove(icourse=None, noattack=False):
newquadrant(noattack)
break
elif check_collision(w):
newquadrant(noattack)
break
elif check_collision(w):
- print
"Collision detected"
+ print
("Collision detected")
break
else:
game.sector = w
break
else:
game.sector = w
@@
-5057,7
+5057,7
@@
def status(req=0):
if game.condition != "docked":
newcnd()
prstat(_("Condition"), _("%s, %i DAMAGES") % \
if game.condition != "docked":
newcnd()
prstat(_("Condition"), _("%s, %i DAMAGES") % \
- (game.condition.upper(), sum(
map(lambda x: x > 0, game.damage)
)))
+ (game.condition.upper(), sum(
[x > 0 for x in game.damage]
)))
if not req or req == 3:
prstat(_("Position"), "%s , %s" % (game.quadrant, game.sector))
if not req or req == 4:
if not req or req == 3:
prstat(_("Position"), "%s , %s" % (game.quadrant, game.sector))
if not req or req == 4:
@@
-5291,7
+5291,7
@@
def freeze(boss):
except IOError:
prout(_("Can't freeze game as file %s") % scanner.token)
return
except IOError:
prout(_("Can't freeze game as file %s") % scanner.token)
return
-
cP
ickle.dump(game, fp)
+
p
ickle.dump(game, fp)
fp.close()
scanner.chew()
fp.close()
scanner.chew()
@@
-5313,7
+5313,7
@@
def thaw():
except IOError:
prout(_("Can't thaw game in %s") % scanner.token)
return
except IOError:
prout(_("Can't thaw game in %s") % scanner.token)
return
- game =
cP
ickle.load(fp)
+ game =
p
ickle.load(fp)
fp.close()
scanner.chew()
return False
fp.close()
scanner.chew()
return False
@@
-5584,7
+5584,7
@@
def setup():
prout(_("%d stardates.") % int(game.intime))
proutn(_("%d starbases in ") % game.inbase)
for i in range(game.inbase):
prout(_("%d stardates.") % int(game.intime))
proutn(_("%d starbases in ") % game.inbase)
for i in range(game.inbase):
- proutn(
`game.state.baseq[i]`
)
+ proutn(
repr(game.state.baseq[i])
)
proutn(" ")
skip(2)
proutn(_("The Enterprise is currently in Quadrant %s") % game.quadrant)
proutn(" ")
skip(2)
proutn(_("The Enterprise is currently in Quadrant %s") % game.quadrant)
@@
-5932,7
+5932,7
@@
def helpme():
setwnd(message_window)
if key == "IHEOL":
return
setwnd(message_window)
if key == "IHEOL":
return
- cmds =
map(lambda x: x[0], commands)
+ cmds =
[x[0] for x in commands]
if scanner.token.upper() in cmds or scanner.token.upper() == "ABBREV":
break
skip(1)
if scanner.token.upper() in cmds or scanner.token.upper() == "ABBREV":
break
skip(1)
@@
-6081,7
+6081,7
@@
def makemoves():
elif cmd == "EMEXIT": # Emergency exit
clrscr() # Hide screen
freeze(True) # forced save
elif cmd == "EMEXIT": # Emergency exit
clrscr() # Hide screen
freeze(True) # forced save
- raise SystemExit
,1
# And quick exit
+ raise SystemExit
(1)
# And quick exit
elif cmd == "PROBE":
probe() # Launch probe
if game.ididit:
elif cmd == "PROBE":
probe() # Launch probe
if game.ididit:
@@
-6160,7
+6160,7
@@
def crmena(stars, enemy, loctype, w):
buf += _("Quadrant ")
elif loctype == "sector":
buf += _("Sector ")
buf += _("Quadrant ")
elif loctype == "sector":
buf += _("Sector ")
- return buf +
`w`
+ return buf +
repr(w)
def crmshp():
"Emit our ship name."
def crmshp():
"Emit our ship name."
@@
-6378,7
+6378,7
@@
if __name__ == '__main__':
replayfp = open(val, "r")
except IOError:
sys.stderr.write("sst: can't open replay file %s\n" % val)
replayfp = open(val, "r")
except IOError:
sys.stderr.write("sst: can't open replay file %s\n" % val)
- raise SystemExit
, 1
+ raise SystemExit
(1)
try:
line = replayfp.readline().strip()
(leader, __, seed) = line.split()
try:
line = replayfp.readline().strip()
(leader, __, seed) = line.split()
@@
-6400,11
+6400,11
@@
if __name__ == '__main__':
elif switch == '-x':
game.idebug = True
elif switch == '-V':
elif switch == '-x':
game.idebug = True
elif switch == '-V':
- print
"SST2K", version
- raise SystemExit
, 0
+ print
("SST2K", version)
+ raise SystemExit
(0)
else:
sys.stderr.write("usage: sst [-t] [-x] [startcommand...].\n")
else:
sys.stderr.write("usage: sst [-t] [-x] [startcommand...].\n")
- raise SystemExit
, 1
+ raise SystemExit
(1)
# where to save the input in case of bugs
if "TMPDIR" in os.environ:
tmpdir = os.environ['TMPDIR']
# where to save the input in case of bugs
if "TMPDIR" in os.environ:
tmpdir = os.environ['TMPDIR']
@@
-6423,7
+6423,8
@@
if __name__ == '__main__':
(getpass.getuser(),socket.gethostname(),time.ctime()))
random.seed(seed)
scanner = sstscanner()
(getpass.getuser(),socket.gethostname(),time.ctime()))
random.seed(seed)
scanner = sstscanner()
- map(scanner.append, arguments)
+ for arg in arguments:
+ scanner.append(arg)
try:
iostart()
while True: # Play a game
try:
iostart()
while True: # Play a game
@@
-6455,10
+6456,10
@@
if __name__ == '__main__':
prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
finally:
ioend()
prout(_("May the Great Bird of the Galaxy roost upon your home planet."))
finally:
ioend()
- raise SystemExit
, 0
+ raise SystemExit
(0)
except KeyboardInterrupt:
if logfp:
logfp.close()
except KeyboardInterrupt:
if logfp:
logfp.close()
- print
""
+ print
("")
# End.
# End.