X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.py;h=7c7d075a8c9527a484e089dcfd070ae77badfade;hp=58857746e4b63c47474ffea7e956da28c6ba246c;hb=aa6040b239a54a4fe69ba0d2e142b2ffa8bda9f4;hpb=f531891fef11ef7391efcc66fb4d20d2ea8d5c03 diff --git a/sst.py b/sst.py index 5885774..7c7d075 100755 --- a/sst.py +++ b/sst.py @@ -21,6 +21,13 @@ try: 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/") @@ -2120,20 +2127,22 @@ def capture(): # 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: @@ -2141,7 +2150,7 @@ def capture(): return # big surprise, he refuses to surrender */ - prout(_("Fat chance, captain!")) + prout(_("Fat chance, captain!")) # Code from events.c begins here. @@ -3404,7 +3413,7 @@ def pause_game(): sys.stdout.write('\n') proutn(prompt) if not replayfp: - input() + my_input() sys.stdout.write('\n' * rows) linecount = 0 @@ -3476,7 +3485,11 @@ def cgetline(): 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 @@ -3527,7 +3540,7 @@ def clrscr(): 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: @@ -3564,7 +3577,7 @@ def textcolor(color=DEFAULT): 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) # @@ -3998,15 +4011,16 @@ def getcourse(isprobe): iprompt = True key = scanner.nexttok() itemp = "verbose" - if key != "IHREAL": + if key == "IHREAL": + delta.j = scanner.real + else: huh() raise TrekError - delta.j = scanner.real key = scanner.nexttok() - if key != "IHREAL": - huh() - raise TrekError - delta.i = scanner.real + if key == "IHREAL": + delta.i = scanner.real + else: + delta.i = 0 # Check for zero movement if delta.i == 0 and delta.j == 0: scanner.chew()