this.log_msg(i + ': ' + direction);
};
} else if (this.mode.name == 'enter_design') {
- this.log_msg('@ The design you enter must be '
- + game.player.carrying.design[0][0] + ' lines of max '
- + game.player.carrying.design[0][1] + ' characters width each');
if (game.player.carrying.type_ == 'Hat') {
+ this.log_msg('@ The design you enter must be '
+ + game.player.carrying.design[0][0] + ' lines of max '
+ + game.player.carrying.design[0][1] + ' characters width each');
this.log_msg('@ Legal characters: ' + game.players_hat_chars);
this.log_msg('@ (Eat cookies to extend the ASCII characters available for drawing.)');
+ } else {
+ this.log_msg('@ Width of first line determines maximum width for remaining design')
+ this.log_msg('@ Finish design by entering an empty line (multiple space characters do not count as empty)')
}
} else if (this.mode.name == 'command_thing') {
server.send(['TASK:COMMAND', 'HELP']);
this.inputEl.value = "";
this.switch_mode('play');
},
- enter_ascii_art: function(command, height, width, with_pw=false) {
- if (this.inputEl.value.length > width) {
- this.log_msg('? wrong input length, must be max ' + width + '; try again');
- return;
- } else if (this.inputEl.value.length < width) {
- while (this.inputEl.value.length < width) {
- this.inputEl.value += ' ';
- }
- }
- this.log_msg(' ' + this.inputEl.value);
- this.full_ascii_draw += this.inputEl.value;
- this.ascii_draw_stage += 1;
- if (this.ascii_draw_stage < height) {
- this.restore_input_values();
- } else {
- if (with_pw) {
- server.send([command, this.full_ascii_draw, this.password]);
- } else {
- server.send([command, this.full_ascii_draw]);
- }
- this.full_ascii_draw = '';
- this.ascii_draw_stage = 0;
- this.inputEl.value = '';
- this.switch_mode('edit');
- }
+ enter_ascii_art: function(command, height, width, with_pw=false, with_size=false) {
+ if (with_size && this.ascii_draw_stage == 0) {
+ width = this.inputEl.value.length;
+ if (width > 36) {
+ this.log_msg('? wrong input length, must be max 36; try again');
+ return;
+ }
+ if (width != game.player.carrying.design[0][1]) {
+ game.player.carrying.design[1] = '';
+ game.player.carrying.design[0][1] = width;
+ }
+ } else if (this.inputEl.value.length > width) {
+ this.log_msg('? wrong input length, must be max ' + width + '; try again');
+ return;
+ }
+ this.log_msg(' ' + this.inputEl.value);
+ if (with_size && ['', ' '].includes(this.inputEl.value) && this.ascii_draw_stage > 0) {
+ height = this.ascii_draw_stage;
+ } else {
+ if (with_size) {
+ height = this.ascii_draw_stage + 2;
+ }
+ while (this.inputEl.value.length < width) {
+ this.inputEl.value += ' ';
+ }
+ this.full_ascii_draw += this.inputEl.value;
+ }
+ if (with_size) {
+ game.player.carrying.design[0][0] = height;
+ }
+ this.ascii_draw_stage += 1;
+ if (this.ascii_draw_stage < height) {
+ this.restore_input_values();
+ } else {
+ if (with_pw && with_size) {
+ server.send([command + '_SIZE',
+ unparser.to_yx(game.player.carrying.design[0]),
+ this.password]);
+ }
+ if (with_pw) {
+ server.send([command, this.full_ascii_draw, this.password]);
+ } else {
+ server.send([command, this.full_ascii_draw]);
+ }
+ this.full_ascii_draw = '';
+ this.ascii_draw_stage = 0;
+ this.inputEl.value = '';
+ this.switch_mode('edit');
+ }
},
draw_map: function() {
if (!game.turn_complete && this.map_lines.length == 0) {
return;
}
const start_x = tui.window_width - 10;
- let t_char = ' ';
- if (t.thing_char) {
- t_char = t.thing_char;
- }
function draw_body_part(body_part, end_y) {
- terminal.write(end_y - 4, start_x, ' _[ @' + t_char + ' ]_ ');
- terminal.write(end_y - 3, start_x, '| |');
+ terminal.write(end_y - 3, start_x, '----------');
terminal.write(end_y - 2, start_x, '| ' + body_part.slice(0, 6) + ' |');
terminal.write(end_y - 1, start_x, '| ' + body_part.slice(6, 12) + ' |');
terminal.write(end_y, start_x, '| ' + body_part.slice(12, 18) + ' |');
}
if (t.face) {
- draw_body_part(t.face, terminal.rows - 2);
+ draw_body_part(t.face, terminal.rows - 3);
}
if (t.hat) {
- draw_body_part(t.hat, terminal.rows - 5);
+ draw_body_part(t.hat, terminal.rows - 6);
}
- terminal.write(terminal.rows - 1, start_x, '| |');
+ terminal.write(terminal.rows - 2, start_x, '----------');
+ let name = t.name_;
+ if (name.length > 6) {
+ name = name.slice(0, 6) + '…';
+ }
+ terminal.write(terminal.rows - 1, start_x, '@' + t.thing_char + ':' + name);
},
draw_mode_line: function() {
let help = 'hit [' + this.keys.help + '] for help';
for (let t_id in game.things) {
let t = game.things[t_id];
if (t.position[0] == this.position[0] && t.position[1] == this.position[1]) {
- info_to_cache += this.get_thing_info(t);
+ info_to_cache += this.get_thing_info(t, true);
}
}
let terrain_char = game.map[position_i]
this.info_cached = info_to_cache;
return this.info_cached;
},
- get_thing_info: function(t) {
- const symbol = game.thing_types[t.type_];
- let info = '- ' + symbol;
+ get_thing_info: function(t, detailed=false) {
+ let info = '';
+ if (detailed) {
+ info += '- ';
+ }
+ info += game.thing_types[t.type_];
if (t.thing_char) {
info += t.thing_char;
};
if (t.installed) {
info += "/installed";
}
- const protection = t.protection;
- if (protection != '.') {
- info += '/protection:' + protection;
- }
- info += ')\n';
- if (t.hat || t.face) {
- info += '----------\n';
- }
- if (t.hat) {
- info += '| ' + t.hat.slice(0, 6) + ' |\n';
- info += '| ' + t.hat.slice(6, 12) + ' |\n';
- info += '| ' + t.hat.slice(12, 18) + ' |\n';
- }
- if (t.face) {
- info += '| ' + t.face.slice(0, 6) + ' |\n';
- info += '| ' + t.face.slice(6, 12) + ' |\n';
- info += '| ' + t.face.slice(12, 18) + ' |\n';
- info += '----------\n';
+ if (t.type_ == 'Bottle') {
+ if (t.thing_char == '_') {
+ info += '/empty';
+ } else if (t.thing_char == '~') {
+ info += '/full';
+ }
}
- if (t.design) {
- const line_length = t.design[0][1];
- info += '-'.repeat(line_length + 4) + '\n';
- const regexp = RegExp('.{1,' + line_length + '}', 'g');
- const lines = t.design[1].match(regexp);
- for (const line of lines) {
- info += '| ' + line + ' |\n';
+ if (detailed) {
+ const protection = t.protection;
+ if (protection != '.') {
+ info += '/protection:' + protection;
}
- info += '-'.repeat(line_length + 4) + '\n';
+ info += ')\n';
+ if (t.hat || t.face) {
+ info += '----------\n';
+ }
+ if (t.hat) {
+ info += '| ' + t.hat.slice(0, 6) + ' |\n';
+ info += '| ' + t.hat.slice(6, 12) + ' |\n';
+ info += '| ' + t.hat.slice(12, 18) + ' |\n';
+ }
+ if (t.face) {
+ info += '| ' + t.face.slice(0, 6) + ' |\n';
+ info += '| ' + t.face.slice(6, 12) + ' |\n';
+ info += '| ' + t.face.slice(12, 18) + ' |\n';
+ info += '----------\n';
+ }
+ if (t.design) {
+ const line_length = t.design[0][1];
+ info += '-'.repeat(line_length + 4) + '\n';
+ console.log(line_length)
+ let lines = ['']
+ if (line_length > 0) {
+ const regexp = RegExp('.{1,' + line_length + '}', 'g');
+ lines = t.design[1].match(regexp);
+ }
+ for (const line of lines) {
+ info += '| ' + line + ' |\n';
+ }
+ info += '-'.repeat(line_length + 4) + '\n';
+ }
+ } else {
+ info += ')';
}
return info;
},
} else if (tui.mode.name == 'enter_face' && event.key == 'Enter') {
tui.enter_ascii_art('PLAYER_FACE', 3, 6);
} else if (tui.mode.name == 'enter_design' && event.key == 'Enter') {
- tui.enter_ascii_art('THING_DESIGN',
- game.player.carrying.design[0][0],
- game.player.carrying.design[0][1], true);
+ if (game.player.carrying.type_ == 'Hat') {
+ tui.enter_ascii_art('THING_DESIGN',
+ game.player.carrying.design[0][0],
+ game.player.carrying.design[0][1], true);
+ } else {
+ tui.enter_ascii_art('THING_DESIGN',
+ game.player.carrying.design[0][0],
+ game.player.carrying.design[0][1], true, true);
+ }
} else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
server.send(['TASK:COMMAND', tui.inputEl.value]);
tui.inputEl.value = "";