From: Eric S. Raymond Date: Sat, 25 Feb 2017 11:44:13 +0000 (-0500) Subject: Add fix and regression test for capture and cloak. X-Git-Tag: 2.2~31 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=c2d17fbca924685a924ce9efab357ea918e8de44;p=super-star-trek.git Add fix and regression test for capture and cloak. --- diff --git a/sst.py b/sst.py index cef7b8f..c36f137 100755 --- a/sst.py +++ b/sst.py @@ -2127,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: @@ -3538,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: @@ -3575,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) # diff --git a/test/test9.chk b/test/test9.chk new file mode 100644 index 0000000..2d0396a --- /dev/null +++ b/test/test9.chk @@ -0,0 +1,155 @@ +sst2k: seed set to 1487996992 + + +-SUPER- STAR TREK + + + +Stardate 2267. + +25 Klingons. +An unknown number of Romulans. +And one (GULP) Super-Commander. +14 stardates. +3 starbases in 2 - 3 6 - 3 7 - 2 + +The Enterprise is currently in Quadrant 1 - 6 Sector 8 - 1 + +Good Luck! + YOU'LL NEED IT. +COMMAND> # SST2K version 2.1 +# Tests capture and cloak +# recorded by esr@snark on Sat Feb 25 06:40:00 2017 +help move +Spock- "Captain, that information is missing from the + computer. You need to find sst.doc and put it somewhere + in these directories: .:doc/:/usr/share/doc/sst/." +COMMAND> +COMMAND> +COMMAND> m a 6 2 1 1 + +Ensign Chekov- "Course laid in, Captain." + +Entering Quadrant 6 - 2. +COMMAND> +COMMAND> m a 5 1 10 10 + +Ensign Chekov- "Course laid in, Captain." + +Entering Quadrant 5 - 1. + +168 unit hit from Klingon at 10 - 5 + +167 unit hit from Klingon at 5 - 8 + +146 unit hit from Klingon at 4 - 8 + +149 unit hit from Klingon at 7 - 4 + +70 unit hit from Klingon at 3 - 3 + + +Energy left 3562 shields down 100%, torpedoes left 10 + +Mc Coy- "Sickbay to bridge. We suffered 2 casualties + in that last attack." + +127 unit hit from Klingon at 10 - 5 + +109 unit hit from Klingon at 5 - 8 + +[CONTINUE?] + + + + + + + + + + + + + + + + + + + + + + + + +96 unit hit from Klingon at 4 - 8 + +93 unit hit from Klingon at 7 - 4 + +56 unit hit from Klingon at 3 - 3 + + +Energy left 3080 shields down 100%, torpedoes left 10 +COMMAND> phasers + +Manual or automatic? a +Phasers locked on target. Energy available: 3062.93 +1323 units required. Units to fire= 1323 + +129 unit hit on Klingon at Sector 10 - 5 +***Klingon at Sector 10 - 5 destroyed. +205 unit hit on Klingon at Sector 3 - 3 +***Klingon at Sector 3 - 3 destroyed. +158 unit hit on Klingon at Sector 4 - 8 +***Klingon at Sector 4 - 8 destroyed. +436 expended on empty space. + +101 unit hit from Klingon at 5 - 8 + +80 unit hit from Klingon at 7 - 4 + + +Energy left 1557 shields down 100%, torpedoes left 10 +COMMAND> m a 7 10 + + +95 unit hit from Klingon at 5 - 8 + +64 unit hit from Klingon at 7 - 4 + + +Energy left 1398 shields down 100%, torpedoes left 10 +COMMAND> cloak +Switch cloaking device on? y +Engineer Scott- "Cloaking device has engaging, Sir..." + +88 unit hit from Klingon at 5 - 8 + +54 unit hit from Klingon at 7 - 4 + + +Energy left 1218 shields down 100%, torpedoes left 10 +Engineer Scott- "Cloaking device has engaged, Sir." +COMMAND> phasers + +Manual or automatic? a +Phasers locked on target. Energy available: 1218.12 +189 units required. Units to fire= 189 + +62 unit hit on Klingon at Sector 5 - 8 +***Klingon at Sector 5 - 8 destroyed. +28 unit hit on Klingon at Sector 7 - 4 +***Mr. Spock- "Captain, the vessel at Sector 7 - 4 + has just lost its firepower." +79 expended on empty space. +COMMAND> capture +Klingon captain at 7 - 4 surrenders. +162 Klingons commit suicide rather than be taken captive. +37 captives taken +***Klingon at Sector 7 - 10 destroyed. +COMMAND> cloak off +Engineer Scott- "Aye, Sir." +COMMAND> quit + +May the Great Bird of the Galaxy roost upon your home planet. diff --git a/test/test9.log b/test/test9.log new file mode 100644 index 0000000..b4731c6 --- /dev/null +++ b/test/test9.log @@ -0,0 +1,23 @@ +# seed 1487996992 +# options regular medium good fancy +# SST2K version 2.1 +# Tests capture and cloak +# recorded by esr@snark on Sat Feb 25 06:40:00 2017 +help move + + +m a 6 2 1 1 + +m a 5 1 10 10 +phasers +a +1323 +m a 7 10 +cloak +y +phasers +a +189 +capture +cloak off +quit