- 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');
+ }