let quoted = ['"'];
for (let i = 0; i < str.length; i++) {
let c = str[i];
- if (c in ['"', '\\']) {
+ if (['"', '\\'].includes(c)) {
quoted.push('\\');
};
quoted.push(c);
return lines;
},
log_msg: function(msg) {
- let lines = this.msg_into_lines_of_width(msg, this.window_width);
- this.log = this.log.concat(lines);
- while (this.log.length > terminal.rows) {
+ this.log.push(msg);
+ while (this.log.length > terminal.rows * 4) {
this.log.shift();
};
this.full_refresh();
terminal.write(1, this.window_width, 'TURN: ' + game.turn);
},
draw_history: function() {
- if (terminal.rows <= this.height_header + this.height_input) {
- return;
- }
+ let log_display_lines = [];
+ for (let line of this.log) {
+ log_display_lines = log_display_lines.concat(this.msg_into_lines_of_width(line, this.window_width));
+ };
for (let y = terminal.rows - 1 - this.height_input,
- i = this.log.length - 1;
+ i = log_display_lines.length - 1;
y >= this.height_header && i >= 0;
y--, i--) {
- terminal.write(y, this.window_width, this.log[i]);
+ terminal.write(y, this.window_width, log_display_lines[i]);
}
},
draw_info: function() {
tui.log_msg('# ' + tokens[1], 1);
} else if (tokens[0] === 'PLAYER_ID') {
game.player_id = parseInt(tokens[1]);
- } else if (tokens[0] === 'META') {
- tui.log_msg('@ ' + tokens[1]);
} else if (tokens[0] === 'LOGIN_OK') {
server.send(['GET_GAMESTATE']);
- tui.log_msg('@ ' + tokens[1]);
tui.log_help();
- tui.switch_mode(mode_chat);
+ tui.switch_mode(mode_play);
} else if (tokens[0] === 'ANNOTATION') {
let position = parser.parse_yx(tokens[1]);
explorer.update_info_db(position, tokens[2]);