+ this.log.push(msg);
+ while (this.log.length > 100) {
+ this.log.shift();
+ };
+ this.full_refresh();
+ },
+ log_help: function() {
+ let movement_keys_desc = Object.keys(this.movement_keys).join(',');
+ this.log_msg("HELP:");
+ this.log_msg("chat mode commands:");
+ this.log_msg(" /nick NAME - re-name yourself to NAME");
+ this.log_msg(" /msg USER TEXT - send TEXT to USER");
+ this.log_msg(" /help - show this help");
+ this.log_msg(" /" + this.keys.switch_to_play + " or /play - switch to play mode");
+ this.log_msg(" /" + this.keys.switch_to_study + " or /study - switch to study mode");
+ this.log_msg("commands common to study and play mode:");
+ this.log_msg(" " + movement_keys_desc + " - move");
+ this.log_msg(" " + this.keys.switch_to_chat + " - switch to chat mode");
+ this.log_msg("commands specific to play mode:");
+ this.log_msg(" " + this.keys.switch_to_edit + " - write following ASCII character");
+ this.log_msg(" " + this.keys.flatten + " - flatten surroundings");
+ this.log_msg(" " + this.keys.switch_to_study + " - switch to study mode");
+ this.log_msg("commands specific to study mode:");
+ this.log_msg(" " + this.keys.switch_to_annotate + " - annotate terrain");
+ this.log_msg(" " + this.keys.switch_to_play + " - switch to play mode");
+ },
+ 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;
+ };
+ line.push(game.map[i]);
+ };
+ map_lines_split.push(line);
+ for (const thing_id in game.things) {
+ let t = game.things[thing_id];
+ map_lines_split[t.position[0]][t.position[1]] = '@';
+ };
+ if (tui.mode.shows_info) {
+ map_lines_split[explorer.position[0]][explorer.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;
+ };
+ };
+ }
+ 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) {
+ 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;