Add color. Turns out SCORE was implemented already.
[super-star-trek.git] / sst.py
diff --git a/sst.py b/sst.py
index 757c8c884b07d25b3984cb8853f6a2f0bfef0722..df431649e1c0a0579f0f336a4d4b6ce1aa819130 100755 (executable)
--- a/sst.py
+++ b/sst.py
@@ -23,7 +23,7 @@ except ImportError:
 
 version = "2.1"
 
-docpath        = (".", "../doc", "/usr/share/doc/sst")
+docpath        = (".", "doc/", "/usr/share/doc/sst/")
 
 def _(st):
     return gettext.gettext(st)
@@ -212,22 +212,22 @@ class Event:
 # game options
 OPTION_ALL        = 0xffffffff
 OPTION_TTY        = 0x00000001        # old interface
-OPTION_CURSES        = 0x00000002        # new interface
-OPTION_IOMODES        = 0x00000003        # cover both interfaces
-OPTION_PLANETS        = 0x00000004        # planets and mining
-OPTION_THOLIAN        = 0x00000008        # Tholians and their webs (UT 1979 version)
-OPTION_THINGY        = 0x00000010        # Space Thingy can shoot back (Stas, 2005)
-OPTION_PROBE        = 0x00000020        # deep-space probes (DECUS version, 1980)
-OPTION_SHOWME        = 0x00000040        # bracket Enterprise in chart
-OPTION_RAMMING        = 0x00000080        # enemies may ram Enterprise (Almy)
-OPTION_MVBADDY        = 0x00000100        # more enemies can move (Almy)
-OPTION_BLKHOLE        = 0x00000200        # black hole may timewarp you (Stas, 2005)
-OPTION_BASE        = 0x00000400        # bases have good shields (Stas, 2005)
-OPTION_WORLDS        = 0x00000800        # logic for inhabited worlds (ESR, 2006)
-OPTION_AUTOSCAN        = 0x00001000        # automatic LRSCAN before CHART (ESR, 2006)
-OPTION_PLAIN        = 0x01000000        # user chose plain game
-OPTION_ALMY        = 0x02000000        # user chose Almy variant
-OPTION_COLOR    = 0x04000000        # enable color display (experimental, ESR, 2010)
+OPTION_CURSES     = 0x00000002        # new interface
+OPTION_IOMODES    = 0x00000003        # cover both interfaces
+OPTION_PLANETS    = 0x00000004        # planets and mining
+OPTION_THOLIAN    = 0x00000008        # Tholians and their webs (UT 1979 version)
+OPTION_THINGY     = 0x00000010        # Space Thingy can shoot back (Stas, 2005)
+OPTION_PROBE      = 0x00000020        # deep-space probes (DECUS version, 1980)
+OPTION_SHOWME     = 0x00000040        # bracket Enterprise in chart
+OPTION_RAMMING    = 0x00000080        # enemies may ram Enterprise (Almy)
+OPTION_MVBADDY    = 0x00000100        # more enemies can move (Almy)
+OPTION_BLKHOLE    = 0x00000200        # black hole may timewarp you (Stas, 2005)
+OPTION_BASE       = 0x00000400        # bases have good shields (Stas, 2005)
+OPTION_WORLDS     = 0x00000800        # logic for inhabited worlds (ESR, 2006)
+OPTION_AUTOSCAN   = 0x00001000        # automatic LRSCAN before CHART (ESR, 2006)
+OPTION_PLAIN      = 0x01000000        # user chose plain game
+OPTION_ALMY       = 0x02000000        # user chose Almy variant
+OPTION_COLOR      = 0x04000000        # enable color display (ESR, 2010)
 
 # Define devices
 DSRSENS         = 0
@@ -5054,13 +5054,20 @@ def chart():
 def sectscan(goodScan, i, j):
     "Light up an individual dot in a sector."
     if goodScan or (abs(i-game.sector.i)<= 1 and abs(j-game.sector.j) <= 1):
-        textcolor({"green":GREEN,
-                   "yellow":YELLOW,
-                   "red":RED,
-                   "docked":CYAN,
-                   "dead":BROWN}[game.condition])
-        if game.quad[i][j] != game.ship:
-            highvideo()
+        if game.quad[i][j] in ('E', 'F'):
+            textcolor({"green":GREEN,
+                       "yellow":YELLOW,
+                       "red":RED,
+                       "docked":CYAN,
+                       "dead":BROWN}[game.condition])
+        else:
+            textcolor({'?':LIGHTMAGENTA,
+                       'K':LIGHTRED,
+                       'S':LIGHTRED,
+                       'C':LIGHTRED,
+                       'R':LIGHTRED,
+                       'T':LIGHTRED,
+                       }.get(game.quad[i][j], DEFAULT))
         proutn("%c " % game.quad[i][j])
         textcolor(DEFAULT)
     else:
@@ -5691,17 +5698,16 @@ def choose():
         scanner.nexttok()
     if scanner.sees("plain"):
         # Approximates the UT FORTRAN version.
-        game.options &=~ (OPTION_THOLIAN | OPTION_PLANETS | OPTION_THINGY | OPTION_PROBE | OPTION_RAMMING | OPTION_MVBADDY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
+        game.options &=~ (OPTION_THOLIAN | OPTION_PLANETS | OPTION_THINGY | OPTION_PROBE | OPTION_RAMMING | OPTION_MVBADDY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS | OPTION_COLOR)
         game.options |= OPTION_PLAIN
     elif scanner.sees("almy"):
         # Approximates Tom Almy's version.
-        game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS)
+        game.options &=~ (OPTION_THINGY | OPTION_BLKHOLE | OPTION_BASE | OPTION_WORLDS | OPTION_COLOR)
         game.options |= OPTION_ALMY
     elif scanner.sees("fancy") or scanner.sees("\n"):
         pass
     elif len(scanner.token):
         proutn(_("What is \"%s\"?") % scanner.token)
-    game.options &=~ OPTION_COLOR
     setpassword()
     if game.passwd == "debug":
         game.idebug = True
@@ -5900,7 +5906,6 @@ commands = [
     ("IMPULSE",          0),
     ("REST",             0),
     ("WARP",             0),
-    ("SCORE",            0),
     ("SENSORS",          OPTION_PLANETS),
     ("ORBIT",            OPTION_PLANETS),
     ("TRANSPORT",        OPTION_PLANETS),
@@ -5924,6 +5929,7 @@ commands = [
     ("CALL",             0),        # Synonym for MAYDAY
     ("QUIT",             0),
     ("HELP",             0),
+    ("SCORE",            OPTION_ALMY),
     ("",                 0),
 ]
 
@@ -6070,8 +6076,6 @@ def makemoves():
                 hitme = True
         elif cmd == "WARP":                # warp
             setwarp()
-        elif cmd == "SCORE":                # score
-            score()
         elif cmd == "SENSORS":                # sensors
             sensor()
         elif cmd == "ORBIT":                # orbit
@@ -6131,6 +6135,8 @@ def makemoves():
             game.alldone = True                # quit the game
         elif cmd == "HELP":
             helpme()                        # get help
+        elif cmd == "SCORE":
+            score()                         # see current score
         while True:
             if game.alldone:
                 break                # Game has ended