home · contact · privacy
49fa6133aa7d91aad532ed109dfed45c0836ee26
[plomrogue] / server / config / commands.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 server.commands import command_plugin, command_quit, command_ping, \
7     command_thingshere, command_makeworld, command_seedrandomness, setter, \
8     command_maplength, command_worldactive, setter_map, command_taid, \
9     command_taname, command_ttid, command_ttname, command_tttool, \
10     command_ttsymbol, command_ttcorpseid, command_tid, command_tcommand, \
11     command_ttype, command_tcarries, command_tmemthing, setter_tpos, \
12     play_wait, play_move, play_pickup, play_drop, play_use, command_ai
13
14
15 """Commands database.
16
17 Map command start tokens to ([0]) number of expected command arguments, ([1])
18 the command's meta-ness (i.e. is it to be written to the record file, is it to
19 be ignored in replay mode if read from server input file), and ([2]) a function
20 to be called on it.
21 """
22 commands_db = {
23     "PLUGIN": (1, False, command_plugin),
24     "QUIT": (0, True, command_quit),
25     "PING": (0, True, command_ping),
26     "THINGS_HERE": (2, True, command_thingshere),
27     "MAKE_WORLD": (1, False, command_makeworld),
28     "SEED_RANDOMNESS": (1, False, command_seedrandomness),
29     "TURN": (1, False, setter(None, "TURN", 0, 65535)),
30     "PLAYER_TYPE": (1, False, setter(None, "PLAYER_TYPE", 0)),
31     "MAP_LENGTH": (1, False, command_maplength),
32     "WORLD_ACTIVE": (1, False, command_worldactive),
33     "MAP": (2, False, setter_map("MAP")),
34     "TA_ID": (1, False, command_taid),
35     "TA_EFFORT": (1, False, setter("ThingAction", "TA_EFFORT", 0, 255)),
36     "TA_NAME": (1, False, command_taname),
37     "TT_ID": (1, False, command_ttid),
38     "TT_NAME": (1, False, command_ttname),
39     "TT_TOOL": (1, False, command_tttool),
40     "TT_SYMBOL": (1, False, command_ttsymbol),
41     "TT_CORPSE_ID": (1, False, command_ttcorpseid),
42     "TT_TOOLPOWER": (1, False, setter("ThingType", "TT_TOOLPOWER", 0, 65535)),
43     "TT_START_NUMBER": (1, False, setter("ThingType", "TT_START_NUMBER",
44                                          0, 255)),
45     "TT_PROLIFERATE": (1, False, setter("ThingType", "TT_PROLIFERATE",
46                                         0, 65535)),
47     "TT_LIFEPOINTS": (1, False, setter("ThingType", "TT_LIFEPOINTS", 0, 255)),
48     "T_ID": (1, False, command_tid),
49     "T_ARGUMENT": (1, False, setter("Thing", "T_ARGUMENT", 0, 255)),
50     "T_PROGRESS": (1, False, setter("Thing", "T_PROGRESS", 0, 255)),
51     "T_LIFEPOINTS": (1, False, setter("Thing", "T_LIFEPOINTS", 0, 255)),
52     "T_SATIATION": (1, False, setter("Thing", "T_SATIATION", -32768, 32767)),
53     "T_COMMAND": (1, False, command_tcommand),
54     "T_TYPE": (1, False, command_ttype),
55     "T_CARRIES": (1, False, command_tcarries),
56     "T_MEMMAP": (2, False, setter_map("T_MEMMAP")),
57     "T_MEMDEPTHMAP": (2, False, setter_map("T_MEMDEPTHMAP")),
58     "T_MEMTHING": (3, False, command_tmemthing),
59     "T_POSY": (1, False, setter_tpos("Y")),
60     "T_POSX": (1, False, setter_tpos("X")),
61     "wait": (0, False, play_wait),
62     "move": (1, False, play_move),
63     "pickup": (0, False, play_pickup),
64     "drop": (1, False, play_drop),
65     "use": (1, False, play_use),
66     "ai": (0, False, command_ai)
67 }
68 # TODO: Unhandled cases: (Un-)killing animates (esp. player!) with T_LIFEPOINTS.
69
70 command_worldactive_test_hook = lambda: True
71 play_move_attempt_hook = lambda x, y, z: False