}
class Mode {
- constructor(name, has_input_prompt=false, shows_annotations=false, is_intro=false) {
+ constructor(name, has_input_prompt=false, shows_info=false, is_intro=false) {
this.name = name;
this.has_input_prompt = has_input_prompt;
- this.shows_annotations = shows_annotations;
+ this.shows_info= shows_info;
this.is_intro = is_intro;
}
}
let mode_study = new Mode('check map tiles for messages', false, true);
let mode_edit = new Mode('write ASCII char to map tile', false, false);
let mode_teleport = new Mode('teleport away?');
+let mode_portal = new Mode('add portal to map tile', true, true);
let tui = {
mode: mode_waiting_for_server,
if (mode == mode_annotate && explorer.position in explorer.info_db) {
let info = explorer.info_db[explorer.position];
if (info != "(none)") {
- this.inputEl.value = explorer.info_db[explorer.position];
+ this.inputEl.value = info;
this.recalc_input_lines();
}
+ }
+ if (mode == mode_portal && explorer.position in game.portals) {
+ let portal = game.portals[explorer.position]
+ this.inputEl.value = portal;
+ this.recalc_input_lines();
} else if (mode == mode_teleport) {
- tui.log_msg("Type Y or y to affirm teleportation, any other key to abort.");
- tui.log_msg("target: " + tui.teleport_target);
+ tui.log_msg("@ May teleport to: " + tui.teleport_target);
+ tui.log_msg("@ Type Y or y to affirm, other keys to abort.");
}
this.full_refresh();
},
center_pos = t;
}
};
- if (tui.mode.shows_annotations) {
+ if (tui.mode.shows_info) {
map_lines[explorer.position[0]][explorer.position[1]] = '?';
center_pos = explorer.position;
}
this.draw_map();
this.draw_turn_line();
this.draw_mode_line();
- if (this.mode.shows_annotations) {
+ if (this.mode.shows_info) {
this.draw_info();
} else {
this.draw_history();
msg = " "; // triggers annotation deletion
}
server.send(["ANNOTATE", unparser.to_yx(explorer.position), msg]);
+ },
+ set_portal: function(msg) {
+ if (msg.length == 0) {
+ msg = " "; // triggers portal deletion
+ }
+ server.send(["PORTAL", unparser.to_yx(explorer.position), msg]);
}
}
if (['Y', 'y'].includes(tui.inputEl.value[0])) {
server.reconnect_to(tui.teleport_target);
} else {
+ tui.log_msg("@ teleportation aborted");
tui.switch_mode(mode_play);
}
}
if (tui.mode == mode_login && event.key == 'Enter') {
server.send(['LOGIN', tui.inputEl.value]);
tui.switch_mode(mode_login);
+ } else if (tui.mode == mode_portal && event.key == 'Enter') {
+ explorer.set_portal(tui.inputEl.value);
+ tui.switch_mode(mode_study, true);
} else if (tui.mode == mode_annotate && event.key == 'Enter') {
explorer.annotate(tui.inputEl.value);
tui.switch_mode(mode_study, true);
tui.switch_mode(mode_chat);
} else if (event.key == 'p') {
tui.switch_mode(mode_play);
+ } else if (event.key === 'P') {
+ event.preventDefault();
+ tui.switch_mode(mode_portal);
} else if (event.key === tui.key_left) {
explorer.move('left');
} else if (event.key === tui.key_right) {