self.io.send('MAP_CONTROL %s' % quote(player.visible_control), c_id)
for t in [t for t in self.things if player.fov_test(*t.position)]:
target_yx = player.fov_stencil.target_yx(*t.position)
- self.io.send('THING %s %s %s %s %s' % (target_yx, t.type_,
- quote(t.protection),
- t.id_, int(t.portable)),
+ self.io.send('THING %s %s %s %s %s %s'
+ % (target_yx, t.type_, quote(t.protection), t.id_,
+ int(t.portable), int(t.commandable)),
c_id)
if hasattr(t, 'name'):
self.io.send('THING_NAME %s %s' % (t.id_, quote(t.name)), c_id)
self.io.send('THING_CHAR %s %s' % (t.id_,
quote(t.thing_char)), c_id)
if hasattr(t, 'carrying') and t.carrying:
- self.io.send('THING_CARRYING %s' % (t.id_), c_id)
+ self.io.send('THING_CARRYING %s %s' % (t.id_, t.carrying.id_),
+ c_id)
if hasattr(t, 'installable') and not t.portable:
self.io.send('THING_INSTALLED %s' % (t.id_), c_id)
for big_yx in self.portals:
t.type_ = tokens[2];
t.protection = tokens[3];
t.portable = parseInt(tokens[5]);
+ t.commandable = parseInt(tokens[6]);
} else if (tokens[0] === 'THING_NAME') {
let t = game.get_thing(tokens[1], false);
t.name_ = tokens[2];
game.thing_types[tokens[1]] = tokens[2]
} else if (tokens[0] === 'THING_CARRYING') {
let t = game.get_thing(tokens[1], false);
- t.carrying = true;
+ t.carrying = t = game.get_thing(tokens[2], false);
} else if (tokens[0] === 'THING_INSTALLED') {
let t = game.get_thing(tokens[1], false);
t.installed = true;
tui.log_msg('@ finished tile protection drawing.')
}
this.tile_draw = false;
+ const player = game.things[game.player_id];
+ if (mode_name == 'command_thing' && (!player.carrying || !player.carrying.commandable)) {
+ this.log_msg('? not carrying anything commandable');
+ terminal.blink_screen();
+ this.switch_mode('play');
+ return;
+ };
if (mode_name == 'admin_enter' && this.is_admin) {
mode_name = 'admin';
} else if (['name_thing', 'admin_thing_protect'].includes(mode_name)) {
- let player_position = game.things[game.player_id].position;
let thing_id = null;
for (let t_id in game.things) {
if (t_id == game.player_id) {
continue;
}
let t = game.things[t_id];
- if (player_position[0] == t.position[0] && player_position[1] == t.position[1]) {
+ if (player.position[0] == t.position[0]
+ && player.position[1] == t.position[1]) {
thing_id = t_id;
break;
}
tui.inputEl.value = "";
tui.switch_mode('edit');
} else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
- if (tui.task_action_on('command')) {
- server.send(['TASK:COMMAND', tui.inputEl.value]);
- tui.inputEl.value = "";
- }
+ server.send(['TASK:COMMAND', tui.inputEl.value]);
+ tui.inputEl.value = "";
} else if (tui.mode.name == 'take_thing' && event.key == 'Enter') {
const i = parseInt(tui.inputEl.value);
if (isNaN(i) || i < 0 || i >= tui.selectables.length) {
game.player_id = player_id
cmd_PLAYER_ID.argtypes = 'int:nonneg'
-def cmd_THING(game, yx, thing_type, protection, thing_id, portable):
+def cmd_THING(game, yx, thing_type, protection, thing_id, portable, commandable):
t = game.get_thing(thing_id)
if not t:
t = ThingBase(game, thing_id)
t.type_ = thing_type
t.protection = protection
t.portable = portable
-cmd_THING.argtypes = 'yx_tuple:nonneg string:thing_type char int:nonneg bool'
+ t.commandable = commandable
+cmd_THING.argtypes = 'yx_tuple:nonneg string:thing_type char int:nonneg bool bool'
def cmd_THING_NAME(game, thing_id, name):
t = game.get_thing(thing_id)
game.get_thing(thing_id).installed = True
cmd_THING_INSTALLED.argtypes = 'int:pos'
-def cmd_THING_CARRYING(game, thing_id):
- game.get_thing(thing_id).carrying = True
-cmd_THING_CARRYING.argtypes = 'int:pos'
+def cmd_THING_CARRYING(game, thing_id, carried_id):
+ game.get_thing(thing_id).carrying = game.get_thing(carried_id)
+cmd_THING_CARRYING.argtypes = 'int:pos int:pos'
def cmd_TERRAIN(game, terrain_char, terrain_desc):
game.terrains[terrain_char] = terrain_desc
if self.mode and self.mode.name == 'control_tile_draw':
self.log_msg('@ finished tile protection drawing.')
self.tile_draw = False
+ player = self.game.get_thing(self.game.player_id)
+ if mode_name == 'command_thing' and\
+ (not hasattr(player, 'carrying') or not player.carrying.commandable):
+ self.log_msg('? not carrying anything commandable')
+ self.flash = True
+ self.switch_mode('play')
+ return
if mode_name == 'admin_enter' and self.is_admin:
mode_name = 'admin'
elif mode_name in {'name_thing', 'admin_thing_protect'}:
- player = self.game.get_thing(self.game.player_id)
thing = None
for t in [t for t in self.game.things if t.position == player.position
and t.id_ != player.id_]:
self.input_ = ''
self.switch_mode('play')
elif self.mode.name == 'command_thing' and key == '\n':
- if task_action_on('command'):
- self.send('TASK:COMMAND ' + quote(self.input_))
- self.input_ = ""
+ self.send('TASK:COMMAND ' + quote(self.input_))
+ self.input_ = ""
elif self.mode.name == 'control_pw_pw' and key == '\n':
if self.input_ == '':
self.log_msg('@ aborted')