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 win_size = next(win["size"] for win in windows
70 if win["func"] == win_look)
71 if string == "up" and world_data["look_scroll"] > 0:
72 world_data["look_scroll"] -= 1
73 elif string == "down" and world_data["look_scroll"] \
74 < len(world_data["look"]) - win_size[0]:
75 world_data["look_scroll"] += 1
76 return command_look_scroll
79 def command_inventory_selector(string):
80 def command_inventory_select():
81 if string == "up" and world_data["inventory_selection"] > 0:
82 world_data["inventory_selection"] -= 1
83 elif string == "down" and world_data["inventory_selection"] \
84 < len(world_data["inventory"]) - 1:
85 world_data["inventory_selection"] += 1
86 return command_inventory_select