X-Git-Url: https://plomlompom.com/repos/todo?a=blobdiff_plain;f=rogue_chat.html;h=8efe2a2a637c5e55a8d6a634976a514cb7d6001e;hb=c1024023126d1fd91be3145e50cae4b493d7a956;hp=9be10523e911239400965e16eac91783bba4308c;hpb=06e12644d7261a1f0a154db5f0cfb6336dca6079;p=plomrogue2
diff --git a/rogue_chat.html b/rogue_chat.html
index 9be1052..8efe2a2 100644
--- a/rogue_chat.html
+++ b/rogue_chat.html
@@ -20,60 +20,63 @@ terminal rows:
keyboard input/control:
button controls for mouse players
-
+
- |
- |
- |
+ |
+ |
+ |
- |
+ |
move |
- |
+ |
- |
- |
- |
+ |
+ |
+ |
- |
+ |
-
|
+
|
- |
-
+ | |
+
|
- |
+ |
-
-
-
+
+
+
+
+
+
|
- |
+ |
-
-
-
-
-
-
+
+
+
+
+
+
|
- |
+ |
-
-
-
-
+
+
+
+
|
@@ -95,12 +98,15 @@ keyboard input/control:
teleport:
pick up thing:
drop thing:
+open/close:
+consume:
+
@@ -133,6 +139,10 @@ let mode_helps = {
'short': 'name thing',
'long': 'Give name to/change name of thing here.'
},
+ 'command_thing': {
+ 'short': 'command thing',
+ 'long': 'Enter a command to the thing you carry. Enter nothing to return to play mode.'
+ },
'admin_thing_protect': {
'short': 'change thing protection',
'long': 'Change protection character for thing here.'
@@ -200,6 +210,8 @@ let key_descriptions = {
'teleport': 'teleport',
'take_thing': 'pick up thing',
'drop_thing': 'drop thing',
+ 'door': 'open/close',
+ 'consume': 'consume',
'toggle_map_mode': 'toggle map view',
'toggle_tile_draw': 'toggle protection character drawing',
'hex_move_upleft': 'up-left',
@@ -208,10 +220,10 @@ let key_descriptions = {
'hex_move_left': 'left',
'hex_move_downleft': 'down-left',
'hex_move_downright': 'down-right',
- 'square_move_right': 'right',
- 'square_move_left': 'left',
'square_move_up': 'up',
+ 'square_move_left': 'left',
'square_move_down': 'down',
+ 'square_move_right': 'right',
};
for (const mode_name of Object.keys(mode_helps)) {
key_descriptions['switch_to_' + mode_name] = mode_helps[mode_name].short;
@@ -248,14 +260,12 @@ function escapeHTML(str) {
};
let terminal = {
- foreground: 'white',
- background: 'black',
initialize: function() {
this.rows = rows_selector.value;
this.cols = cols_selector.value;
this.pre_el = document.getElementById("terminal");
- this.pre_el.style.color = this.foreground;
- this.pre_el.style.backgroundColor = this.background;
+ this.set_default_colors();
+ this.apply_colors();
this.content = [];
let line = []
for (let y = 0, x = 0; y <= this.rows; x++) {
@@ -271,6 +281,23 @@ let terminal = {
line.push(' ');
}
},
+ apply_colors: function() {
+ this.pre_el.style.color = this.foreground;
+ this.pre_el.style.backgroundColor = this.background;
+ },
+ set_default_colors: function() {
+ this.foreground = 'white';
+ this.background = 'black';
+ this.apply_colors();
+ },
+ set_random_colors: function() {
+ function rand(offset) {
+ return Math.floor(offset + Math.random() * 96).toString(16).padStart(2, '0');
+ }
+ this.foreground = '#' + rand(159) + rand(159) + rand(159);
+ this.background = '#' + rand(0) + rand(0) + rand(0);
+ this.apply_colors();
+ },
blink_screen: function() {
this.pre_el.style.color = this.background;
this.pre_el.style.backgroundColor = this.foreground;
@@ -427,11 +454,12 @@ let server = {
} else if (tokens[0] === 'THING_CHAR') {
let t = game.get_thing(tokens[1], false);
if (t) {
- t.player_char = tokens[2];
+ t.thing_char = tokens[2];
};
} else if (tokens[0] === 'TASKS') {
game.tasks = tokens[1].split(',');
tui.mode_write.legal = game.tasks.includes('WRITE');
+ tui.mode_command_thing.legal = game.tasks.includes('WRITE');
} else if (tokens[0] === 'THING_TYPE') {
game.thing_types[tokens[1]] = tokens[2]
} else if (tokens[0] === 'TERRAIN') {
@@ -455,11 +483,17 @@ let server = {
tui.full_refresh();
} else if (tokens[0] === 'CHAT') {
tui.log_msg('# ' + tokens[1], 1);
+ } else if (tokens[0] === 'REPLY') {
+ tui.log_msg('#MUSICPLAYER: ' + tokens[1], 1);
} else if (tokens[0] === 'PLAYER_ID') {
game.player_id = parseInt(tokens[1]);
} else if (tokens[0] === 'LOGIN_OK') {
this.send(['GET_GAMESTATE']);
tui.switch_mode('post_login_wait');
+ } else if (tokens[0] === 'DEFAULT_COLORS') {
+ terminal.set_default_colors();
+ } else if (tokens[0] === 'RANDOM_COLORS') {
+ terminal.set_random_colors();
} else if (tokens[0] === 'ADMIN_OK') {
tui.is_admin = true;
tui.log_msg('@ you now have admin rights');
@@ -522,6 +556,7 @@ class Mode {
this.name = name;
this.short_desc = mode_helps[name].short;
this.available_modes = [];
+ this.available_actions = [];
this.has_input_prompt = has_input_prompt;
this.shows_info= shows_info;
this.is_intro = is_intro;
@@ -588,21 +623,41 @@ let tui = {
mode_portal: new Mode('portal', true, true),
mode_password: new Mode('password', true),
mode_name_thing: new Mode('name_thing', true, true),
+ mode_command_thing: new Mode('command_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),
mode_control_tile_type: new Mode('control_tile_type', true),
mode_control_tile_draw: new Mode('control_tile_draw'),
+ action_tasks: {
+ 'flatten': 'FLATTEN_SURROUNDINGS',
+ 'take_thing': 'PICK_UP',
+ 'drop_thing': 'DROP',
+ 'move': 'MOVE',
+ 'door': 'DOOR',
+ 'command': 'COMMAND',
+ 'consume': 'INTOXICATE',
+ },
+ offset: [0,0],
+ map_lines: [],
init: function() {
- this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter"]
+ 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",
+ "teleport", "door", "consume"];
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",
"control_tile_type", "chat",
"study", "play", "edit"]
+ this.mode_admin.available_actions = ["move"];
this.mode_control_tile_draw.available_modes = ["admin_enter"]
+ this.mode_control_tile_draw.available_actions = ["toggle_tile_draw"];
this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing",
"password", "chat", "study", "play",
"admin_enter"]
+ this.mode_edit.available_actions = ["move", "flatten", "toggle_map_mode"]
this.mode = this.mode_waiting_for_server;
this.inputEl = document.getElementById("input");
this.inputEl.focus();
@@ -612,15 +667,16 @@ let tui = {
this.init_keys();
},
init_keys: function() {
+ document.getElementById("move_table").hidden = true;
this.keys = {};
for (let key_selector of key_selectors) {
this.keys[key_selector.id.slice(4)] = key_selector.value;
}
this.movement_keys = {};
- if (!game.map_geometry) {
- return;
+ let geometry_prefix = 'undefinedMapGeometry_';
+ if (game.map_geometry) {
+ geometry_prefix = game.map_geometry.toLowerCase() + '_';
}
- let geometry_prefix = game.map_geometry.toLowerCase() + '_';
for (const key_name of Object.keys(key_descriptions)) {
if (key_name.startsWith(geometry_prefix)) {
let direction = key_name.split('_')[2].toUpperCase();
@@ -629,9 +685,13 @@ let tui = {
}
};
for (const move_button of document.querySelectorAll('[id*="_move_"]')) {
+ if (move_button.id.startsWith('key_')) {
+ continue;
+ }
move_button.hidden = true;
};
for (const move_button of document.querySelectorAll('[id^="' + geometry_prefix + 'move_"]')) {
+ document.getElementById("move_table").hidden = false;
move_button.hidden = false;
};
for (let el of document.getElementsByTagName("button")) {
@@ -640,6 +700,9 @@ let tui = {
el.innerHTML = escapeHTML(action_desc) + '
' + escapeHTML(action_key) + '';
}
},
+ task_action_on: function(action) {
+ return game.tasks.includes(this.action_tasks[action]);
+ },
switch_mode: function(mode_name) {
if (this.mode.name == 'control_tile_draw') {
tui.log_msg('@ finished tile protection drawing.')
@@ -689,25 +752,21 @@ let tui = {
el.disabled = true;
}
document.getElementById("help").disabled = false;
- if (this.mode.name == 'play' || this.mode.name == 'study' || this.mode.name == 'control_tile_draw' || this.mode.name == 'edit' || this.mode.name == 'admin') {
- for (const move_key of document.querySelectorAll('[id*="_move_"]')) {
- move_key.disabled = false;
- }
- }
- if (!this.mode.is_intro && this.mode.name != 'play') {
- document.getElementById("switch_to_play").disabled = false;
- }
- if (!this.mode.is_intro && this.mode.name != 'study') {
- document.getElementById("switch_to_study").disabled = false;
- }
- if (!this.mode.is_intro && this.mode.name != 'chat') {
- document.getElementById("switch_to_chat").disabled = false;
- }
- if (!this.mode.is_intro && this.mode.name != 'edit') {
- document.getElementById("switch_to_edit").disabled = false;
+ for (const action of this.mode.available_actions) {
+ if (["move", "move_explorer"].includes(action)) {
+ for (const move_key of document.querySelectorAll('[id*="_move_"]')) {
+ move_key.disabled = false;
+ }
+ } else if (Object.keys(this.action_tasks).includes(action)) {
+ if (this.task_action_on(action)) {
+ document.getElementById(action).disabled = false;
+ }
+ } else {
+ document.getElementById(action).disabled = false;
+ };
}
- if (!this.mode.is_intro && this.mode.name != 'admin' && this.mode.name != 'admin_enter') {
- document.getElementById("switch_to_admin_enter").disabled = false;
+ for (const mode_name of this.mode.available_modes) {
+ document.getElementById('switch_to_' + mode_name).disabled = false;
}
if (this.mode.name == 'login') {
if (this.login_name) {
@@ -715,34 +774,10 @@ let tui = {
} else {
this.log_msg("? need login name");
}
- } else if (this.mode.name == 'play') {
- if (game.tasks.includes('PICK_UP')) {
- document.getElementById("take_thing").disabled = false;
- }
- if (game.tasks.includes('DROP')) {
- document.getElementById("drop_thing").disabled = false;
- }
- if (game.tasks.includes('MOVE')) {
- }
- document.getElementById("teleport").disabled = false;
- } else if (this.mode.name == 'edit') {
- if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
- document.getElementById("flatten").disabled = false;
- }
- document.getElementById("switch_to_annotate").disabled = false;
- document.getElementById("switch_to_write").disabled = false;
- document.getElementById("switch_to_portal").disabled = false;
- document.getElementById("switch_to_password").disabled = false;
- document.getElementById("switch_to_name_thing").disabled = false;
- document.getElementById("toggle_map_mode").disabled = false;
- } else if (this.mode.name == 'admin') {
- document.getElementById("switch_to_control_pw_type").disabled = false;
- document.getElementById("switch_to_control_tile_type").disabled = false;
- document.getElementById("switch_to_admin_thing_protect").disabled = false;
- } else if (this.mode.name == 'study') {
- document.getElementById("toggle_map_mode").disabled = false;
} else if (this.mode.is_single_char_entry) {
this.show_help = true;
+ } else if (this.mode.name == 'command_thing') {
+ server.send(['TASK:COMMAND', 'HELP']);
} else if (this.mode.name == 'admin_enter') {
this.log_msg('@ enter admin password:')
} else if (this.mode.name == 'control_pw_type') {
@@ -754,7 +789,6 @@ let tui = {
} else if (this.mode.name == 'control_pw_pw') {
this.log_msg('@ enter protection password for "' + this.tile_control_char + '":');
} else if (this.mode.name == 'control_tile_draw') {
- document.getElementById("toggle_tile_draw").disabled = false;
this.log_msg('@ can draw protection character "' + this.tile_control_char + '", turn drawing on/off with [' + this.keys.toggle_tile_draw + '], finish with [' + this.keys.switch_to_admin_enter + '].')
}
this.full_refresh();
@@ -871,85 +905,87 @@ let tui = {
this.full_refresh();
},
draw_map: function() {
- let map_lines_split = [];
- let line = [];
- for (let i = 0, j = 0; i < game.map.length; i++, j++) {
- if (j == game.map_size[1]) {
- map_lines_split.push(line);
- line = [];
- j = 0;
+ if (game.turn_complete) {
+ let map_lines_split = [];
+ let line = [];
+ for (let i = 0, j = 0; i < game.map.length; i++, j++) {
+ if (j == game.map_size[1]) {
+ map_lines_split.push(line);
+ line = [];
+ j = 0;
+ };
+ if (this.map_mode == 'protections') {
+ line.push(game.map_control[i] + ' ');
+ } else {
+ line.push(game.map[i] + ' ');
+ }
};
- if (this.map_mode == 'protections') {
- line.push(game.map_control[i] + ' ');
- } else {
- line.push(game.map[i] + ' ');
- }
- };
- map_lines_split.push(line);
- if (this.map_mode == 'terrain + annotations') {
- for (const coordinate of explorer.info_hints) {
- map_lines_split[coordinate[0]][coordinate[1]] = 'A ';
+ map_lines_split.push(line);
+ if (this.map_mode == 'terrain + annotations') {
+ for (const coordinate of explorer.info_hints) {
+ map_lines_split[coordinate[0]][coordinate[1]] = 'A ';
+ }
+ } else if (this.map_mode == 'terrain + things') {
+ for (const p in game.portals) {
+ let coordinate = p.split(',')
+ let original = map_lines_split[coordinate[0]][coordinate[1]];
+ 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];
+ let symbol = game.thing_types[t.type_];
+ let meta_char = ' ';
+ if (t.thing_char) {
+ meta_char = t.thing_char;
+ }
+ if (used_positions.includes(t.position.toString())) {
+ meta_char = '+';
+ };
+ map_lines_split[t.position[0]][t.position[1]] = symbol + meta_char;
+ used_positions.push(t.position.toString());
+ };
}
- } else if (this.map_mode == 'terrain + things') {
- for (const p in game.portals) {
- let coordinate = p.split(',')
- let original = map_lines_split[coordinate[0]][coordinate[1]];
- map_lines_split[coordinate[0]][coordinate[1]] = original[0] + 'P';
+ let player = game.things[game.player_id];
+ if (tui.mode.shows_info || tui.mode.name == 'control_tile_draw') {
+ map_lines_split[explorer.position[0]][explorer.position[1]] = '??';
+ } else if (tui.map_mode != 'terrain + things') {
+ map_lines_split[player.position[0]][player.position[1]] = '??';
}
- let used_positions = [];
- for (const thing_id in game.things) {
- let t = game.things[thing_id];
- let symbol = game.thing_types[t.type_];
- let meta_char = ' ';
- if (t.player_char) {
- meta_char = t.player_char;
- }
- if (used_positions.includes(t.position.toString())) {
- meta_char = '+';
+ this.map_lines = []
+ if (game.map_geometry == 'Square') {
+ for (let line_split of map_lines_split) {
+ this.map_lines.push(line_split.join(''));
};
- map_lines_split[t.position[0]][t.position[1]] = symbol + meta_char;
- used_positions.push(t.position.toString());
- };
- }
- let player = game.things[game.player_id];
- if (tui.mode.shows_info || tui.mode.name == 'control_tile_draw') {
- map_lines_split[explorer.position[0]][explorer.position[1]] = '??';
- } else if (tui.map_mode != 'terrain + things') {
- map_lines_split[player.position[0]][player.position[1]] = '??';
- }
- let map_lines = []
- if (game.map_geometry == 'Square') {
- for (let line_split of map_lines_split) {
- map_lines.push(line_split.join(''));
- };
- } else if (game.map_geometry == 'Hex') {
- let indent = 0
- for (let line_split of map_lines_split) {
- map_lines.push(' '.repeat(indent) + line_split.join(''));
- if (indent == 0) {
- indent = 1;
- } else {
- indent = 0;
+ } else if (game.map_geometry == 'Hex') {
+ let indent = 0
+ for (let line_split of map_lines_split) {
+ this.map_lines.push(' '.repeat(indent) + line_split.join(''));
+ if (indent == 0) {
+ indent = 1;
+ } else {
+ indent = 0;
+ };
};
+ }
+ let window_center = [terminal.rows / 2, this.window_width / 2];
+ let center_position = [player.position[0], player.position[1]];
+ if (tui.mode.shows_info || tui.mode.name == 'control_tile_draw') {
+ center_position = [explorer.position[0], explorer.position[1]];
+ }
+ center_position[1] = center_position[1] * 2;
+ this.offset = [center_position[0] - window_center[0],
+ center_position[1] - window_center[1]]
+ if (game.map_geometry == 'Hex' && this.offset[0] % 2) {
+ this.offset[1] += 1;
};
- }
- let window_center = [terminal.rows / 2, this.window_width / 2];
- let center_position = [player.position[0], player.position[1]];
- if (tui.mode.shows_info || tui.mode.name == 'control_tile_draw') {
- center_position = [explorer.position[0], explorer.position[1]];
- }
- center_position[1] = center_position[1] * 2;
- let offset = [center_position[0] - window_center[0],
- center_position[1] - window_center[1]]
- if (game.map_geometry == 'Hex' && offset[0] % 2) {
- offset[1] += 1;
};
- let term_y = Math.max(0, -offset[0]);
- let term_x = Math.max(0, -offset[1]);
- let map_y = Math.max(0, offset[0]);
- let map_x = Math.max(0, offset[1]);
+ let term_y = Math.max(0, -this.offset[0]);
+ let term_x = Math.max(0, -this.offset[1]);
+ let map_y = Math.max(0, this.offset[0]);
+ let map_x = Math.max(0, this.offset[1]);
for (; term_y < terminal.rows && map_y < game.map_size[0]; term_y++, map_y++) {
- let to_draw = map_lines[map_y].slice(map_x, this.window_width + offset[1]);
+ let to_draw = this.map_lines[map_y].slice(map_x, this.window_width + this.offset[1]);
terminal.write(term_y, term_x, to_draw);
}
},
@@ -961,7 +997,9 @@ let tui = {
terminal.write(0, this.window_width, 'MODE: ' + this.mode.short_desc + ' â ' + help);
},
draw_turn_line: function(n) {
- terminal.write(1, this.window_width, 'TURN: ' + game.turn);
+ if (game.turn_complete) {
+ terminal.write(1, this.window_width, 'TURN: ' + game.turn);
+ }
},
draw_history: function() {
let log_display_lines = [];
@@ -1017,48 +1055,28 @@ let tui = {
movement_keys_desc = Object.keys(this.movement_keys).join(',');
}
let content = this.mode.short_desc + " help\n\n" + this.mode.help_intro + "\n\n";
- if (this.mode.name == 'play') {
- content += "Available actions:\n";
- if (game.tasks.includes('MOVE')) {
- content += "[" + movement_keys_desc + "] â move player\n";
- }
- if (game.tasks.includes('PICK_UP')) {
- content += "[" + this.keys.take_thing + "] â pick up thing\n";
- }
- if (game.tasks.includes('DROP')) {
- content += "[" + this.keys.drop_thing + "] â drop thing\n";
- }
- content += "[" + tui.keys.teleport + "] â teleport\n";
- content += '\n';
- } else if (this.mode.name == 'study') {
- content += "Available actions:\n";
- content += '[' + movement_keys_desc + '] â move question mark\n';
- content += '[' + this.keys.toggle_map_mode + '] â toggle map view\n';
- content += '\n';
- } else if (this.mode.name == 'edit') {
- content += "Available actions:\n";
- if (game.tasks.includes('MOVE')) {
- content += "[" + movement_keys_desc + "] â move player\n";
- }
- if (game.tasks.includes('FLATTEN_SURROUNDINGS')) {
- content += "[" + tui.keys.flatten + "] â flatten surroundings\n";
- }
- content += '[' + this.keys.toggle_map_mode + '] â toggle map view\n';
- content += '\n';
- } else if (this.mode.name == 'control_tile_draw') {
- content += "Available actions:\n";
- content += "[" + tui.keys.toggle_tile_draw + "] â toggle protection character drawing\n";
- content += '\n';
- } else if (this.mode.name == 'chat') {
+ if (this.mode.name == 'chat') {
content += '/nick NAME â re-name yourself to NAME\n';
content += '/' + this.keys.switch_to_play + ' or /play â switch to play mode\n';
content += '/' + this.keys.switch_to_study + ' or /study â switch to study mode\n';
content += '/' + this.keys.switch_to_edit + ' or /edit â switch to world edit mode\n';
content += '/' + this.keys.switch_to_admin_enter + ' or /admin â switch to admin mode\n';
- } else if (this.mode.name == 'admin') {
+ } else if (this.mode.available_actions.length > 0) {
content += "Available actions:\n";
- if (game.tasks.includes('MOVE')) {
- content += "[" + movement_keys_desc + "] â move player\n";
+ for (let action of this.mode.available_actions) {
+ if (Object.keys(this.action_tasks).includes(action)) {
+ if (!this.task_action_on(action)) {
+ continue;
+ }
+ }
+ if (action == 'move_explorer') {
+ action = 'move';
+ }
+ if (action == 'move') {
+ content += "[" + movement_keys_desc + "] â move\n"
+ } else {
+ content += "[" + this.keys[action] + "] â " + key_descriptions[action] + "\n";
+ }
}
content += '\n';
}
@@ -1099,10 +1117,8 @@ let tui = {
this.draw_history();
this.draw_input();
} else {
- if (game.turn_complete) {
- this.draw_map();
- this.draw_turn_line();
- }
+ this.draw_map();
+ this.draw_turn_line();
this.draw_mode_line();
if (this.mode.shows_info) {
this.draw_info();
@@ -1252,16 +1268,16 @@ let explorer = {
let symbol = game.thing_types[t.type_];
let protection = t.protection;
if (protection == '.') {
- protection = 'unprotected';
+ protection = 'none';
}
- info += "THING: " + t.type_ + " / protection: " + protection + " / " + symbol;
- if (t.player_char) {
- info += t.player_char;
+ info += "THING: " + t.type_ + " / " + symbol;
+ if (t.thing_char) {
+ info += t.thing_char;
};
if (t.name_) {
info += " (" + t.name_ + ")";
}
- info += "\n";
+ info += " / protection: " + protection + "\n";
}
}
if (this.position in game.portals) {
@@ -1322,6 +1338,14 @@ tui.inputEl.addEventListener('keydown', (event) => {
tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
tui.inputEl.value = "";
+ } else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
+ if (tui.inputEl.value.length == 0) {
+ tui.log_msg('@ aborted');
+ tui.switch_mode('play');
+ } else if (tui.task_action_on('command')) {
+ server.send(['TASK:COMMAND', tui.inputEl.value]);
+ tui.inputEl.value = "";
+ }
} else if (tui.mode.name == 'control_pw_pw' && event.key == 'Enter') {
if (tui.inputEl.value.length == 0) {
tui.log_msg('@ aborted');
@@ -1408,14 +1432,15 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (tui.mode.name == 'play') {
if (tui.mode.mode_switch_on_key(event)) {
null;
- } else if (event.key === tui.keys.take_thing
- && game.tasks.includes('PICK_UP')) {
+ } 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
- && game.tasks.includes('DROP')) {
+ } else if (event.key === tui.keys.drop_thing && tui.task_action_on('drop_thing')) {
server.send(["TASK:DROP"]);
- } else if (event.key in tui.movement_keys
- && game.tasks.includes('MOVE')) {
+ } else if (event.key === tui.keys.consume && tui.task_action_on('consume')) {
+ server.send(["TASK:INTOXICATE"]);
+ } else if (event.key === tui.keys.door && tui.task_action_on('door')) {
+ server.send(["TASK:DOOR"]);
+ } 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) {
game.teleport();
@@ -1439,18 +1464,15 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (tui.mode.name == 'admin') {
if (tui.mode.mode_switch_on_key(event)) {
null;
- } else if (event.key in tui.movement_keys
- && game.tasks.includes('MOVE')) {
+ } else if (event.key in tui.movement_keys && tui.task_action_on('move')) {
server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
};
} else if (tui.mode.name == 'edit') {
if (tui.mode.mode_switch_on_key(event)) {
null;
- } else if (event.key in tui.movement_keys
- && game.tasks.includes('MOVE')) {
+ } 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.flatten
- && game.tasks.includes('FLATTEN_SURROUNDINGS')) {
+ } else if (event.key === tui.keys.flatten && tui.task_action_on('flatten')) {
server.send(["TASK:FLATTEN_SURROUNDINGS", tui.password]);
} else if (event.key == tui.keys.toggle_map_mode) {
tui.toggle_map_mode();
@@ -1534,13 +1556,20 @@ document.getElementById("drop_thing").onclick = function() {
document.getElementById("flatten").onclick = function() {
server.send(['TASK:FLATTEN_SURROUNDINGS', tui.password]);
};
+document.getElementById("door").onclick = function() {
+ server.send(['TASK:DOOR']);
+};
+document.getElementById("consume").onclick = function() {
+ server.send(['TASK:INTOXICATE']);
+};
document.getElementById("teleport").onclick = function() {
game.teleport();
};
for (const move_button of document.querySelectorAll('[id*="_move_"]')) {
let direction = move_button.id.split('_')[2].toUpperCase();
move_button.onclick = function() {
- if (tui.mode.name == 'play' || tui.mode.name == 'edit') {
+ if (tui.mode.available_actions.includes("move")
+ || tui.mode.available_actions.includes("move_explorer")) {
server.send(['TASK:MOVE', direction]);
} else {
explorer.move(direction);