"switch_to_study": "?",
"switch_to_edit": "m",
"flatten": "F",
+ "take_thing": "z",
+ "drop_thing": "u",
"help": "h",
"toggle_map_mode": "M",
"hex_move_upleft": "w",
todo = 1
def do(self):
- return 'success'
+ pass
def do(self):
self.thing.position = self.get_move_target()
+ if self.thing.carrying:
+ self.thing.carrying.position = self.thing.position
if not self.thing.game.can_do_tile_with_pw(yx, self.args[0]):
continue
self.thing.game.map[yx] = '.'
+
+
+
+class Task_PICK_UP(Task):
+ todo = 1
+
+ def check(self):
+ if self.thing.carrying:
+ raise PlayError('already carrying')
+ nothing_to_pick_up = True
+ for t in [t for t in self.thing.game.things
+ if t != self.thing and t.position == self.thing.position
+ and t.type_ != 'Player']:
+ nothing_to_pick_up = False
+ break
+ if nothing_to_pick_up:
+ raise PlayError('nothing to pick up')
+
+ def do(self):
+ to_pick_up = [t for t in self.thing.game.things
+ if t != self.thing and t.position == self.thing.position][0]
+ self.thing.carrying = to_pick_up
+
+
+
+class Task_DROP(Task):
+ todo = 1
+
+ def check(self):
+ if not self.thing.carrying:
+ raise PlayError('nothing to drop')
+
+ def do(self):
+ self.thing.carrying = None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.nickname = 'undefined'
+ self.carrying = None
cmd_ANNOTATE, cmd_PORTAL, cmd_GET_GAMESTATE,
cmd_TASKS, cmd_MAP_CONTROL_LINE, cmd_MAP_CONTROL_PW,
cmd_GOD_ANNOTATE, cmd_GOD_PORTAL, cmd_THING_TYPES)
-from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE,
- Task_FLATTEN_SURROUNDINGS)
+from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
+ Task_DROP, Task_FLATTEN_SURROUNDINGS)
from plomrogue.things import Thing_Player, Thing_Stone
import sys
game.register_task(Task_MOVE)
game.register_task(Task_WRITE)
game.register_task(Task_FLATTEN_SURROUNDINGS)
+game.register_task(Task_PICK_UP)
+game.register_task(Task_DROP)
game.register_thing_type(Thing_Player)
game.register_thing_type(Thing_Stone)
game.read_savefile()
'switch_to_study': '?',
'switch_to_edit': 'm',
'flatten': 'F',
+ 'take_thing': 'z',
+ 'drop_thing': 'u',
'toggle_map_mode': 'M',
'hex_move_upleft': 'w',
'hex_move_upright': 'e',
content += "Available actions:\n"
if 'MOVE' in self.game.tasks:
content += "[%s] – move player\n" % ','.join(self.movement_keys)
+ if 'PICK_UP' in self.game.tasks:
+ content += "[%s] – take thing under player\n" % self.keys['take_thing']
+ if 'DROP' in self.game.tasks:
+ content += "[%s] – drop carried thing\n" % self.keys['drop_thing']
if 'FLATTEN_SURROUNDINGS' in self.game.tasks:
content += "[%s] – flatten player's surroundings\n" % self.keys['flatten']
content += 'Other modes available from here:\n'
elif key == self.keys['flatten'] and\
'FLATTEN_SURROUNDINGS' in self.game.tasks:
self.send('TASK:FLATTEN_SURROUNDINGS ' + quote(self.password))
+ elif key == self.keys['take_thing'] and 'PICK_UP' in self.game.tasks:
+ self.send('TASK:PICK_UP')
+ elif key == self.keys['drop_thing'] and 'DROP' in self.game.tasks:
+ self.send('TASK:DROP')
elif key in self.movement_keys and 'MOVE' in self.game.tasks:
self.send('TASK:MOVE ' + self.movement_keys[key])
elif self.mode == self.mode_edit:
move left (hex grid): <input id="key_hex_move_left" type="text" value="a" /><br />
help: <input id="key_help" type="text" value="h" /><br />
flatten surroundings: <input id="key_flatten" type="text" value="F" /><br />
+take thing under player: <input id="key_take_thing" type="text" value="z" /><br />
+drop carried thing: <input id="key_drop_thing" type="text" value="u" /><br />
switch to chat mode: <input id="key_switch_to_chat" type="text" value="t" /><br />
switch to play mode: <input id="key_switch_to_play" type="text" value="p" /><br />
switch to study mode: <input id="key_switch_to_study" type="text" value="?" /><br />
if (game.tasks.includes('MOVE')) {
content += "[" + movement_keys_desc + "] – move player\n";
}
+ if (game.tasks.includes('PICK_UP')) {
+ content += "[" + this.keys.take_thing + "] – take thing under player\n";
+ }
+ if (game.tasks.includes('DROP')) {
+ content += "[" + this.keys.drop_thing + "] – drop carried thing\n";
+ }
if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
content += "[" + tui.keys.flatten + "] – flatten player's surroundings\n";
}
} else if (event.key === tui.keys.flatten
&& game.tasks.includes('FLATTEN_SURROUNDINGS')) {
server.send(["TASK:FLATTEN_SURROUNDINGS", tui.password]);
+ } else if (event.key === tui.keys.take_thing
+ && game.tasks.includes('PICK_UP')) {
+ server.send(["TASK:PICK_UP"]);
+ } else if (event.key === tui.keys.drop_thing
+ && game.tasks.includes('DROP')) {
+ server.send(["TASK:DROP"]);
} else if (event.key in tui.movement_keys
&& game.tasks.includes('MOVE')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);