<tr>
<td><button id="switch_to_play"></button></td>
<td>
- <button id="take_thing"></button>
+ <button id="switch_to_take_thing"></button>
<button id="drop_thing"></button>
<button id="door"></button>
<button id="consume"></button>
<li>help: <input id="key_help" type="text" value="h" />
<li>flatten surroundings: <input id="key_flatten" type="text" value="F" />
<li>teleport: <input id="key_teleport" type="text" value="p" />
-<li>pick up thing: <input id="key_take_thing" type="text" value="z" />
<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><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" />
<li><input id="key_switch_to_study" type="text" value="?" />
'short': 'command thing',
'long': 'Enter a command to the thing you carry. Enter nothing to return to play mode.'
},
+ 'take_thing': {
+ 'short': 'take thing',
+ 'long': 'You see a list of things which you could pick up. Enter the target thing\'s index, or, to leave, nothing.'
+ },
'admin_thing_protect': {
'short': 'change thing protection',
'long': 'Change protection character for thing here.'
'help': 'help',
'flatten': 'flatten surroundings',
'teleport': 'teleport',
- 'take_thing': 'pick up thing',
'drop_thing': 'drop thing',
'door': 'open/close',
'consume': 'consume',
game.tasks = tokens[1].split(',');
tui.mode_write.legal = game.tasks.includes('WRITE');
tui.mode_command_thing.legal = game.tasks.includes('WRITE');
+ tui.mode_take_thing.legal = game.tasks.includes('PICK_UP');
} else if (tokens[0] === 'THING_TYPE') {
game.thing_types[tokens[1]] = tokens[2]
} else if (tokens[0] === 'TERRAIN') {
mode_password: new Mode('password', true),
mode_name_thing: new Mode('name_thing', true, true),
mode_command_thing: new Mode('command_thing', true),
+ mode_take_thing: new Mode('take_thing', true),
mode_admin_enter: new Mode('admin_enter', true),
mode_admin: new Mode('admin'),
mode_control_pw_pw: new Mode('control_pw_pw', true),
init: function() {
this.mode_chat.available_modes = ["play", "study", "edit", "admin_enter"]
this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
- "command_thing"]
- this.mode_play.available_actions = ["move", "take_thing", "drop_thing",
+ "command_thing", "take_thing"]
+ this.mode_play.available_actions = ["move", "drop_thing",
"teleport", "door", "consume"];
this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
this.mode_study.available_actions = ["toggle_map_mode", "move_explorer"];
}
} else if (this.mode.is_single_char_entry) {
this.show_help = true;
+ } else if (this.mode.name == 'take_thing') {
+ this.log_msg("selectable things:");
+ const player = game.things[game.player_id];
+ let selectables = [];
+ for (const t_id in game.things) {
+ const t = game.things[t_id];
+ if (t.position[0] == player.position[0]
+ && t.position[1] == player.position[1]
+ && t != player && t.type_ != 'Player') {
+ selectables.push([t_id, t]);
+ }
+ };
+ if (selectables.length == 0) {
+ this.log_msg('none')
+ } else {
+ for (const t of selectables) {
+ this.log_msg(t[0] + ' ' + explorer.get_thing_info(t[1]));
+ }
+ }
} else if (this.mode.name == 'command_thing') {
server.send(['TASK:COMMAND', 'HELP']);
} else if (this.mode.name == 'admin_enter') {
map_lines_split[coordinate[0]][coordinate[1]] = original[0] + 'P';
}
let used_positions = [];
- for (const thing_id in game.things) {
- let t = game.things[thing_id];
+ function draw_thing(t, used_positions) {
let symbol = game.thing_types[t.type_];
let meta_char = ' ';
if (t.thing_char) {
};
map_lines_split[t.position[0]][t.position[1]] = symbol + meta_char;
used_positions.push(t.position.toString());
+ }
+ for (const thing_id in game.things) {
+ let t = game.things[thing_id];
+ if (t.type_ != 'Player') {
+ draw_thing(t, used_positions);
+ }
+ };
+ for (const thing_id in game.things) {
+ let t = game.things[thing_id];
+ if (t.type_ == 'Player') {
+ draw_thing(t, used_positions);
+ }
};
}
let player = game.things[game.player_id];
for (let t_id in game.things) {
let t = game.things[t_id];
if (t.position[0] == this.position[0] && t.position[1] == this.position[1]) {
- let symbol = game.thing_types[t.type_];
+ info_to_cache += "THING: " + this.get_thing_info(t);
let protection = t.protection;
if (protection == '.') {
protection = 'none';
}
- info_to_cache += "THING: " + t.type_ + " / " + symbol;
- if (t.thing_char) {
- info_to_cache += t.thing_char;
- };
- if (t.name_) {
- info_to_cache += " (" + t.name_ + ")";
- }
info_to_cache += " / protection: " + protection + "\n";
}
}
this.info_cached = info_to_cache;
return this.info_cached;
},
+ get_thing_info: function(t) {
+ const symbol = game.thing_types[t.type_];
+ let info = t.type_ + " / " + symbol;
+ if (t.thing_char) {
+ info += t.thing_char;
+ };
+ if (t.name_) {
+ info += " (" + t.name_ + ")";
+ }
+ return info;
+ },
annotate: function(msg) {
if (msg.length == 0) {
msg = " "; // triggers annotation deletion
server.send(['TASK:COMMAND', tui.inputEl.value]);
tui.inputEl.value = "";
}
+ } else if (tui.mode.name == 'take_thing' && event.key == 'Enter') {
+ if (tui.inputEl.value.length == 0) {
+ tui.log_msg('@ aborted');
+ } else {
+ server.send(['TASK:PICK_UP', tui.inputEl.value]);
+ }
+ tui.inputEl.value = "";
+ tui.switch_mode('play');
} else if (tui.mode.name == 'control_pw_pw' && event.key == 'Enter') {
if (tui.inputEl.value.length == 0) {
tui.log_msg('@ aborted');
} else if (tui.mode.name == 'play') {
if (tui.mode.mode_switch_on_key(event)) {
null;
- } else if (event.key === tui.keys.take_thing && tui.task_action_on('take_thing')) {
- server.send(["TASK:PICK_UP"]);
} else if (event.key === tui.keys.drop_thing && tui.task_action_on('drop_thing')) {
server.send(["TASK:DROP"]);
} else if (event.key === tui.keys.consume && tui.task_action_on('consume')) {
tui.toggle_map_mode();
tui.full_refresh();
};
-document.getElementById("take_thing").onclick = function() {
- server.send(['TASK:PICK_UP']);
-};
document.getElementById("drop_thing").onclick = function() {
- server.send(['TASK:DROP']);
+ server.send(['TASK:DROP']);
};
document.getElementById("flatten").onclick = function() {
server.send(['TASK:FLATTEN_SURROUNDINGS', tui.password]);