home · contact · privacy
e8cfa0ca3e15ecab4db7ac4ba2f61db26667cc5f
[plomrogue] / plugins / client / PleaseTheIslandGod.py
1 from client.config.io import io
2 from client.config.world_data import world_data
3 world_data["log"][-2] = "STATS OVERVIEW: " \
4 "T: turn, H: health, S: satiation, G: god's favor."
5 world_data["GOD_FAVOR"] = 0
6 io["worldstate_read_order"] += [["GOD_FAVOR", "int"]]
7 world_data["metamap_A"] = ""
8 world_data["metamap_B"] = ""
9 io["worldstate_read_order"] += [["metamap_A", "map"]]
10 io["worldstate_read_order"] += [["metamap_B", "map"]]
11
12 def win_info(self):
13     winmap = "T: " + str(world_data["turn"]) \
14         + " H: " + str(world_data["lifepoints"]) \
15         + " S: " + str(world_data["satiation"]) \
16         + " G: " + str(world_data["GOD_FAVOR"])
17     winmap_size = [1, len(winmap)]
18     offset = [0, 0]
19     return offset, winmap_size, winmap
20
21 def win_map(self):
22     win_size = self.size
23     offset = [0, 0]
24     for i in range(2):
25         if world_data["map_center"][i] * (i + 1) > win_size[i] / 2 and \
26                 win_size[i] < world_data["map_size"] * (i + 1):
27             if world_data["map_center"][i] * (i + 1) \
28                 < world_data["map_size"] * (i + 1) - win_size[i] / 2:
29                 offset[i] = world_data["map_center"][i] * (i + 1) \
30                     - int(win_size[i] / 2)
31                 if i == 1:
32                     offset[1] = offset[1] + world_data["map_center"][0] % 2
33             else:
34                 offset[i] = world_data["map_size"] * (i + 1) - win_size[i] + i
35     winmap_size = [world_data["map_size"], world_data["map_size"] * 2 + 1]
36     winmap = []
37     curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_WHITE)
38     curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_WHITE)
39     curses.init_pair(3, curses.COLOR_RED, curses.COLOR_WHITE)
40     curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_BLUE)
41     curses.init_pair(5, curses.COLOR_BLUE, curses.COLOR_RED)
42     curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_RED)
43     curses.init_pair(7, curses.COLOR_BLUE, curses.COLOR_GREEN)
44     curses.init_pair(8, curses.COLOR_BLUE, curses.COLOR_YELLOW)
45     curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
46     curses.init_pair(10, curses.COLOR_BLACK, curses.COLOR_CYAN)
47     curses.init_pair(11, curses.COLOR_WHITE, curses.COLOR_BLACK)
48     curses.init_pair(12, curses.COLOR_BLUE, curses.COLOR_BLACK)
49     curses.init_pair(13, curses.COLOR_RED, curses.COLOR_BLACK)
50     curses.init_pair(14, curses.COLOR_GREEN, curses.COLOR_BLACK)
51     curses.init_pair(15, curses.COLOR_YELLOW, curses.COLOR_BLACK)
52     curses.init_pair(16, curses.COLOR_CYAN, curses.COLOR_BLACK)
53     curses.init_pair(17, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
54     curses.init_pair(18, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
55     col_unknown = curses.color_pair(1)
56     col_mem = curses.color_pair(4)
57     col_mem_obstacle = curses.color_pair(2)
58     col_mem_altar = curses.color_pair(18)
59     col_plant = curses.color_pair(11)
60     col_altar = curses.color_pair(10)
61     col_tool = curses.color_pair(16)
62     col_corpse = curses.color_pair(17)
63     col_unkraut = curses.color_pair(14)
64     col_animal = curses.color_pair(6)
65     col_player = curses.color_pair(3)
66     col_ground = curses.color_pair(15)
67     col_obstacle = curses.color_pair(9)
68     col_health_good = curses.color_pair(7)
69     col_health_middle = curses.color_pair(8)
70     col_health_bad = curses.color_pair(5)
71     col_lumber = curses.color_pair(13)
72     col_water = curses.color_pair(12)
73     col_stack = curses.color_pair(11)
74     for y in range(world_data["map_size"]):
75         for x in range(world_data["map_size"]):
76             pos = y * world_data["map_size"] + x
77             char = world_data["fov_map"][pos]
78             if world_data["look_mode"] and y == world_data["map_center"][0] \
79                     and x == world_data["map_center"][1]:
80                 if char == " ":
81                     char = world_data["mem_map"][pos]
82                 winmap += [(char, curses.A_REVERSE), ("?", curses.A_REVERSE)]
83                 continue
84             if char == " ":
85                 char = world_data["mem_map"][pos]
86                 attribute = col_mem
87                 if char == " ":
88                     attribute = col_unknown
89                 elif char == "X" or char == "|":
90                     attribute = col_mem_obstacle
91                 elif char == "_":
92                     attribute = col_mem_altar
93                 bonus = (" ", attribute)
94                 if len(world_data["metamap_A"]) > 0 and \
95                         world_data["metamap_A"][pos] == "2":
96                     bonus = ("+", col_mem)
97                 winmap += [(char, attribute), bonus]
98             else:
99                 attribute = col_water
100                 if char == "." or char == ":":
101                     attribute = col_ground
102                 elif char == "@":
103                     attribute = col_player
104                 elif char == "," or char == "d" or char == "B":
105                     attribute = col_animal
106                 elif char == "#":
107                     attribute = col_unkraut
108                 elif char == "$" or char == "%" or char == ";" or char == "&":
109                     attribute = col_corpse
110                 elif char == "-" or char == "/" or char == "]" or char == "[":
111                     attribute = col_tool
112                 elif char == "X" or char == "|":
113                     attribute = col_obstacle
114                 elif char == "_":
115                     attribute = col_altar
116                 elif char == "(" or char == "*":
117                     attribute = col_plant
118                 elif char == "=":
119                     attribute = col_lumber
120                 bonus = (" ", attribute)
121                 if len(world_data["metamap_A"]) > 0 and \
122                         world_data["metamap_A"][pos] == "2":
123                     bonus = ("+", col_stack)
124                 winmap += [(char, attribute), bonus]
125         if y % 2 == 0:
126             winmap += "  "
127     return offset, winmap_size, winmap
128
129 from client.config.windows import windows_config
130 from client.windows import win_log, win_inventory, win_look
131 windows_config[:] = [
132     {"config": [1, 33], "func": win_info, "title": "Stats"},
133     {"config": [-7, 33], "func": win_log, "title": "Log"},
134     {"config": [4, 16], "func": win_inventory, "title": "Inventory"},
135     {"config": [4, 16], "func": win_look, "title": "Things here"},
136     {"config": [0, -34], "func": win_map, "title": "PLEASE THE ISLAND GOD"}
137 ]
138 from client.window_management import set_windows
139 set_windows()