home · contact · privacy
a4be1a588fcc89bcec2f37740215122486f1b5e5
[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_stomach(self):
7     winmap = []
8     curses.init_pair(80, curses.COLOR_YELLOW, curses.COLOR_RED)
9     for i in range(world_data["stomach"]):
10         winmap += [("#", curses.color_pair(80))]
11     winmap_size = [1, len(winmap)]
12     offset = [0, 0]
13     return offset, winmap_size, winmap
14
15
16 def win_map(self):
17     win_size = self.size
18     offset = [0, 0]
19     for i in range(2):
20         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
21                 win_size[i] < world_data["map_size"] * (i + 1):
22             if world_data["map_center"][i] * (i + 1) \
23                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
24                 offset[i] = world_data["map_center"][i] * (i + 1) \
25                     - int(win_size[i] / 2)
26                 if i == 1:
27                     offset[1] = offset[1] + world_data["map_center"][0] % 2
28             else:
29                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
30     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
31     winmap = []
32     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
33     curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
34     curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
35     curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
36     col_unknown = curses.color_pair(1)
37     col_mem_obstacle = curses.color_pair(2)
38     col_mem = curses.color_pair(2)
39     col_stone = curses.color_pair(1)
40     col_dirt = curses.color_pair(4)
41     col_earth = curses.color_pair(3)
42     col_player = curses.color_pair(1)
43     for y in range(world_data["map_size"]):
44         for x in range(world_data["map_size"]):
45             pos = y * world_data["map_size"] + x
46             char = world_data["fov_map"][pos]
47             if world_data["look_mode"] and y == world_data["map_center"][0] \
48                     and x == world_data["map_center"][1]:
49                 if char == " ":
50                     char = world_data["mem_map"][pos]
51                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
52                 continue
53             if char == " ":
54                 char = world_data["mem_map"][pos]
55                 attribute = col_mem
56                 if char == " ":
57                     attribute = col_unknown
58                 elif char == "X" or char == "#":
59                     attribute = col_mem_obstacle
60                 bonus = (" ", attribute)
61                 winmap += [(char, attribute), bonus]
62             else:
63                 attribute = col_stone
64                 if char == ".":
65                     attribute = col_dirt
66                 elif char == ":":
67                     attribute = col_earth
68                 elif char == "%":
69                     attribute = col_earth
70                 elif char == "#":
71                     attribute = col_dirt
72                 elif char == "@":
73                     attribute = col_player
74                 bonus = (" ", attribute)
75                 winmap += [(char, attribute), bonus]
76         if y % 2 == 0:
77             winmap += "  "
78     return offset, winmap_size, winmap
79
80 from client.config.world_data import world_data
81 world_data["stomach"] = 0
82 from client.config.io import io
83 io["worldstate_read_order"] += [["stomach", "int"]]
84 from client.config.windows import windows_config
85 from client.windows import win_log
86 windows_config[:] = [
87     {"config": [0, -34], "func": win_map, "title": "The Crawling Eater"},
88     {"config": [1, 33], "func": win_stomach, "title": "stomach"},
89     {"config": [-2, 33], "func": win_log, "title": "log"}
90 ]
91 from client.window_management import set_windows
92 set_windows()
93 from client.commands import command_sender
94 from client.config.commands import commands
95 commands["D"] = (command_sender("drop"),)