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