+ mode: mode_waiting_for_server,
+ log: [],
+ input_prompt: '> ',
+ input_lines: [],
+ window_width: terminal.cols / 2,
+ height_turn_line: 1,
+ height_mode_line: 1,
+ height_input: 1,
+ init: function() {
+ this.inputEl = document.getElementById("input");
+ this.inputEl.focus();
+ this.recalc_input_lines();
+ this.height_header = this.height_turn_line + this.height_mode_line;
+ this.log_msg("@ waiting for server connection ...");
+ this.init_keys();
+ },
+ init_keys: function() {
+ this.keys = {
+ switch_to_chat: key_switch_to_chat_selector.value,
+ switch_to_play: key_switch_to_play_selector.value,
+ switch_to_annotate: key_switch_to_annotate_selector.value,
+ switch_to_portal: key_switch_to_portal_selector.value,
+ switch_to_study: key_switch_to_study_selector.value,
+ switch_to_edit: key_switch_to_edit_selector.value,
+ flatten: key_flatten_selector.value,
+ hex_move_upleft: key_hex_move_upleft_selector.value,
+ hex_move_upright: key_hex_move_upright_selector.value,
+ hex_move_right: key_hex_move_right_selector.value,
+ hex_move_downright: key_hex_move_downright_selector.value,
+ hex_move_downleft: key_hex_move_downleft_selector.value,
+ hex_move_left: key_hex_move_left_selector.value,
+ square_move_up: key_square_move_up_selector.value,
+ square_move_left: key_square_move_left_selector.value,
+ square_move_down: key_square_move_down_selector.value,
+ square_move_right: key_square_move_right_selector.value,
+ }
+ if (game.map_geometry == 'Square') {
+ this.movement_keys = {
+ [this.keys.square_move_up]: 'UP',
+ [this.keys.square_move_left]: 'LEFT',
+ [this.keys.square_move_down]: 'DOWN',
+ [this.keys.square_move_right]: 'RIGHT'
+ };
+ } else if (game.map_geometry == 'Hex') {
+ this.movement_keys = {
+ [this.keys.hex_move_upleft]: 'UPLEFT',
+ [this.keys.hex_move_upright]: 'UPRIGHT',
+ [this.keys.hex_move_right]: 'RIGHT',
+ [this.keys.hex_move_downright]: 'DOWNRIGHT',
+ [this.keys.hex_move_downleft]: 'DOWNLEFT',
+ [this.keys.hex_move_left]: 'LEFT'
+ };
+ };
+ },
+ switch_mode: function(mode, keep_pos=false) {
+ if (mode == mode_study && !keep_pos && game.player_id in game.things) {
+ explorer.position = game.things[game.player_id].position;
+ }
+ this.mode = mode;
+ this.empty_input();
+ if (mode == mode_annotate && explorer.position in explorer.info_db) {
+ let info = explorer.info_db[explorer.position];
+ if (info != "(none)") {
+ this.inputEl.value = info;
+ this.recalc_input_lines();
+ }
+ }
+ if (mode == mode_login) {
+ if (this.login_name) {
+ server.send(['LOGIN', this.login_name]);
+ } else {
+ this.log_msg("? need login name");
+ }
+ } else 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("@ May teleport to: " + tui.teleport_target);
+ tui.log_msg("@ Enter 'YES!' to entusiastically affirm.");