From abf770449f233ca6c9f3941b1083cff3ac74f87a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 20 Feb 2012 17:17:17 -0500 Subject: [PATCH] Revert invalid change from 19 Feb, My commit 'pylint found a real bug in phaser damage allocation vs. multiple targets.' was erroneous. This fixes it, and adds a regression test for that code. --- sst.py | 12 +++++-- test/test2.chk | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/test2.log | 10 ++++++ 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 test/test2.chk create mode 100644 test/test2.log diff --git a/sst.py b/sst.py index ee6b58a..724674a 100755 --- a/sst.py +++ b/sst.py @@ -1663,7 +1663,8 @@ def hittem(hits): "Register a phaser hit on Klingons and Romulans." w = Coord() skip(1) - for (kk, wham) in enumerate(hits): + kk = 0 + for wham in hits: if wham == 0: continue dustfac = randreal(0.9, 1.0) @@ -3185,7 +3186,8 @@ def pause_game(): global linecount sys.stdout.write('\n') proutn(prompt) - raw_input() + if not replayfp: + raw_input() sys.stdout.write('\n' * rows) linecount = 0 @@ -3286,7 +3288,11 @@ def setwnd(wnd): legend = "unknown" logfp.write("#curses: setwnd(%s)\n" % legend) curwnd = wnd - curses.curs_set(wnd == fullscreen_window or wnd == message_window or wnd == prompt_window) + # Some curses implementations get confused when you try this. + try: + curses.curs_set(wnd in (fullscreen_window, message_window, prompt_window)) + except curses.error: + pass def clreol(): "Clear to end of line -- can be a no-op in tty mode" diff --git a/test/test2.chk b/test/test2.chk new file mode 100644 index 0000000..24c547a --- /dev/null +++ b/test/test2.chk @@ -0,0 +1,98 @@ +sst2k: seed set to 1329775764 + + +-SUPER- STAR TREK + +Would you like a regular, tournament, or saved game? # recorded by esr@snark on Mon Feb 20 17:09:24 2012 +r +Would you like a Short, Medium, or Long game? s +Are you a Novice, Fair, Good, Expert, or Emeritus player? g +Choose your game style (plain, almy, fancy or just press enter): f + + +Stardate 2149. + +22 Klingons. +An unknown number of Romulans. +And one (GULP) Super-Commander. +7 stardates. +5 starbases in 4 - 8 4 - 7 2 - 1 1 - 1 8 - 8 + +The Enterprise is currently in Quadrant 2 - 7 Sector 4 - 5 + +Good Luck! + YOU'LL NEED IT. +COMMAND> phasers + +Weapons Officer Sulu- "High-speed shield control enabled, sir." +Manual or automatic? auto +Phasers locked on target. Energy available: 4800.00 +3064 units required. Units to fire= 4800 + +Shields lowered. + +219 unit hit on Klingon at Sector 4 - 7 +***Klingon at Sector 4 - 7 destroyed. +192 unit hit on Klingon at Sector 10 - 1 +***Mr. Spock- "Captain, the vessel at Sector 10 - 1 + has just lost its firepower." +708 unit hit on Klingon at Sector 6 - 7 +***Klingon at Sector 6 - 7 destroyed. +244 unit hit on Klingon at Sector 10 - 1 +***Klingon at Sector 10 - 1 destroyed. +271 unit hit on Klingon at Sector 7 - 2 +***Klingon at Sector 7 - 2 destroyed. +279 unit hit on Commander at Sector 6 - 3 +2175 expended on empty space. + +Shields raised. +Weapons officer Sulu- "Phasers overheated, sir." + +27 unit hit from Klingon at 8 - 6 + +26 unit hit from Klingon at 9 - 5 + + +[CONTINUE?] + + + + + + + + + + + + + + + + + + + + + + + + + + +It is stardate 2149.8. + +The Enterprise has been destroyed in battle. + +Dulce et decorum est pro patria mori. +The Federation will be destroyed. + + +Your score -- + 0.00 Klingons per stardate 0 + 1 ship(s) lost or destroyed -100 +Penalty for getting yourself killed -200 + +TOTAL SCORE -300 + +May the Great Bird of the Galaxy roost upon your home planet. diff --git a/test/test2.log b/test/test2.log new file mode 100644 index 0000000..e6d34d2 --- /dev/null +++ b/test/test2.log @@ -0,0 +1,10 @@ +# seed 1329775764 +# options +# recorded by esr@snark on Mon Feb 20 17:09:24 2012 +r +s +g +f +phasers +auto +4800 -- 2.31.1