except ImportError:
pass
+# Prevent lossage under Python 3
+try:
+ my_input = raw_input
+except NameError:
+ my_input = input
+
+
version = "2.1"
docpath = (".", "doc/", "/usr/share/doc/sst/")
return
else:
if not game.iscloaked:
- proutn(_("Switch cloaking device on?"))
+ proutn(_("Switch cloaking device on? "))
if not ja():
return
action = "CLON"
else:
- proutn(_("Switch cloaking device off?"))
+ proutn(_("Switch cloaking device off? "))
if not ja():
return
action = "CLOFF"
if not ja():
return;
prout("Engineer Scott- \"Aye, Sir.\"");
- game.iscloaked = FALSE;
+ game.iscloaked = False;
if game.irhere and game.state.date >= ALGERON and not game.isviolreported:
prout(_("The Romulan ship discovers you are breaking the Treaty of Algeron!"))
game.ncviol += 1
return;
if action == "CLON":
- if damage(DCLOAK):
+ if damaged(DCLOAK):
prout(_("Engineer Scott- \"The cloaking device is damaged, Sir.\""))
return;
prout(_("You cannot cloak while docked."))
if game.state.date >= ALGERON and not game.isviolreported:
- prout(_("Spock- \"Captain, using the cloaking device is be a violation"))
+ prout(_("Spock- \"Captain, using the cloaking device is a violation"))
prout(_(" of the Treaty of Algeron. Considering the alternatives,"))
- proutn(" are you sure this is wise?");
+ proutn(_(" are you sure this is wise? "))
if not ja():
return
prout(_("Engineer Scott- \"Cloaking device has engaging, Sir...\""))
# Nah, just select the weakest one since it is most likely to
# surrender (Tom Almy mod)
klingons = [e for e in game.enemies if e.type == 'K']
- weakest = sorted(klingons, key=lambda e: e.power)
+ weakest = sorted(klingons, key=lambda e: e.power)[0]
game.optime = 0.05 # This action will take some time
game.ididit = True # So any others can strike back
# intelligent design
# x = 300 + 25*skill;
x = game.energy / (weakest.power * len(klingons))
- x *= 2.5; # would originally have been equivalent of 1.4,
+ #prout(_("Stats: energy = %s, kpower = %s, klingons = %s")
+ # % (game.energy, weakest.power, len(klingons)))
+ x *= 2.5 # would originally have been equivalent of 1.4,
# but we want command to work more often, more humanely */
- #prout(_("Prob = %d (%.4f)\n", i, x))
+ #prout(_("Prob = %.4f" % x))
# x = 100; // For testing, of course!
- if x > randreal(100):
+ if x < randreal(100):
# guess what, he surrendered!!! */
prout(_("Klingon captain at %s surrenders.") % weakest.location)
i = randreal(200)
if i > 0:
- prout(_("%d Klingons commit suicide rather than be taken captive.") % 200 - i)
- if i > brigfree:
- prout(_("%d Klingons die because there is no room for them in the brig.") % i-brigfree)
- i = brigfree
- brigfree -= i
+ prout(_("%d Klingons commit suicide rather than be taken captive.") % (200 - i))
+ if i > game.brigfree:
+ prout(_("%d Klingons die because there is no room for them in the brig.") % (i-brigfree))
+ i = game.brigfree
+ game.brigfree -= i
prout(_("%d captives taken") % i)
deadkl(weakest.location, weakest.type, game.sector)
if (game.state.remkl + len(game.state.kcmdr) + game.state.nscrem)<=0:
return
# big surprise, he refuses to surrender */
- prout(_("Fat chance, captain!"))
+ prout(_("Fat chance, captain!"))
# Code from events.c begins here.
prout(_("to think about pigeons."))
game.gamewon = True
score()
+ scanner.chew() # Clean up leftovers
def score():
"Compute player's score."
sys.stdout.write('\n')
proutn(prompt)
if not replayfp:
- input()
+ my_input()
sys.stdout.write('\n' * rows)
linecount = 0
elif linein[0] != "#":
break
else:
- linein = eval(input()) + "\n"
+ try:
+ linein = my_input() + "\n"
+ except EOFError:
+ prout("")
+ sys.exit(0)
if logfp:
logfp.write(linein)
return linein
linecount = 0
def textcolor(color=DEFAULT):
- if game.options & OPTION_COLOR:
+ if (game.options & OPTION_COLOR) and (game.options & OPTION_CURSES):
if color == DEFAULT:
curwnd.attrset(0)
elif color == BLACK:
curwnd.attron(curses.color_pair(curses.COLOR_WHITE) | curses.A_BOLD)
def highvideo():
- if game.options & OPTION_COLOR:
+ if (game.options & OPTION_COLOR) and (game.options & OPTION_CURSES):
curwnd.attron(curses.A_REVERSE)
#
"Light up an individual dot in a sector."
if goodScan or (abs(i-game.sector.i)<= 1 and abs(j-game.sector.j) <= 1):
if game.quad[i][j] in ('E', 'F'):
+ if game.iscloaked:
+ highvideo()
textcolor({"green":GREEN,
"yellow":YELLOW,
"red":RED,
'R':LIGHTRED,
'T':LIGHTRED,
}.get(game.quad[i][j], DEFAULT))
- if game.iscloaked:
- highvideo()
proutn("%c " % game.quad[i][j])
textcolor(DEFAULT)
else:
game.tourn = game.length = 0
game.thawed = False
game.skill = SKILL_NONE
- scanner.chew()
-# if not scanner.inqueue: # Can start with command line options
- proutn(_("Would you like a regular, tournament, or saved game? "))
+ # Do not chew here, we want to use command-line tokens
+ if not scanner.inqueue: # Can start with command line options
+ proutn(_("Would you like a regular, tournament, or saved game? "))
scanner.nexttok()
if scanner.sees("tournament"):
while scanner.nexttok() == "IHEOL":
hitme = True
elif cmd == "CAPTURE":
capture()
+ elif cmd == "CLOAK":
+ cloak()
elif cmd == "DEBUGCMD": # What do we want for debug???
debugme()
elif cmd == "MAYDAY": # Call for help