<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') {
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]);
'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.'
game.tasks = tasks_comma_separated.split(',')
game.tui.mode_write.legal = 'WRITE' in game.tasks
game.tui.mode_command_thing.legal = 'COMMAND' in game.tasks
+ game.tui.mode_take_thing.legal = 'PICK_UP' in game.tasks
cmd_TASKS.argtypes = 'string'
def cmd_THING_TYPE(game, thing_type, symbol_hint):
mode_password = Mode('password', has_input_prompt=True)
mode_name_thing = Mode('name_thing', has_input_prompt=True, shows_info=True)
mode_command_thing = Mode('command_thing', has_input_prompt=True)
+ mode_take_thing = Mode('take_thing', has_input_prompt=True)
is_admin = False
tile_draw = False
import os
import json
self.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
- "command_thing"]
- self.mode_play.available_actions = ["move", "take_thing", "drop_thing",
+ "command_thing", "take_thing"]
+ self.mode_play.available_actions = ["move", "drop_thing",
"teleport", "door", "consume"]
self.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
self.mode_study.available_actions = ["toggle_map_mode", "move_explorer"]
'switch_to_control_tile_type': 'Q',
'switch_to_admin_thing_protect': 'T',
'flatten': 'F',
- 'take_thing': 'z',
+ 'switch_to_take_thing': 'z',
'drop_thing': 'u',
'teleport': 'p',
'consume': 'C',
self.send('LOGIN ' + quote(self.login_name))
else:
self.log_msg('@ enter username')
+ elif self.mode.name == 'take_thing':
+ self.log_msg('selectable things:')
+ player = self.game.get_thing(self.game.player_id)
+ selectables = [t for t in self.game.things
+ if t != player and t.type_ != 'Player'
+ and t.position == player.position]
+ if len(selectables) == 0:
+ self.log_msg('none')
+ else:
+ for t in selectables:
+ self.log_msg(str(t.id_) + ' ' + self.get_thing_info(t))
elif self.mode.name == 'command_thing':
self.send('TASK:COMMAND ' + quote('HELP'))
elif self.mode.name == 'admin_enter':
info_to_cache += 'PROTECTION: %s\n' % protection
for t in self.game.things:
if t.position == self.explorer:
+ info_to_cache += 'THING: %s' % self.get_thing_info(t)
protection = t.protection
if protection == '.':
protection = 'none'
- info_to_cache += 'THING: %s / %s' %\
- (t.type_, self.game.thing_types[t.type_])
- if hasattr(t, 'thing_char'):
- info_to_cache += t.thing_char
- if hasattr(t, 'name'):
- info_to_cache += ' (%s)' % t.name
info_to_cache += ' / protection: %s\n' % protection
if self.explorer in self.game.portals:
info_to_cache += 'PORTAL: ' +\
self.info_cached = info_to_cache
return self.info_cached
+ def get_thing_info(self, t):
+ info = '%s / %s' %\
+ (t.type_, self.game.thing_types[t.type_])
+ if hasattr(t, 'thing_char'):
+ info += t.thing_char
+ if hasattr(t, 'name'):
+ info += ' (%s)' % t.name
+ return info
+
def loop(self, stdscr):
import datetime
self.login_name = self.input_
self.send('LOGIN ' + quote(self.input_))
self.input_ = ""
+ elif self.mode.name == 'take_thing' and key == '\n':
+ if self.input_ == '':
+ self.log_msg('@ aborted')
+ else:
+ self.send('TASK:PICK_UP ' + quote(self.input_))
+ self.input_ = ''
+ self.switch_mode('play')
elif self.mode.name == 'command_thing' and key == '\n':
if self.input_ == '':
self.log_msg('@ aborted')
elif self.mode.name == 'play':
if self.mode.mode_switch_on_key(self, key):
continue
- elif key == self.keys['take_thing'] and task_action_on('take_thing'):
- self.send('TASK:PICK_UP')
elif key == self.keys['drop_thing'] and task_action_on('drop_thing'):
self.send('TASK:DROP')
elif key == self.keys['door'] and task_action_on('door'):