"drop_thing": "u",
"teleport": "p",
"door": "D",
+ "install": "I",
+ "wear": "W",
"consume": "C",
"help": "h",
"toggle_map_mode": "L",
def cmd_GOD_PLAYER_FACE(game, name, face):
game.faces[name] = face
cmd_GOD_PLAYER_FACE.argtypes = 'string string'
+
+def cmd_GOD_PLAYER_HAT(game, name, hat):
+ game.hats[name] = hat
+cmd_GOD_PLAYER_HAT.argtypes = 'string string'
self.thing_types = {}
self.sessions = {}
self.faces = {}
+ self.hats = {}
self.maps = {}
self.map_controls = {}
self.map_control_passwords = {}
c_id)
if hasattr(t, 'name'):
self.io.send('THING_NAME %s %s' % (t.id_, quote(t.name)), c_id)
+ if t.type_ == 'Player' and t.name in self.hats:
+ hat = self.hats[t.name]
+ self.io.send('THING_HAT %s %s' % (t.id_, quote(hat)), c_id)
face = self.get_face(t)
if face:
self.io.send('THING_FACE %s %s' % (t.id_, quote(face)), c_id)
for name in self.faces:
write(f, 'GOD_PLAYER_FACE %s %s' % (quote(name),
quote(self.faces[name])))
+ for name in self.hats:
+ write(f, 'GOD_PLAYER_HAT %s %s' % (quote(name),
+ quote(self.hats[name])))
for t in [t for t in self.things if not t.type_ == 'Player']:
write(f, 'THING %s %s %s %s' % (t.position[0],
t.position[1], t.type_, t.id_))
else:
self._get_uninstallables()[0].uninstall()
self.thing.send_msg('CHAT "You uninstall the thing here."')
+
+
+
+class Task_WEAR(Task):
+
+ def check(self):
+ if self.thing.name in self.thing.game.hats:
+ return
+ if not self.thing.carrying:
+ raise PlayError('carrying nothing to wear')
+ if self.thing.name in self.thing.game.hats:
+ raise PlayError('already wearing a hat')
+ if self.thing.carrying.type_ != 'Hat':
+ raise PlayError('can only wear a hat')
+
+ def do(self):
+ if self.thing.name in self.thing.game.hats:
+ t = self.thing.game.thing_types['Hat'](self.thing.game,
+ position=self.thing.position)
+ self.thing.game.things += [t]
+ t.design = self.thing.game.hats[self.thing.name]
+ del self.thing.game.hats[self.thing.name]
+ else:
+ self.thing.game.hats[self.thing.name] = self.thing.carrying.design
+ self.thing.game.things.remove(self.thing.carrying)
+ self.thing.carrying = None
+class Thing_Hat(Thing):
+ symbol_hint = 'H'
+ portable = True
+ design = ' X X ==='
+
+
+
+class Thing_HatSpawner(ThingSpawner):
+ child_type = 'Hat'
+
+
+
+
import datetime
class Thing_MusicPlayer(Thing):
symbol_hint = 'R'
<button id="switch_to_command_thing"></button>
<button id="teleport"></button>
<button id="install"></button>
+ <button id="wear"></button>
</td>
</tr>
<tr>
<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>(un-)wear: <input id="key_wear" type="text" value="W" />
<li><input id="key_switch_to_enter_face" type="text" value="f" />
<li><input id="key_switch_to_take_thing" type="text" value="z" />
<li><input id="key_switch_to_chat" type="text" value="t" />
'door': 'open/close',
'consume': 'consume',
'install': '(un-)install',
+ 'wear': '(un-)wear',
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
'hex_move_upleft': 'up-left',
} else if (tokens[0] === 'THING_FACE') {
let t = game.get_thing(tokens[1], false);
t.face = tokens[2];
+ } else if (tokens[0] === 'THING_HAT') {
+ let t = game.get_thing(tokens[1], false);
+ t.hat = tokens[2];
} else if (tokens[0] === 'THING_CHAR') {
let t = game.get_thing(tokens[1], false);
t.thing_char = tokens[2];
'move': 'MOVE',
'door': 'DOOR',
'install': 'INSTALL',
+ 'wear': 'WEAR',
'command': 'COMMAND',
'consume': 'INTOXICATE',
},
init: function() {
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", "install"];
+ this.mode_play.available_actions = ["move", "drop_thing", "teleport",
+ "door", "consume", "install", "wear"];
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",
protection = 'none';
}
info_to_cache += " / protection: " + protection + "\n";
+ if (t.hat) {
+ info_to_cache += t.hat.slice(0, 3) + '\n';
+ info_to_cache += t.hat.slice(3, 6) + '\n';
+ info_to_cache += t.hat.slice(6, 9) + '\n';
+ }
if (t.face) {
info_to_cache += t.face.slice(0, 3) + '\n';
info_to_cache += t.face.slice(3, 6) + '\n';
server.send(["TASK:DOOR"]);
} else if (event.key === tui.keys.install && tui.task_action_on('install')) {
server.send(["TASK:INSTALL"]);
+ } else if (event.key === tui.keys.install && tui.task_action_on('wear')) {
+ server.send(["TASK:WEAR"]);
} 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("install").onclick = function() {
server.send(['TASK:INSTALL']);
};
+document.getElementById("wear").onclick = function() {
+ server.send(['TASK:WEAR']);
+};
document.getElementById("teleport").onclick = function() {
game.teleport();
};
cmd_THING_MUSICPLAYER_SETTINGS,
cmd_THING_MUSICPLAYER_PLAYLIST_ITEM,
cmd_THING_BOTTLE_EMPTY, cmd_PLAYER_FACE,
- cmd_GOD_PLAYER_FACE)
+ cmd_GOD_PLAYER_FACE, cmd_GOD_PLAYER_HAT)
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_INSTALL)
+ Task_INTOXICATE, Task_COMMAND, Task_INSTALL,
+ Task_WEAR)
from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
Thing_SpawnPoint, Thing_SpawnPointSpawner,
Thing_Door, Thing_DoorSpawner, Thing_Bottle,
Thing_BottleSpawner, Thing_BottleDeposit,
- Thing_MusicPlayer)
+ Thing_MusicPlayer, Thing_Hat, Thing_HatSpawner)
from plomrogue.config import config
game = Game(config['savefile'])
game.register_command(cmd_THING_BOTTLE_EMPTY)
game.register_command(cmd_PLAYER_FACE)
game.register_command(cmd_GOD_PLAYER_FACE)
+game.register_command(cmd_GOD_PLAYER_HAT)
game.register_task(Task_WAIT)
game.register_task(Task_MOVE)
game.register_task(Task_WRITE)
game.register_task(Task_INTOXICATE)
game.register_task(Task_COMMAND)
game.register_task(Task_INSTALL)
+game.register_task(Task_WEAR)
game.register_thing_type(Thing_Player)
game.register_thing_type(Thing_Item)
game.register_thing_type(Thing_ItemSpawner)
game.register_thing_type(Thing_BottleSpawner)
game.register_thing_type(Thing_BottleDeposit)
game.register_thing_type(Thing_MusicPlayer)
+game.register_thing_type(Thing_Hat)
+game.register_thing_type(Thing_HatSpawner)
game.read_savefile()
game.io.start_loop()
for port in config['servers']:
t.face = face
cmd_THING_FACE.argtypes = 'int:pos string'
+def cmd_THING_HAT(game, thing_id, hat):
+ t = game.get_thing(thing_id)
+ t.hat = hat
+cmd_THING_HAT.argtypes = 'int:pos string'
+
def cmd_THING_CHAR(game, thing_id, c):
t = game.get_thing(thing_id)
t.thing_char = c
self.register_command(cmd_THING_NAME)
self.register_command(cmd_THING_CHAR)
self.register_command(cmd_THING_FACE)
+ self.register_command(cmd_THING_HAT)
self.register_command(cmd_THING_CARRYING)
self.register_command(cmd_THING_INSTALLED)
self.register_command(cmd_TERRAIN)
"command_thing", "take_thing"]
self.mode_play.available_actions = ["move", "drop_thing",
"teleport", "door", "consume",
- "install"]
+ "install", "wear"]
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",
'consume': 'C',
'door': 'D',
'install': 'I',
+ 'wear': 'W',
'help': 'h',
'toggle_map_mode': 'L',
'toggle_tile_draw': 'm',
if protection == '.':
protection = 'none'
info_to_cache += ' / protection: %s\n' % protection
+ if hasattr(t, 'hat'):
+ info_to_cache += t.hat[0:3] + '\n'
+ info_to_cache += t.hat[3:6] + '\n'
+ info_to_cache += t.hat[6:9] + '\n'
if hasattr(t, 'face'):
info_to_cache += t.face[0:3] + '\n'
info_to_cache += t.face[3:6] + '\n'
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
'install': '(un-)install',
+ 'wear': '(un-)wear',
'door': 'open/close',
'consume': 'consume',
}
'drop_thing': 'DROP',
'door': 'DOOR',
'install': 'INSTALL',
+ 'wear': 'WEAR',
'move': 'MOVE',
'command': 'COMMAND',
'consume': 'INTOXICATE',
self.send('TASK:INTOXICATE')
elif key == self.keys['install'] and task_action_on('install'):
self.send('TASK:INSTALL')
+ elif key == self.keys['wear'] and task_action_on('wear'):
+ self.send('TASK:WEAR')
elif key == self.keys['teleport']:
player = self.game.get_thing(self.game.player_id)
if player.position in self.game.portals: