X-Git-Url: https://plomlompom.com/repos/condition_titles?a=blobdiff_plain;f=rogue_chat.html;h=ffed950bfe65738cfe5d29468eb93de0fa244fec;hb=94f399dbee74479669095c3f79548ebae4a4cd80;hp=49fdda0bc8480e7ef0bd2577d63dd6effa031625;hpb=b03c50a4922dfd0017712958b8a317a7bd612c54;p=plomrogue2
diff --git a/rogue_chat.html b/rogue_chat.html
index 49fdda0..ffed950 100644
--- a/rogue_chat.html
+++ b/rogue_chat.html
@@ -63,6 +63,7 @@ keyboard input/control:
+
@@ -71,6 +72,7 @@ keyboard input/control:
+
|
@@ -98,13 +100,15 @@ keyboard input/control:
+
+
-toggle map view:
+toggle map view:
toggle protection character drawing:
@@ -122,8 +126,16 @@ let mode_helps = {
'short': 'study',
'long': 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it. Toggle the map view to show or hide different information layers.'},
'edit': {
- 'short': 'map edit',
- 'long': 'This mode allows you to change the map in various ways. Individual map tiles are shown together with their "protection characters". You can edit a tile if you set the map edit password that matches its protection character. The character "." marks the absence of protection: Such tiles can always be edited.'
+ 'short': 'world edit',
+ 'long': 'This mode allows you to change the game world in various ways. Individual map tiles can be protected by "protection characters", which you can see by toggling into the protections map view. You can edit a tile if you set the map edit password that matches its protection character. The character "." marks the absence of protection: Such tiles can always be edited.'
+ },
+ 'name_thing': {
+ 'short': 'name thing',
+ 'long': 'Give name to/change name of thing here.'
+ },
+ 'admin_thing_protect': {
+ 'short': 'change thing protection',
+ 'long': 'Change protection character for thing here.'
},
'write': {
'short': 'change terrain',
@@ -253,7 +265,7 @@ let terminal = {
let start_x = 0;
for (let span of tui.links[y]) {
chunks.push(escapeHTML(line.slice(start_x, span[0])));
- chunks.push('');
chunks.push(escapeHTML(line.slice(span[0], span[1])));
@@ -380,9 +392,10 @@ let server = {
game.portals = {};
game.turn = parseInt(tokens[1]);
} else if (tokens[0] === 'THING') {
- let t = game.get_thing(tokens[3], true);
+ let t = game.get_thing(tokens[4], true);
t.position = parser.parse_yx(tokens[1]);
t.type_ = tokens[2];
+ t.protection = tokens[3];
} else if (tokens[0] === 'THING_NAME') {
let t = game.get_thing(tokens[1], false);
if (t) {
@@ -437,7 +450,6 @@ let server = {
} else if (tokens[0] === 'ANNOTATION') {
let position = parser.parse_yx(tokens[1]);
explorer.update_info_db(position, tokens[2]);
- tui.restore_input_values();
tui.full_refresh();
} else if (tokens[0] === 'UNHANDLED_INPUT') {
tui.log_msg('? unknown command');
@@ -549,8 +561,10 @@ let tui = {
mode_write: new Mode('write', false, false, false, true),
mode_edit: new Mode('edit'),
mode_control_pw_type: new Mode('control_pw_type', true),
+ mode_admin_thing_protect: new Mode('admin_thing_protect', true),
mode_portal: new Mode('portal', true, true),
mode_password: new Mode('password', true),
+ mode_name_thing: new Mode('name_thing', true, true),
mode_admin_enter: new Mode('admin_enter', true),
mode_admin: new Mode('admin'),
mode_control_pw_pw: new Mode('control_pw_pw', true),
@@ -559,11 +573,11 @@ let tui = {
init: function() {
this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter"]
this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
- this.mode_admin.available_modes = ["control_pw_type",
+ this.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
"control_tile_type", "chat",
"study", "play", "edit"]
this.mode_control_tile_draw.available_modes = ["admin_enter"]
- this.mode_edit.available_modes = ["write", "annotate", "portal",
+ this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing",
"password", "chat", "study", "play",
"admin_enter"]
this.mode = this.mode_waiting_for_server;
@@ -613,12 +627,36 @@ let tui = {
if (this.mode.name == 'control_tile_draw') {
tui.log_msg('@ finished tile protection drawing.')
}
- this.map_mode = 'terrain + things';
this.tile_draw = false;
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]) {
+ thing_id = t_id;
+ break;
+ }
+ }
+ if (!thing_id) {
+ terminal.blink_screen();
+ this.log_msg('? not standing over thing');
+ return;
+ } else {
+ this.selected_thing_id = thing_id;
+ }
};
this.mode = this['mode_' + mode_name];
+ if (["control_tile_draw", "control_tile_type", "control_pw_type"].includes(this.mode.name)) {
+ this.map_mode = 'protections';
+ } else if (this.mode.name != "edit") {
+ this.map_mode = 'terrain + things';
+ };
if (this.mode.has_input_prompt || this.mode.is_single_char_entry) {
this.inputEl.focus();
}
@@ -628,13 +666,13 @@ let tui = {
explorer.query_info();
}
}
- this.empty_input();
+ this.inputEl.value = "";
this.restore_input_values();
for (let el of document.getElementsByTagName("button")) {
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') {
+ 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;
}
@@ -678,9 +716,12 @@ let tui = {
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) {
@@ -691,6 +732,8 @@ let tui = {
this.log_msg('@ enter tile protection character for which you want to change the password:')
} else if (this.mode.name == 'control_tile_type') {
this.log_msg('@ enter tile protection character which you want to draw:')
+ } else if (this.mode.name == 'admin_thing_protect') {
+ this.log_msg('@ enter thing protection character:')
} else if (this.mode.name == 'control_pw_pw') {
this.log_msg('@ enter tile protection password for "' + this.tile_control_char + '":');
} else if (this.mode.name == 'control_tile_draw') {
@@ -716,28 +759,31 @@ let tui = {
let info = explorer.info_db[explorer.position];
if (info != "(none)") {
this.inputEl.value = info;
- this.recalc_input_lines();
}
} else if (this.mode.name == 'portal' && explorer.position in game.portals) {
let portal = game.portals[explorer.position]
this.inputEl.value = portal;
- this.recalc_input_lines();
} else if (this.mode.name == 'password') {
this.inputEl.value = this.password;
- this.recalc_input_lines();
+ } else if (this.mode.name == 'name_thing') {
+ let t = game.get_thing(this.selected_thing_id);
+ if (t && t.name_) {
+ this.inputEl.value = t.name_;
+ }
+ } else if (this.mode.name == 'admin_thing_protect') {
+ let t = game.get_thing(this.selected_thing_id);
+ if (t && t.protection) {
+ this.inputEl.value = t.protection;
+ }
}
},
- empty_input: function(str) {
- this.inputEl.value = "";
+ recalc_input_lines: function() {
if (this.mode.has_input_prompt) {
- this.recalc_input_lines();
+ let _ = null;
+ [this.input_lines, _] = this.msg_into_lines_of_width(this.input_prompt + this.inputEl.value, this.window_width);
} else {
- this.height_input = 0;
+ this.input_lines = [];
}
- },
- recalc_input_lines: function() {
- let _ = null;
- [this.input_lines, _] = this.msg_into_lines_of_width(this.input_prompt + this.inputEl.value, this.window_width);
this.height_input = this.input_lines.length;
},
msg_into_lines_of_width: function(msg, width) {
@@ -811,9 +857,8 @@ let tui = {
line = [];
j = 0;
};
- if (['edit', 'write', 'control_tile_draw',
- 'control_tile_type'].includes(this.mode.name)) {
- line.push(game.map[i] + game.map_control[i]);
+ if (this.map_mode == 'protections') {
+ line.push(game.map_control[i] + ' ');
} else {
line.push(game.map[i] + ' ');
}
@@ -844,8 +889,11 @@ let tui = {
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') {
@@ -864,9 +912,8 @@ let tui = {
};
}
let window_center = [terminal.rows / 2, this.window_width / 2];
- let player = game.things[game.player_id];
let center_position = [player.position[0], player.position[1]];
- if (tui.mode.shows_info) {
+ 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;
@@ -974,6 +1021,7 @@ let tui = {
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";
@@ -985,6 +1033,12 @@ let tui = {
content += '/' + this.keys.switch_to_study + ' or /study â switch to study mode\n';
content += '/' + this.keys.switch_to_edit + ' or /edit â switch to map edit mode\n';
content += '/' + this.keys.switch_to_admin_enter + ' or /admin â switch to admin mode\n';
+ } else if (this.mode.name == 'admin') {
+ content += "Available actions:\n";
+ if (game.tasks.includes('MOVE')) {
+ content += "[" + movement_keys_desc + "] â move player\n";
+ }
+ content += '\n';
}
content += this.mode.list_available_modes();
let start_x = 0;
@@ -1009,13 +1063,16 @@ let tui = {
tui.map_mode = 'terrain + annotations';
} else if (tui.map_mode == 'terrain + annotations') {
tui.map_mode = 'terrain + things';
- } else {
+ } else if (tui.map_mode == 'terrain + things') {
+ tui.map_mode = 'protections';
+ } else if (tui.map_mode == 'protections') {
tui.map_mode = 'terrain only';
}
},
full_refresh: function() {
this.links = {};
terminal.drawBox(0, 0, terminal.rows, terminal.cols);
+ this.recalc_input_lines();
if (this.mode.is_intro) {
this.draw_history();
this.draw_input();
@@ -1171,7 +1228,11 @@ let explorer = {
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 += "THING: " + t.type_ + " / " + symbol;
+ let protection = t.protection;
+ if (protection == '.') {
+ protection = 'unprotected';
+ }
+ info += "THING: " + t.type_ + " / protection: " + protection + " / " + symbol;
if (t.player_char) {
info += t.player_char;
};
@@ -1214,7 +1275,6 @@ tui.inputEl.addEventListener('input', (event) => {
if (tui.inputEl.value.length > max_length) {
tui.inputEl.value = tui.inputEl.value.slice(0, max_length);
};
- tui.recalc_input_lines();
} else if (tui.mode.name == 'write' && tui.inputEl.value.length > 0) {
server.send(["TASK:WRITE", tui.inputEl.value[0], tui.password]);
tui.switch_mode('edit');
@@ -1231,7 +1291,7 @@ tui.inputEl.addEventListener('keydown', (event) => {
}
if (tui.mode.has_input_prompt && event.key == 'Enter' && tui.inputEl.value == '/help') {
tui.show_help = true;
- tui.empty_input();
+ tui.inputEl.value = "";
tui.restore_input_values();
} else if (!tui.mode.has_input_prompt && event.key == tui.keys.help
&& !tui.mode.is_single_char_entry) {
@@ -1239,7 +1299,7 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (tui.mode.name == 'login' && event.key == 'Enter') {
tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
- tui.empty_input();
+ tui.inputEl.value = "";
} else if (tui.mode.name == 'control_pw_pw' && event.key == 'Enter') {
if (tui.inputEl.value.length == 0) {
tui.log_msg('@ aborted');
@@ -1252,6 +1312,13 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (tui.mode.name == 'portal' && event.key == 'Enter') {
explorer.set_portal(tui.inputEl.value);
tui.switch_mode('edit');
+ } else if (tui.mode.name == 'name_thing' && event.key == 'Enter') {
+ if (tui.inputEl.value.length == 0) {
+ tui.inputEl.value = " ";
+ }
+ server.send(["THING_NAME", tui.selected_thing_id, tui.inputEl.value,
+ tui.password]);
+ tui.switch_mode('edit');
} else if (tui.mode.name == 'annotate' && event.key == 'Enter') {
explorer.annotate(tui.inputEl.value);
tui.switch_mode('edit');
@@ -1280,6 +1347,14 @@ tui.inputEl.addEventListener('keydown', (event) => {
tui.tile_control_char = tui.inputEl.value[0];
tui.switch_mode('control_tile_draw');
}
+ } else if (tui.mode.name == 'admin_thing_protect' && event.key == 'Enter') {
+ if (tui.inputEl.value.length != 1) {
+ tui.log_msg('@ entered non-single-char, therefore aborted');
+ } else {
+ server.send(['THING_PROTECTION', tui.selected_thing_id, tui.inputEl.value])
+ tui.log_msg('@ sent new protection character for thing');
+ }
+ tui.switch_mode('admin');
} else if (tui.mode.name == 'chat' && event.key == 'Enter') {
let tokens = parser.tokenize(tui.inputEl.value);
if (tokens.length > 0 && tokens[0].length > 0) {
@@ -1307,7 +1382,7 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (tui.inputEl.valuelength > 0) {
server.send(['ALL', tui.inputEl.value]);
}
- tui.empty_input();
+ tui.inputEl.value = "";
} else if (tui.mode.name == 'play') {
if (tui.mode.mode_switch_on_key(event)) {
null;
@@ -1342,6 +1417,9 @@ 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')) {
+ server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
};
} else if (tui.mode.name == 'edit') {
if (tui.mode.mode_switch_on_key(event)) {
@@ -1352,6 +1430,8 @@ tui.inputEl.addEventListener('keydown', (event) => {
} else if (event.key === tui.keys.flatten
&& game.tasks.includes('FLATTEN_SURROUNDINGS')) {
server.send(["TASK:FLATTEN_SURROUNDINGS", tui.password]);
+ } else if (event.key == tui.keys.toggle_map_mode) {
+ tui.toggle_map_mode();
}
}
tui.full_refresh();