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.
6 from client.config.world_data import world_data
7 from client.io import send
8 from client.query_mapcell import query_mapcell
13 raise SystemExit("Received QUIT command, forwarded to server, leaving.")
16 def command_toggle_look_mode():
17 if not world_data["look_mode"]:
18 world_data["look_mode"] = True
20 world_data["look_mode"] = False
21 world_data["map_center"] = world_data["avatar_position"]
25 def command_sender(string, int_field=None):
29 int_string = " " + str(world_data[int_field])
30 send(string + int_string)
34 def command_looker(string):
37 and world_data["map_center"][1] > 0:
38 world_data["map_center"][1] -= 1
39 elif string == "east" \
40 and world_data["map_center"][1] < world_data["map_size"] - 1:
41 world_data["map_center"][1] += 1
43 y_unevenness = world_data["map_center"][0] % 2
44 y_evenness = int(not(y_unevenness))
45 if string[6:] == "west" and \
46 world_data["map_center"][1] > -y_unevenness:
47 if string[:5] == "north" and world_data["map_center"][0] > 0:
48 world_data["map_center"][0] -= 1
49 world_data["map_center"][1] -= y_evenness
50 if string[:5] == "south" and world_data["map_center"][0] \
51 < world_data["map_size"] - 1:
52 world_data["map_center"][0] += 1
53 world_data["map_center"][1] -= y_evenness
54 elif string[6:] == "east" and world_data["map_center"][1] \
55 < world_data["map_size"] - y_unevenness:
56 if string[:5] == "north" and world_data["map_center"][0] > 0:
57 world_data["map_center"][0] -= 1
58 world_data["map_center"][1] += y_unevenness
59 if string[:5] == "south" and world_data["map_center"][0] \
60 < world_data["map_size"] - 1:
61 world_data["map_center"][0] += 1
62 world_data["map_center"][1] += y_unevenness
67 def command_look_scroller(string):
68 def command_look_scroll():
69 from client.window_management import windows
70 from client.config.windows import windows_config
71 from client.windows import win_look
73 i = next(i for i in range(len(windows_config))
74 if windows_config[i]["func"] == win_look)
77 win_size = windows[i].size
78 if string == "up" and world_data["look_scroll"] > 0:
79 world_data["look_scroll"] -= 1
80 elif string == "down" and world_data["look_scroll"] \
81 < len(world_data["look"]) - win_size[0]:
82 world_data["look_scroll"] += 1
83 return command_look_scroll
86 def command_inventory_selector(string):
87 def command_inventory_select():
88 if string == "up" and world_data["inventory_selection"] > 0:
89 world_data["inventory_selection"] -= 1
90 elif string == "down" and world_data["inventory_selection"] \
91 < len(world_data["inventory"]) - 1:
92 world_data["inventory_selection"] += 1
93 return command_inventory_select