home · contact · privacy
TCE: Replae hard-coded height values with height map.
[plomrogue] / plugins / client / TheCrawlingEater.py
index b1f4005a02ac63fb302b487dd0f4438c23436cab..3d13d2c3d22e5af95c3f03fc1d4e3b74640cc96c 100644 (file)
@@ -24,6 +24,14 @@ def win_bowel(self):
 
 
 def win_map(self):
+    charmap = {
+        "0": "_",
+        "1": ".",
+        "2": ":",
+        "3": "%",
+        "4": "#",
+        "5": "X",
+    }
     win_size = self.size
     offset = [0, 0]
     for i in range(2):
@@ -40,44 +48,37 @@ def win_map(self):
     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
     winmap = []
     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
-    curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
-    curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
-    curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
-    curses.init_pair(5, curses.COLOR_CYAN, curses.COLOR_BLACK)
-    curses.init_pair(6, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
-    curses.init_pair(7, curses.COLOR_GREEN, curses.COLOR_BLACK)
-    curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_BLUE)
-    curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
+    #curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
+    #curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
+    curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
+    curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)
+    curses.init_pair(6, curses.COLOR_RED, curses.COLOR_BLACK)
+    curses.init_pair(7, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
+    curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_WHITE)
+    #curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_BLUE)
     curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_CYAN)
+    curses.init_pair(11, curses.COLOR_BLACK, curses.COLOR_GREEN)
+    curses.init_pair(12, curses.COLOR_BLACK, curses.COLOR_YELLOW)
+    curses.init_pair(13, curses.COLOR_BLACK, curses.COLOR_RED)
+    curses.init_pair(14, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
     col_unknown = curses.color_pair(1)
-    col_mem_obstacle = curses.color_pair(2)
-    col_mem = curses.color_pair(2)
-    col_stone = curses.color_pair(1)
-    col_player = curses.color_pair(5)
-    col_ground = curses.color_pair(6)
-    col_ground_wet = curses.color_pair(8)
-    col_ground_wetter = curses.color_pair(9)
-    col_ground_wettest = curses.color_pair(10)
-    col_dirt = curses.color_pair(3)
-    col_dirt_wet = curses.color_pair(8)
-    col_dirt_wetter = curses.color_pair(9)
-    col_dirt_wettest = curses.color_pair(10)
-    col_earth = curses.color_pair(3)
-    col_earth_wet = curses.color_pair(8)
-    col_earth_wetter = curses.color_pair(9)
-    col_earth_wettest = curses.color_pair(10)
-    col_wall_dirt = curses.color_pair(4)
-    col_wall_dirt_wet = curses.color_pair(8)
-    col_wall_dirt_wetter = curses.color_pair(9)
-    col_wall_dirt_wettest = curses.color_pair(10)
-    col_wall_earth = curses.color_pair(4)
-    col_wall_earth_wet = curses.color_pair(8)
-    col_wall_earth_wetter = curses.color_pair(9)
-    col_wall_earth_wettest = curses.color_pair(10)
-    col_wall_stone = curses.color_pair(1)
-    col_wall_stone_wet = curses.color_pair(8)
-    col_wall_stone_wetter = curses.color_pair(9)
-    col_wall_stone_wettest = curses.color_pair(10)
+    col_mem = curses.color_pair(1)
+    col_player = curses.color_pair(8)
+    earth_colors = [
+        curses.color_pair(4),
+        curses.color_pair(5),
+        curses.color_pair(5),
+        curses.color_pair(6),
+        curses.color_pair(6),
+        curses.color_pair(7),
+    ]
+    water_colors = [
+        curses.color_pair(10),
+        curses.color_pair(11),
+        curses.color_pair(12),
+        curses.color_pair(13),
+        curses.color_pair(14),
+    ]
     for y in range(world_data["map_size"]):
         for x in range(world_data["map_size"]):
             pos = y * world_data["map_size"] + x
@@ -90,65 +91,26 @@ def win_map(self):
                 continue
             if char == " ":
                 char = world_data["mem_map"][pos]
-                attribute = col_mem
                 if char == " ":
                     attribute = col_unknown
-                elif char in "%#X":
-                    attribute = col_mem_obstacle
+                else:
+                    attribute = col_mem
+                if char in charmap:
+                    char = charmap[char]
                 bonus = (" ", attribute)
                 winmap += [(char, attribute), bonus]
             else:
-                attribute = col_stone
                 bonus = " "
-                if char == "_":
-                    attribute = col_ground
-                elif char == "~":
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_ground_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_ground_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_ground_wettest
-                if char == ".":
-                    attribute = col_dirt
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_dirt_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_dirt_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_dirt_wettest
-                elif char == ":":
-                    attribute = col_earth
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_earth_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_earth_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_earth_wettest
-                elif char == "%":
-                    attribute = col_wall_dirt
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_wall_dirt_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_wall_dirt_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_wall_dirt_wettest
-                elif char == "#":
-                    attribute = col_wall_earth
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_wall_earth_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_wall_earth_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_wall_earth_wettest
-                elif char == "X":
-                    attribute = col_wall_stone
-                    if world_data["wetmap"][pos] == "1":
-                        attribute = col_wall_stone_wet
-                    if world_data["wetmap"][pos] == "2":
-                        attribute = col_wall_stone_wetter
-                    if world_data["wetmap"][pos] == "3":
-                        attribute = col_wall_stone_wettest
+                attribute = col_unknown
+                wetval = ord(world_data["wetmap"][pos]) - ord("0")
+                if ord("0") <= ord(char) <= ord("5"):
+                    mapval = ord(char) - ord("0")
+                    if 1 <= wetval <= 5:
+                        attribute = water_colors[wetval + (mapval - 1)]
+                    else:
+                        attribute = earth_colors[mapval]
+                if char in charmap:
+                    char = charmap[char]
                 elif char == "@":
                     attribute = col_player
                 winmap += [(char, attribute), bonus]
@@ -156,6 +118,7 @@ def win_map(self):
             winmap += "  "
     return offset, winmap_size, winmap
 
+
 from client.config.world_data import world_data
 world_data["bowel"] = 0
 world_data["bladder"] = 0