- draw_mode_line: function() {
- terminal.drawBox(1, this.window_width, this.height_mode_line, this.window_width);
- terminal.write(1, this.window_width, 'MODE ' + this.mode.name);
- },
- draw_history: function() {
- if (terminal.rows <= this.height_header + this.height_input) {
- return;
- }
- terminal.drawBox(this.height_header, this.window_width, terminal.rows - this.height_header - this.height_input, this.window_width);
- for (let y = terminal.rows - 1 - this.height_input,
- i = this.log.length - 1;
- y >= this.height_header && i >= 0;
- y--, i--) {
- terminal.write(y, this.window_width, this.log[i]);
- }
- },
- draw_map: function() {
- terminal.drawBox(0, 0, terminal.rows, this.window_width);
- let map_lines = [];
- let line = [];
- for (let i = 0, j = 0; i < game.map.length; i++, j++) {
- if (j == game.map_size[1]) {
- map_lines.push(line);
- line = [];
- j = 0;
- };
- line.push(game.map[i]);
- };
- map_lines.push(line);
- let player_position = [0,0];
- let center_pos = [Math.floor(game.map_size[0] / 2),
- Math.floor(game.map_size[1] / 2)];
- for (const thing_id in game.things) {
- let t = game.things[thing_id];
- map_lines[t[0]][t[1]] = '@';
- if (game.player_id == thing_id) {
- center_pos = t;
- }
- };
- if (tui.mode.shows_annotations) {
- map_lines[explorer.position[0]][explorer.position[1]] = '?';
- center_pos = explorer.position;
- }
- let offset = [(terminal.rows / 2) - center_pos[0],
- this.window_width / 2 - center_pos[1]];
- for (let term_y = offset[0], map_y = 0;
- term_y < terminal.rows && map_y < game.map_size[0];
- term_y++, map_y++) {
- if (term_y >= 0) {
- let to_draw = map_lines[map_y].join('').slice(0, this.window_width - offset[1]);
- terminal.write(term_y, offset[1], to_draw);
- }
- }
- },
- draw_turn_line: function(n) {
- terminal.drawBox(0, this.window_width, 1, this.window_width);
- terminal.write(0, this.window_width, 'turn: ' + game.turn);
- },