X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=rogue_chat.html;h=653a7034e672d3b2d96e262c146d9b1d2d679e3f;hb=b5440b01de1253e7741d2d48f56557f269943263;hp=26322e94a31c3e797a07924704bfb4e3963e983c;hpb=0ae5c165fbce33fcdc60f92cceb18109124aabde;p=plomrogue2 diff --git a/rogue_chat.html b/rogue_chat.html index 26322e9..653a703 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -173,7 +173,7 @@ let mode_helps = { 'enter_face': { 'short': 'enter your face', 'intro': '@ enter face line (enter nothing to abort):', - 'long': 'Draw your face as ASCII art. The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom..' + 'long': 'Draw your face as ASCII art. The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom. Eat cookies to extend the ASCII characters available for drawing.' }, 'enter_hat': { 'short': 'enter your hat', @@ -718,6 +718,8 @@ let tui = { }, offset: [0,0], map_lines: [], + ascii_draw_stage: 0, + full_ascii_draw: '', selectables: [], draw_face: false, init: function() { @@ -911,6 +913,8 @@ let tui = { for (let [i, direction] of this.selectables.entries()) { this.log_msg(i + ': ' + direction); }; + } else if (this.mode.name == 'enter_hat') { + this.log_msg('legal characters: ' + game.players_hat_chars); } else if (this.mode.name == 'command_thing') { server.send(['TASK:COMMAND', 'HELP']); } else if (this.mode.name == 'control_pw_pw') { @@ -953,6 +957,14 @@ let tui = { if (t && t.protection) { this.inputEl.value = t.protection; } + } else if (['enter_face', 'enter_hat'].includes(this.mode.name)) { + const start = this.ascii_draw_stage * 6; + const end = (this.ascii_draw_stage + 1) * 6; + if (this.mode.name == 'enter_face') { + this.inputEl.value = game.player.face.slice(start, end); + } else if (this.mode.name == 'enter_hat') { + this.inputEl.value = game.player.hat.slice(start, end); + } } }, recalc_input_lines: function() { @@ -1041,6 +1053,24 @@ let tui = { this.inputEl.value = ""; this.switch_mode('play'); }, + enter_ascii_art: function(command) { + if (this.inputEl.value.length != 6) { + this.log_msg('? wrong input length, try again'); + return; + } + this.log_msg(' ' + this.inputEl.value); + this.full_ascii_draw += this.inputEl.value; + this.ascii_draw_stage += 1; + if (this.ascii_draw_stage < 3) { + this.restore_input_values(); + } 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; @@ -1548,21 +1578,9 @@ tui.inputEl.addEventListener('keydown', (event) => { server.send(['LOGIN', tui.inputEl.value]); tui.inputEl.value = ""; } else if (tui.mode.name == 'enter_face' && event.key == 'Enter') { - if (tui.inputEl.value.length != 18) { - tui.log_msg('? wrong input length, aborting'); - } else { - server.send(['PLAYER_FACE', tui.inputEl.value]); - } - tui.inputEl.value = ""; - tui.switch_mode('edit'); + tui.enter_ascii_art('PLAYER_FACE'); } else if (tui.mode.name == 'enter_hat' && event.key == 'Enter') { - if (tui.inputEl.value.length != 18) { - tui.log_msg('? wrong input length, aborting'); - } else { - server.send(['PLAYER_HAT', tui.inputEl.value]); - } - tui.inputEl.value = ""; - tui.switch_mode('edit'); + tui.enter_ascii_art('PLAYER_HAT'); } else if (tui.mode.name == 'command_thing' && event.key == 'Enter') { server.send(['TASK:COMMAND', tui.inputEl.value]); tui.inputEl.value = "";