home · contact · privacy
6996daf1ef4d25bfe611984c33cb2e4bc665bf25
[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_stomach(self):
17     winmap = []
18     curses.init_pair(80, curses.COLOR_YELLOW, curses.COLOR_RED)
19     for i in range(world_data["stomach"]):
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_MAGENTA, curses.COLOR_BLACK)
47     curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_BLUE)
48     col_unknown = curses.color_pair(1)
49     col_mem_obstacle = curses.color_pair(2)
50     col_mem = curses.color_pair(2)
51     col_stone = curses.color_pair(1)
52     col_dirt = curses.color_pair(4)
53     col_earth = curses.color_pair(3)
54     col_player = curses.color_pair(5)
55     col_water = curses.color_pair(6)
56     for y in range(world_data["map_size"]):
57         for x in range(world_data["map_size"]):
58             pos = y * world_data["map_size"] + x
59             char = world_data["fov_map"][pos]
60             if world_data["look_mode"] and y == world_data["map_center"][0] \
61                     and x == world_data["map_center"][1]:
62                 if char == " ":
63                     char = world_data["mem_map"][pos]
64                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
65                 continue
66             if char == " ":
67                 char = world_data["mem_map"][pos]
68                 attribute = col_mem
69                 if char == " ":
70                     attribute = col_unknown
71                 elif char == "X" or char == "#":
72                     attribute = col_mem_obstacle
73                 bonus = (" ", attribute)
74                 winmap += [(char, attribute), bonus]
75             else:
76                 attribute = col_stone
77                 bonus = " "
78                 if char == ".":
79                     attribute = col_dirt
80                 elif char == ":":
81                     attribute = col_earth
82                 elif char == "%":
83                     attribute = col_earth
84                 elif char == "#":
85                     attribute = col_dirt
86                 elif char == "~":
87                     attribute = col_water
88                 elif char == "o":
89                     attribute = col_player
90                     bonus = (char, attribute)
91                 winmap += [(char, attribute), bonus]
92         if y % 2 == 0:
93             winmap += "  "
94     return offset, winmap_size, winmap
95
96 from client.config.world_data import world_data
97 world_data["stomach"] = 0
98 world_data["bladder"] = 0
99 from client.config.io import io
100 io["worldstate_read_order"] += [["stomach", "int"]]
101 io["worldstate_read_order"] += [["bladder", "int"]]
102 from client.config.windows import windows_config
103 from client.windows import win_log
104 windows_config[:] = [
105     {"config": [0, -34], "func": win_map, "title": "The Crawling Eater"},
106     {"config": [1, 33], "func": win_stomach, "title": "stomach"},
107     {"config": [1, 33], "func": win_bladder, "title": "bladder"},
108     {"config": [-4, 33], "func": win_log, "title": "log"}
109 ]
110 from client.window_management import set_windows
111 set_windows()
112 from client.commands import command_sender
113 from client.config.commands import commands
114 commands["S"] = (command_sender("drop"),)
115 commands["D"] = (command_sender("drink"),)