projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Comment fix.
[super-star-trek.git]
/
src
/
sst.py
diff --git
a/src/sst.py
b/src/sst.py
index c1785eee38962934c1ae1d4054bd2e0101dae32c..5e0aa69269ee0503fcf9d07ccb6217ea545fa8aa 100644
(file)
--- a/
src/sst.py
+++ b/
src/sst.py
@@
-319,7
+319,7
@@
class gamestate:
self.iplnet = None # planet # in quadrant
self.inplan = 0 # initial planets
self.irhere = 0 # Romulans in quadrant
self.iplnet = None # planet # in quadrant
self.inplan = 0 # initial planets
self.irhere = 0 # Romulans in quadrant
- self.isatb = 0 # =
1
if super commander is attacking base
+ self.isatb = 0 # =
2
if super commander is attacking base
self.tourn = None # tournament number
self.nprobes = 0 # number of probes available
self.inresor = 0.0 # initial resources
self.tourn = None # tournament number
self.nprobes = 0 # number of probes available
self.inresor = 0.0 # initial resources
@@
-649,7
+649,7
@@
def movescom(iq, avoid):
game.state.kscmdr = iq
game.state.galaxy[game.state.kscmdr.i][game.state.kscmdr.j].klingons += 1
if game.state.kscmdr==game.quadrant:
game.state.kscmdr = iq
game.state.galaxy[game.state.kscmdr.i][game.state.kscmdr.j].klingons += 1
if game.state.kscmdr==game.quadrant:
- # SC has scooted,
R
emove him from current quadrant
+ # SC has scooted,
r
emove him from current quadrant
game.iscate=False
game.isatb=0
game.ientesc = False
game.iscate=False
game.isatb=0
game.ientesc = False
@@
-870,7
+870,6
@@
def doshield(shraise):
if action=="NONE":
proutn(_("Do you wish to change shield energy? "))
if ja() == True:
if action=="NONE":
proutn(_("Do you wish to change shield energy? "))
if ja() == True:
- proutn(_("Energy to transfer to shields- "))
action = "NRG"
elif damaged(DSHIELD):
prout(_("Shields damaged and down."))
action = "NRG"
elif damaged(DSHIELD):
prout(_("Shields damaged and down."))
@@
-918,21
+917,22
@@
def doshield(shraise):
while scanner.next() != "IHREAL":
scanner.chew()
proutn(_("Energy to transfer to shields- "))
while scanner.next() != "IHREAL":
scanner.chew()
proutn(_("Energy to transfer to shields- "))
+ nrg = scanner.real
scanner.chew()
scanner.chew()
- if
scanner.real
== 0:
+ if
nrg
== 0:
return
return
- if
scanner.real
> game.energy:
+ if
nrg
> game.energy:
prout(_("Insufficient ship energy."))
return
game.ididit = True
prout(_("Insufficient ship energy."))
return
game.ididit = True
- if game.shield+
scanner.real
>= game.inshld:
+ if game.shield+
nrg
>= game.inshld:
prout(_("Shield energy maximized."))
prout(_("Shield energy maximized."))
- if game.shield+
scanner.real
> game.inshld:
+ if game.shield+
nrg
> game.inshld:
prout(_("Excess energy requested returned to ship energy"))
game.energy -= game.inshld-game.shield
game.shield = game.inshld
return
prout(_("Excess energy requested returned to ship energy"))
game.energy -= game.inshld-game.shield
game.shield = game.inshld
return
- if
scanner.real < 0.0 and game.energy-scanner.real
> game.inenrg:
+ if
nrg < 0.0 and game.energy-nrg
> game.inenrg:
# Prevent shield drain loophole
skip(1)
prout(_("Engineering to bridge--"))
# Prevent shield drain loophole
skip(1)
prout(_("Engineering to bridge--"))
@@
-940,18
+940,18
@@
def doshield(shraise):
prout(_(" I can't drain the shields."))
game.ididit = False
return
prout(_(" I can't drain the shields."))
game.ididit = False
return
- if game.shield+
scanner.real
< 0:
+ if game.shield+
nrg
< 0:
prout(_("All shield energy transferred to ship."))
game.energy += game.shield
game.shield = 0.0
return
proutn(_("Scotty- \""))
prout(_("All shield energy transferred to ship."))
game.energy += game.shield
game.shield = 0.0
return
proutn(_("Scotty- \""))
- if
scanner.real
> 0:
+ if
nrg
> 0:
prout(_("Transferring energy to shields.\""))
else:
prout(_("Draining energy from shields.\""))
prout(_("Transferring energy to shields.\""))
else:
prout(_("Draining energy from shields.\""))
- game.shield +=
scanner.real
- game.energy -=
scanner.real
+ game.shield +=
nrg
+ game.energy -=
nrg
return
def randdevice():
return
def randdevice():
@@
-970,11
+970,12
@@
def randdevice():
15, # DCOMPTR: computer 1.5%
20, # NAVCOMP: navigation system 2.0%
75, # DTRANSP: transporter 7.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%
+ 20, # DSHCTRL: high-speed shield controller
2.0%
10, # DDRAY: death ray 1.0%
30, # DDSP: deep-space probes 3.0%
)
10, # DDRAY: death ray 1.0%
30, # DDSP: deep-space probes 3.0%
)
- idx = randrange(1000) # weights must sum to 1000
+ assert(sum(weights) == 1000)
+ idx = randrange(1000)
sum = 0
for (i, w) in enumerate(weights):
sum += w
sum = 0
for (i, w) in enumerate(weights):
sum += w
@@
-2326,7
+2327,7
@@
def events():
else:
prout(_("Uhura- Starfleet reports increased Klingon activity"))
if q.planet != None:
else:
prout(_("Uhura- Starfleet reports increased Klingon activity"))
if q.planet != None:
- proutn(_("near %s") % q.planet)
+ proutn(_("near %s
") % q.planet)
prout(_("in Quadrant %s.") % w)
def wait():
prout(_("in Quadrant %s.") % w)
def wait():
@@
-2904,8
+2905,6
@@
def score():
klship = 1
else:
klship = 2
klship = 1
else:
klship = 2
- if not game.gamewon:
- game.state.nromrem = 0 # None captured if no win
iscore = 10*(game.inkling - game.state.remkl) \
+ 50*(game.incom - len(game.state.kcmdr)) \
+ ithperd + iwon \
iscore = 10*(game.inkling - game.state.remkl) \
+ 50*(game.incom - len(game.state.kcmdr)) \
+ ithperd + iwon \
@@
-2920,7
+2919,7
@@
def score():
if game.inrom - game.state.nromrem:
prout(_("%6d Romulans destroyed %5d") %
(game.inrom - game.state.nromrem, 20*(game.inrom - game.state.nromrem)))
if game.inrom - game.state.nromrem:
prout(_("%6d Romulans destroyed %5d") %
(game.inrom - game.state.nromrem, 20*(game.inrom - game.state.nromrem)))
- if game.state.nromrem:
+ if game.state.nromrem
and game.gamewon
:
prout(_("%6d Romulans captured %5d") %
(game.state.nromrem, game.state.nromrem))
if game.inkling - game.state.remkl:
prout(_("%6d Romulans captured %5d") %
(game.state.nromrem, game.state.nromrem))
if game.inkling - game.state.remkl:
@@
-2943,7
+2942,7
@@
def score():
(game.state.nplankl, -10*game.state.nplankl))
if (game.options & OPTION_WORLDS) and game.state.nworldkl:
prout(_("%6d inhabited planets destroyed by your action %5d") %
(game.state.nplankl, -10*game.state.nplankl))
if (game.options & OPTION_WORLDS) and game.state.nworldkl:
prout(_("%6d inhabited planets destroyed by your action %5d") %
- (game.state.n
plan
kl, -300*game.state.nworldkl))
+ (game.state.n
world
kl, -300*game.state.nworldkl))
if game.state.basekl:
prout(_("%6d bases destroyed by your action %5d") %
(game.state.basekl, -100*game.state.basekl))
if game.state.basekl:
prout(_("%6d bases destroyed by your action %5d") %
(game.state.basekl, -100*game.state.basekl))
@@
-4460,7
+4459,7
@@
def usecrystals():
skip(1)
prouts(_("Scotty- \"Keep your fingers crossed, Sir!\""))
skip(1)
skip(1)
prouts(_("Scotty- \"Keep your fingers crossed, Sir!\""))
skip(1)
- if with(game.cryprob):
+ if with
prob
(game.cryprob):
prouts(_(" \"Activating now! - - No good! It's***"))
skip(2)
prouts(_("***RED ALERT! RED A*L********************************"))
prouts(_(" \"Activating now! - - No good! It's***"))
skip(2)
prouts(_("***RED ALERT! RED A*L********************************"))
@@
-5473,7
+5472,7
@@
def choose():
# Choose game options -- added by ESR for SST2K
if scanner.next() != "IHALPHA":
scanner.chew()
# Choose game options -- added by ESR for SST2K
if scanner.next() != "IHALPHA":
scanner.chew()
- proutn(_("Choose your game style (or just press enter): "))
+ proutn(_("Choose your game style (
plain, almy, fancy
or just press enter): "))
scanner.next()
if scanner.sees("plain"):
# Approximates the UT FORTRAN version.
scanner.next()
if scanner.sees("plain"):
# Approximates the UT FORTRAN version.
@@
-6199,10
+6198,15
@@
if __name__ == '__main__':
sys.stderr.write("usage: sst [-t] [-x] [startcommand...].\n")
raise SystemExit, 1
# where to save the input in case of bugs
sys.stderr.write("usage: sst [-t] [-x] [startcommand...].\n")
raise SystemExit, 1
# where to save the input in case of bugs
+ if "TMPDIR" in os.environ:
+ tmpdir = os.environ['TMPDIR']
+ else:
+ tmpdir = "/tmp"
try:
try:
- logfp = open(
"/usr/tmp/sst-input.log"
, "w")
+ logfp = open(
os.path.join(tmpdir, "sst-input.log")
, "w")
except IOError:
sys.stderr.write("sst: warning, can't open logfile\n")
except IOError:
sys.stderr.write("sst: warning, can't open logfile\n")
+ sys.exit(1)
if logfp:
logfp.write("# seed %s\n" % seed)
logfp.write("# options %s\n" % " ".join(arguments))
if logfp:
logfp.write("# seed %s\n" % seed)
logfp.write("# options %s\n" % " ".join(arguments))