home · contact · privacy
TCE: Prefix hole creation with crack hierarchy, fix some bugs.
[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 curses.init_pair(77, curses.COLOR_WHITE, curses.COLOR_GREEN)
7 curses.init_pair(78, curses.COLOR_BLACK, curses.COLOR_RED)
8 curses.init_pair(79, curses.COLOR_WHITE, curses.COLOR_BLUE)
9 curses.init_pair(80, curses.COLOR_BLACK, curses.COLOR_YELLOW)
10
11
12 def win_bar_maker(color_number, symbol, title):
13     def win_bar(self):
14         winmap = []
15         for i in range(world_data[title]):
16             winmap += [(symbol, curses.color_pair(color_number))]
17         winmap_size = [1, len(winmap)]
18         offset = [0, 0]
19         return offset, winmap_size, winmap
20     return win_bar
21
22
23 def win_map(self):
24     charmap = {
25         "0": "_",
26         "1": ".",
27         "2": ":",
28         "3": "%",
29         "4": "#",
30         "5": "X",
31         "*": "O",
32     }
33     win_size = self.size
34     offset = [0, 0]
35     for i in range(2):
36         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
37                 win_size[i] < world_data["map_size"] * (i + 1):
38             if world_data["map_center"][i] * (i + 1) \
39                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
40                 offset[i] = world_data["map_center"][i] * (i + 1) \
41                     - int(win_size[i] / 2)
42                 if i == 1:
43                     offset[1] = offset[1] + world_data["map_center"][0] % 2
44             else:
45                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
46     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
47     winmap = []
48     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
49     #curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
50     #curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK)
51     curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
52     curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK)
53     curses.init_pair(6, curses.COLOR_RED, curses.COLOR_BLACK)
54     curses.init_pair(7, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
55     curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_WHITE)
56     curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_BLUE)
57     curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_CYAN)
58     curses.init_pair(11, curses.COLOR_BLACK, curses.COLOR_GREEN)
59     curses.init_pair(12, curses.COLOR_BLACK, curses.COLOR_YELLOW)
60     curses.init_pair(13, curses.COLOR_BLACK, curses.COLOR_RED)
61     curses.init_pair(14, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
62     col_unknown = curses.color_pair(1)
63     col_creature = curses.color_pair(13)
64     col_player = curses.color_pair(8)
65     earth_colors = [
66         curses.color_pair(4),
67         curses.color_pair(5),
68         curses.color_pair(5),
69         curses.color_pair(6),
70         curses.color_pair(6),
71         curses.color_pair(7),
72     ]
73     water_colors = [
74         curses.color_pair(9),
75         curses.color_pair(10),
76         curses.color_pair(11),
77         curses.color_pair(12),
78         curses.color_pair(14),
79     ]
80     for y in range(world_data["map_size"]):
81         for x in range(world_data["map_size"]):
82             pos = y * world_data["map_size"] + x
83             char = world_data["fov_map"][pos]
84             if world_data["look_mode"] and y == world_data["map_center"][0] \
85                     and x == world_data["map_center"][1]:
86                 if char == " ":
87                     bonus = "?"
88                 else:
89                     bonus = world_data["wetmap"][pos]
90                 char = world_data["mem_map"][pos]
91                 winmap += [(char, curses.A_REVERSE), (bonus, curses.A_REVERSE)]
92                 continue
93             bonus = " "
94             attribute = col_unknown
95             if char == " ":
96                 if world_data["soundmap"][pos] != "0":
97                     bonus = "?"
98                 char = world_data["mem_map"][pos]
99                 if char in charmap:
100                     char = charmap[char]
101                 winmap += [(char, attribute), bonus]
102             else:
103                 wetval = ord(world_data["wetmap"][pos]) - ord("0")
104                 if char in "012345-+":
105                     mapval = 0
106                     if char not in "-+":
107                         mapval = ord(char) - ord("0")
108                     if 1 <= wetval <= 5:
109                         attribute = water_colors[wetval + (mapval - 1)]
110                     else:
111                         attribute = earth_colors[mapval]
112                 if char in charmap:
113                     char = charmap[char]
114                 elif char == "@":
115                     attribute = col_creature
116                     av_pos = world_data["avatar_position"]
117                     if pos == av_pos[0] * world_data["map_size"] + av_pos[1]:
118                         attribute = col_player
119                 winmap += [(char, attribute), bonus]
120         if y % 2 == 0:
121             winmap += "  "
122     return offset, winmap_size, winmap
123
124
125 from client.config.world_data import world_data
126 world_data["kidney"] = 0
127 world_data["stomach"] = 0
128 world_data["bowel"] = 0
129 world_data["bladder"] = 0
130 world_data["wetmap"] = " " * (world_data["map_size"] ** 2)
131 world_data["soundmap"] = " " * (world_data["map_size"] ** 2)
132 from client.config.io import io
133 io["worldstate_read_order"] += [["stomach", "int"]]
134 io["worldstate_read_order"] += [["kidney", "int"]]
135 io["worldstate_read_order"] += [["bowel", "int"]]
136 io["worldstate_read_order"] += [["bladder", "int"]]
137 io["worldstate_read_order"] += [["wetmap", "map"]]
138 io["worldstate_read_order"] += [["soundmap", "map"]]
139 from client.config.windows import windows_config
140 from client.windows import win_log
141 windows_config[:] = [
142     {"config": [0, -34],
143      "func": win_map,
144      "scroll_hints": False,
145       "title": "THE CRAWLING EATER"},
146     {"config": [1, 33],
147      "func": win_bar_maker(77, "%", "stomach"),
148      "scroll_hints": False,
149      "title": "stomach"},
150     {"config": [1, 33],
151      "func": win_bar_maker(79, "~", "kidney"),
152      "scroll_hints": False,
153       "title": "kidney"},
154     {"config": [1, 33],
155      "func": win_bar_maker(78, "%", "bowel"),
156      "scroll_hints": False,
157      "title": "bowel"},
158     {"config": [1, 33],
159      "func": win_bar_maker(80, "~", "bladder"),
160      "scroll_hints": False,
161       "title": "bladder"},
162     {"config": [-8, 33],
163      "func": win_log,
164      "scroll_hints": False,
165      "title": "log"}
166 ]
167 from client.window_management import set_windows
168 set_windows()
169 from client.commands import command_sender
170 from client.config.commands import commands
171 commands["S"] = (command_sender("drop"),)
172 commands["D"] = (command_sender("drink"),)
173 commands["P"] = (command_sender("pee"),)
174 commands["1"] = (command_sender("HELP 1"),)
175 commands["2"] = (command_sender("HELP 2"),)
176 commands["3"] = (command_sender("HELP 3"),)
177 commands["4"] = (command_sender("HELP 4"),)