home · contact · privacy
e3e413fab80b84137b9f8ac94b5e9a59c260fb49
[plomrogue] / plugins / client / TheCrawlingEater.py
1 # This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
2 # or any later version. For details on its copyright, license, and warranties,
3 # see the file NOTICE in the root directory of the PlomRogue source package.
4
5
6 def win_bladder(self):
7     winmap = []
8     curses.init_pair(79, curses.COLOR_WHITE, curses.COLOR_BLUE)
9     for i in range(world_data["bladder"]):
10         winmap += [("~", curses.color_pair(79))]
11     winmap_size = [1, len(winmap)]
12     offset = [0, 0]
13     return offset, winmap_size, winmap
14
15
16 def win_bowel(self):
17     winmap = []
18     curses.init_pair(80, curses.COLOR_YELLOW, curses.COLOR_RED)
19     for i in range(world_data["bowel"]):
20         winmap += [("#", curses.color_pair(80))]
21     winmap_size = [1, len(winmap)]
22     offset = [0, 0]
23     return offset, winmap_size, winmap
24
25
26 def win_map(self):
27     charmap = {
28         "0": "_",
29         "1": ".",
30         "2": ":",
31         "3": "%",
32         "4": "#",
33         "5": "X",
34         "-": "O",
35     }
36     win_size = self.size
37     offset = [0, 0]
38     for i in range(2):
39         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
40                 win_size[i] < world_data["map_size"] * (i + 1):
41             if world_data["map_center"][i] * (i + 1) \
42                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
43                 offset[i] = world_data["map_center"][i] * (i + 1) \
44                     - int(win_size[i] / 2)
45                 if i == 1:
46                     offset[1] = offset[1] + world_data["map_center"][0] % 2
47             else:
48                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
49     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
50     winmap = []
51     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
52     #curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
53     #curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
54     curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
55     curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)
56     curses.init_pair(6, curses.COLOR_RED, curses.COLOR_BLACK)
57     curses.init_pair(7, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
58     curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_WHITE)
59     #curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_BLUE)
60     curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_CYAN)
61     curses.init_pair(11, curses.COLOR_BLACK, curses.COLOR_GREEN)
62     curses.init_pair(12, curses.COLOR_BLACK, curses.COLOR_YELLOW)
63     curses.init_pair(13, curses.COLOR_BLACK, curses.COLOR_RED)
64     curses.init_pair(14, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
65     col_unknown = curses.color_pair(1)
66     col_mem = curses.color_pair(1)
67     col_player = curses.color_pair(8)
68     earth_colors = [
69         curses.color_pair(4),
70         curses.color_pair(5),
71         curses.color_pair(5),
72         curses.color_pair(6),
73         curses.color_pair(6),
74         curses.color_pair(7),
75     ]
76     water_colors = [
77         curses.color_pair(10),
78         curses.color_pair(11),
79         curses.color_pair(12),
80         curses.color_pair(13),
81         curses.color_pair(14),
82     ]
83     for y in range(world_data["map_size"]):
84         for x in range(world_data["map_size"]):
85             pos = y * world_data["map_size"] + x
86             char = world_data["fov_map"][pos]
87             if world_data["look_mode"] and y == world_data["map_center"][0] \
88                     and x == world_data["map_center"][1]:
89                 if char == " ":
90                     char = world_data["mem_map"][pos]
91                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
92                 continue
93             if char == " ":
94                 char = world_data["mem_map"][pos]
95                 if char == " ":
96                     attribute = col_unknown
97                 else:
98                     attribute = col_mem
99                 if char in charmap:
100                     char = charmap[char]
101                 bonus = (" ", attribute)
102                 winmap += [(char, attribute), bonus]
103             else:
104                 bonus = " "
105                 attribute = col_unknown
106                 wetval = ord(world_data["wetmap"][pos]) - ord("0")
107                 if ord("0") <= ord(char) <= ord("5"):
108                     mapval = ord(char) - ord("0")
109                     if 1 <= wetval <= 5:
110                         attribute = water_colors[wetval + (mapval - 1)]
111                     else:
112                         attribute = earth_colors[mapval]
113                 if char in charmap:
114                     char = charmap[char]
115                 elif char == "@":
116                     attribute = col_player
117                 winmap += [(char, attribute), bonus]
118         if y % 2 == 0:
119             winmap += "  "
120     return offset, winmap_size, winmap
121
122
123 from client.config.world_data import world_data
124 world_data["bowel"] = 0
125 world_data["bladder"] = 0
126 world_data["wetmap"] = " " * (world_data["map_size"] ** 2)
127 from client.config.io import io
128 io["worldstate_read_order"] += [["bowel", "int"]]
129 io["worldstate_read_order"] += [["bladder", "int"]]
130 io["worldstate_read_order"] += [["wetmap", "map"]]
131 from client.config.windows import windows_config
132 from client.windows import win_log
133 windows_config[:] = [
134     {"config": [0, -34], "func": win_map, "title": "The Crawling Eater"},
135     {"config": [1, 33], "func": win_bowel, "title": "bowel"},
136     {"config": [1, 33], "func": win_bladder, "title": "bladder"},
137     {"config": [-4, 33], "func": win_log, "title": "log"}
138 ]
139 from client.window_management import set_windows
140 set_windows()
141 from client.commands import command_sender
142 from client.config.commands import commands
143 commands["S"] = (command_sender("drop"),)
144 commands["D"] = (command_sender("drink"),)
145 commands["P"] = (command_sender("pee"),)