class Task_PICK_UP(Task):
- argtypes = 'int:nonneg'
+ argtypes = 'int:pos'
def check(self):
if self.thing.carrying:
self.thing.drunk = 10000
+
class Task_COMMAND(Task):
argtypes = 'string'
for c_id in self.thing.game.sessions:
if self.thing.game.sessions[c_id]['thing_id'] == self.thing.id_:
self.thing.game.io.send('REPLY ' + quote(reply), c_id)
+
+
+
+class Task_INSTALL(Task):
+
+ def _get_uninstallables(self):
+ return [t for t in self.thing.game.things
+ if t != self.thing
+ and hasattr(t, 'installable') and t.installable
+ and (not t.portable)
+ and t.position == self.thing.position]
+
+ def check(self):
+ if self.thing.carrying:
+ if not hasattr(self.thing.carrying, 'installable')\
+ or not self.thing.carrying.installable:
+ raise PlayError('carried thing not installable')
+ elif len(self._get_uninstallables()) == 0:
+ raise PlayError('nothing to uninstall here')
+
+ def do(self):
+ if self.thing.carrying:
+ self.thing.carrying.install()
+ self.thing.carrying = None
+ else:
+ self._get_uninstallables()[0].uninstall()
symbol_hint = 'D'
blocking = False
portable = True
+ installable = True
def open(self):
self.blocking = False
- self.portable = True
del self.thing_char
def close(self):
self.blocking = True
- self.portable = False
self.thing_char = '#'
+ def install(self):
+ self.portable = False
+
+ def uninstall(self):
+ self.portable = True
+
class Thing_Bottle(Thing):
<button id="consume"></button>
<button id="switch_to_command_thing"></button>
<button id="teleport"></button>
+ <button id="install"></button>
</td>
</tr>
<tr>
<li>drop thing: <input id="key_drop_thing" type="text" value="u" />
<li>open/close: <input id="key_door" type="text" value="D" />
<li>consume: <input id="key_consume" type="text" value="C" />
+<li>install: <input id="key_install" type="text" value="I" />
<li><input id="key_switch_to_take_thing" type="text" value="z" />
<li><input id="key_switch_to_chat" type="text" value="t" />
<li><input id="key_switch_to_play" type="text" value="p" />
'drop_thing': 'drop thing',
'door': 'open/close',
'consume': 'consume',
+ 'install': 'install',
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
'hex_move_upleft': 'up-left',
'drop_thing': 'DROP',
'move': 'MOVE',
'door': 'DOOR',
+ 'install': 'INSTALL',
'command': 'COMMAND',
'consume': 'INTOXICATE',
},
this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
"command_thing", "take_thing"]
this.mode_play.available_actions = ["move", "drop_thing",
- "teleport", "door", "consume"];
+ "teleport", "door", "consume", "install"];
this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
this.mode_study.available_actions = ["toggle_map_mode", "move_explorer"];
this.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
server.send(["TASK:INTOXICATE"]);
} else if (event.key === tui.keys.door && tui.task_action_on('door')) {
server.send(["TASK:DOOR"]);
+ } else if (event.key === tui.keys.install && tui.task_action_on('install')) {
+ server.send(["TASK:INSTALL"]);
} else if (event.key in tui.movement_keys && tui.task_action_on('move')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
} else if (event.key === tui.keys.teleport) {
document.getElementById("consume").onclick = function() {
server.send(['TASK:INTOXICATE']);
};
+document.getElementById("install").onclick = function() {
+ server.send(['TASK:INSTALL']);
+};
document.getElementById("teleport").onclick = function() {
game.teleport();
};
cmd_THING_BOTTLE_EMPTY)
from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
Task_DROP, Task_FLATTEN_SURROUNDINGS, Task_DOOR,
- Task_INTOXICATE, Task_COMMAND)
+ Task_INTOXICATE, Task_COMMAND, Task_INSTALL)
from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
game.register_task(Task_DOOR)
game.register_task(Task_INTOXICATE)
game.register_task(Task_COMMAND)
+game.register_task(Task_INSTALL)
game.register_thing_type(Thing_Player)
game.register_thing_type(Thing_Item)
game.register_thing_type(Thing_ItemSpawner)
self.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
"command_thing", "take_thing"]
self.mode_play.available_actions = ["move", "drop_thing",
- "teleport", "door", "consume"]
+ "teleport", "door", "consume",
+ "install"]
self.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
self.mode_study.available_actions = ["toggle_map_mode", "move_explorer"]
self.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
'teleport': 'p',
'consume': 'C',
'door': 'D',
+ 'install': 'I',
'help': 'h',
'toggle_map_mode': 'L',
'toggle_tile_draw': 'm',
'drop_thing': 'drop thing',
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
+ 'install': 'install',
'door': 'open/close',
'consume': 'consume',
}
'take_thing': 'PICK_UP',
'drop_thing': 'DROP',
'door': 'DOOR',
+ 'install': 'INSTALL',
'move': 'MOVE',
'command': 'COMMAND',
'consume': 'INTOXICATE',
self.send('TASK:DOOR')
elif key == self.keys['consume'] and task_action_on('consume'):
self.send('TASK:INTOXICATE')
+ elif key == self.keys['install'] and task_action_on('install'):
+ self.send('TASK:INSTALL')
elif key == self.keys['teleport']:
player = self.game.get_thing(self.game.player_id)
if player.position in self.game.portals: