home · contact · privacy
b39f445840da85aa97458344970d01a225556e13
[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_map(self):
7     win_size = self.size
8     offset = [0, 0]
9     for i in range(2):
10         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
11                 win_size[i] < world_data["map_size"] * (i + 1):
12             if world_data["map_center"][i] * (i + 1) \
13                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
14                 offset[i] = world_data["map_center"][i] * (i + 1) \
15                     - int(win_size[i] / 2)
16                 if i == 1:
17                     offset[1] = offset[1] + world_data["map_center"][0] % 2
18             else:
19                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
20     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
21     winmap = []
22     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLACK)
23     curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
24     curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
25     curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
26     col_unknown = curses.color_pair(1)
27     col_mem_obstacle = curses.color_pair(2)
28     col_mem = curses.color_pair(2)
29     col_ground = curses.color_pair(3)
30     col_stone = curses.color_pair(4)
31     col_earth = curses.color_pair(3)
32     col_player = curses.color_pair(1)
33     for y in range(world_data["map_size"]):
34         for x in range(world_data["map_size"]):
35             pos = y * world_data["map_size"] + x
36             char = world_data["fov_map"][pos]
37             if world_data["look_mode"] and y == world_data["map_center"][0] \
38                     and x == world_data["map_center"][1]:
39                 if char == " ":
40                     char = world_data["mem_map"][pos]
41                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
42                 continue
43             if char == " ":
44                 char = world_data["mem_map"][pos]
45                 attribute = col_mem
46                 if char == " ":
47                     attribute = col_unknown
48                 elif char == "X" or char == "#":
49                     attribute = col_mem_obstacle
50                 bonus = (" ", attribute)
51                 winmap += [(char, attribute), bonus]
52             else:
53                 attribute = col_stone
54                 if char == ".":
55                     attribute = col_ground
56                 if char == "#":
57                     attribute = col_earth
58                 elif char == "@":
59                     attribute = col_player
60                 bonus = (" ", attribute)
61                 winmap += [(char, attribute), bonus]
62         if y % 2 == 0:
63             winmap += "  "
64     return offset, winmap_size, winmap
65
66 from client.config.windows import windows_config
67 from client.windows import win_log, win_inventory, win_look, win_info
68 windows_config[:] = [
69     {"config": [1, 33], "func": win_info, "title": "Stats"},
70     {"config": [-7, 33], "func": win_log, "title": "Log"},
71     {"config": [4, 16], "func": win_inventory, "title": "Inventory"},
72     {"config": [4, 16], "func": win_look, "title": "Things here"},
73     {"config": [0, -34], "func": win_map, "title": "The Crawling Eater"}
74 ]
75 from client.window_management import set_windows
76 set_windows()