home · contact · privacy
TCE: Refine water cycle.
[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     win_size = self.size
28     offset = [0, 0]
29     for i in range(2):
30         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
31                 win_size[i] < world_data["map_size"] * (i + 1):
32             if world_data["map_center"][i] * (i + 1) \
33                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
34                 offset[i] = world_data["map_center"][i] * (i + 1) \
35                     - int(win_size[i] / 2)
36                 if i == 1:
37                     offset[1] = offset[1] + world_data["map_center"][0] % 2
38             else:
39                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
40     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
41     winmap = []
42     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
43     curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
44     curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
45     curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
46     curses.init_pair(5, curses.COLOR_CYAN, curses.COLOR_BLACK)
47     curses.init_pair(6, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
48     curses.init_pair(7, curses.COLOR_GREEN, curses.COLOR_BLACK)
49     curses.init_pair(8, curses.COLOR_BLACK, curses.COLOR_BLUE)
50     curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
51     curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_CYAN)
52     col_unknown = curses.color_pair(1)
53     col_mem_obstacle = curses.color_pair(2)
54     col_mem = curses.color_pair(2)
55     col_stone = curses.color_pair(1)
56     col_player = curses.color_pair(5)
57     col_ground = curses.color_pair(6)
58     col_ground_wet = curses.color_pair(8)
59     col_ground_wetter = curses.color_pair(9)
60     col_ground_wettest = curses.color_pair(10)
61     col_dirt = curses.color_pair(3)
62     col_dirt_wet = curses.color_pair(8)
63     col_dirt_wetter = curses.color_pair(9)
64     col_dirt_wettest = curses.color_pair(10)
65     col_earth = curses.color_pair(3)
66     col_earth_wet = curses.color_pair(8)
67     col_earth_wetter = curses.color_pair(9)
68     col_earth_wettest = curses.color_pair(10)
69     col_wall_dirt = curses.color_pair(4)
70     col_wall_dirt_wet = curses.color_pair(8)
71     col_wall_dirt_wetter = curses.color_pair(9)
72     col_wall_dirt_wettest = curses.color_pair(10)
73     col_wall_earth = curses.color_pair(4)
74     col_wall_earth_wet = curses.color_pair(8)
75     col_wall_earth_wetter = curses.color_pair(9)
76     col_wall_earth_wettest = curses.color_pair(10)
77     col_wall_stone = curses.color_pair(1)
78     col_wall_stone_wet = curses.color_pair(8)
79     col_wall_stone_wetter = curses.color_pair(9)
80     col_wall_stone_wettest = curses.color_pair(10)
81     for y in range(world_data["map_size"]):
82         for x in range(world_data["map_size"]):
83             pos = y * world_data["map_size"] + x
84             char = world_data["fov_map"][pos]
85             if world_data["look_mode"] and y == world_data["map_center"][0] \
86                     and x == world_data["map_center"][1]:
87                 if char == " ":
88                     char = world_data["mem_map"][pos]
89                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
90                 continue
91             if char == " ":
92                 char = world_data["mem_map"][pos]
93                 attribute = col_mem
94                 if char == " ":
95                     attribute = col_unknown
96                 elif char in "%#X":
97                     attribute = col_mem_obstacle
98                 bonus = (" ", attribute)
99                 winmap += [(char, attribute), bonus]
100             else:
101                 attribute = col_stone
102                 bonus = " "
103                 if char == "_":
104                     attribute = col_ground
105                 elif char == "~":
106                     if world_data["wetmap"][pos] == "1":
107                         attribute = col_ground_wet
108                     if world_data["wetmap"][pos] == "2":
109                         attribute = col_ground_wetter
110                     if world_data["wetmap"][pos] == "3":
111                         attribute = col_ground_wettest
112                 if char == ".":
113                     attribute = col_dirt
114                     if world_data["wetmap"][pos] == "1":
115                         attribute = col_dirt_wet
116                     if world_data["wetmap"][pos] == "2":
117                         attribute = col_dirt_wetter
118                     if world_data["wetmap"][pos] == "3":
119                         attribute = col_dirt_wettest
120                 elif char == ":":
121                     attribute = col_earth
122                     if world_data["wetmap"][pos] == "1":
123                         attribute = col_earth_wet
124                     if world_data["wetmap"][pos] == "2":
125                         attribute = col_earth_wetter
126                     if world_data["wetmap"][pos] == "3":
127                         attribute = col_earth_wettest
128                 elif char == "%":
129                     attribute = col_wall_dirt
130                     if world_data["wetmap"][pos] == "1":
131                         attribute = col_wall_dirt_wet
132                     if world_data["wetmap"][pos] == "2":
133                         attribute = col_wall_dirt_wetter
134                     if world_data["wetmap"][pos] == "3":
135                         attribute = col_wall_dirt_wettest
136                 elif char == "#":
137                     attribute = col_wall_earth
138                     if world_data["wetmap"][pos] == "1":
139                         attribute = col_wall_earth_wet
140                     if world_data["wetmap"][pos] == "2":
141                         attribute = col_wall_earth_wetter
142                     if world_data["wetmap"][pos] == "3":
143                         attribute = col_wall_earth_wettest
144                 elif char == "X":
145                     attribute = col_wall_stone
146                     if world_data["wetmap"][pos] == "1":
147                         attribute = col_wall_stone_wet
148                     if world_data["wetmap"][pos] == "2":
149                         attribute = col_wall_stone_wetter
150                     if world_data["wetmap"][pos] == "3":
151                         attribute = col_wall_stone_wettest
152                 elif char == "@":
153                     attribute = col_player
154                 winmap += [(char, attribute), bonus]
155         if y % 2 == 0:
156             winmap += "  "
157     return offset, winmap_size, winmap
158
159 from client.config.world_data import world_data
160 world_data["bowel"] = 0
161 world_data["bladder"] = 0
162 world_data["wetmap"] = " " * (world_data["map_size"] ** 2)
163 from client.config.io import io
164 io["worldstate_read_order"] += [["bowel", "int"]]
165 io["worldstate_read_order"] += [["bladder", "int"]]
166 io["worldstate_read_order"] += [["wetmap", "map"]]
167 from client.config.windows import windows_config
168 from client.windows import win_log
169 windows_config[:] = [
170     {"config": [0, -34], "func": win_map, "title": "The Crawling Eater"},
171     {"config": [1, 33], "func": win_bowel, "title": "bowel"},
172     {"config": [1, 33], "func": win_bladder, "title": "bladder"},
173     {"config": [-4, 33], "func": win_log, "title": "log"}
174 ]
175 from client.window_management import set_windows
176 set_windows()
177 from client.commands import command_sender
178 from client.config.commands import commands
179 commands["S"] = (command_sender("drop"),)
180 commands["D"] = (command_sender("drink"),)
181 commands["P"] = (command_sender("pee"),)