X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new2%2Frogue_chat_nocanvas_monochrome.html;h=583b2dc76becec857bc2fd7252b13415d6742ace;hb=a151d4cbc512d8075c6e49c0feb9cfcf63421f04;hp=578e971912e29ad52991b76d627afdd93da18eaa;hpb=9506b64fe6040ba2489d84ecf852c6e2ad7fef65;p=plomrogue2-experiments diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index 578e971..583b2dc 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -243,10 +243,10 @@ let unparser = { } class Mode { - constructor(name, has_input_prompt=false, shows_annotations=false, is_intro=false) { + constructor(name, has_input_prompt=false, shows_info=false, is_intro=false) { this.name = name; this.has_input_prompt = has_input_prompt; - this.shows_annotations = shows_annotations; + this.shows_info= shows_info; this.is_intro = is_intro; } } @@ -258,6 +258,7 @@ let mode_play = new Mode('play / move around', false, false); let mode_study = new Mode('check map tiles for messages', false, true); let mode_edit = new Mode('write ASCII char to map tile', false, false); let mode_teleport = new Mode('teleport away?'); +let mode_portal = new Mode('add portal to map tile', true, true); let tui = { mode: mode_waiting_for_server, @@ -303,12 +304,17 @@ let tui = { if (mode == mode_annotate && explorer.position in explorer.info_db) { let info = explorer.info_db[explorer.position]; if (info != "(none)") { - this.inputEl.value = explorer.info_db[explorer.position]; + this.inputEl.value = info; this.recalc_input_lines(); } + } + if (mode == mode_portal && explorer.position in game.portals) { + let portal = game.portals[explorer.position] + this.inputEl.value = portal; + this.recalc_input_lines(); } else if (mode == mode_teleport) { - tui.log_msg("Type Y or y to affirm teleportation, any other key to abort."); - tui.log_msg("target: " + tui.teleport_target); + tui.log_msg("@ May teleport to: " + tui.teleport_target); + tui.log_msg("@ Type Y or y to affirm, other keys to abort."); } this.full_refresh(); }, @@ -387,7 +393,7 @@ let tui = { center_pos = t; } }; - if (tui.mode.shows_annotations) { + if (tui.mode.shows_info) { map_lines[explorer.position[0]][explorer.position[1]] = '?'; center_pos = explorer.position; } @@ -442,7 +448,7 @@ let tui = { this.draw_map(); this.draw_turn_line(); this.draw_mode_line(); - if (this.mode.shows_annotations) { + if (this.mode.shows_info) { this.draw_info(); } else { this.draw_history(); @@ -526,6 +532,12 @@ let explorer = { msg = " "; // triggers annotation deletion } server.send(["ANNOTATE", unparser.to_yx(explorer.position), msg]); + }, + set_portal: function(msg) { + if (msg.length == 0) { + msg = " "; // triggers portal deletion + } + server.send(["PORTAL", unparser.to_yx(explorer.position), msg]); } } @@ -544,6 +556,7 @@ tui.inputEl.addEventListener('input', (event) => { if (['Y', 'y'].includes(tui.inputEl.value[0])) { server.reconnect_to(tui.teleport_target); } else { + tui.log_msg("@ teleportation aborted"); tui.switch_mode(mode_play); } } @@ -555,6 +568,9 @@ tui.inputEl.addEventListener('keydown', (event) => { if (tui.mode == mode_login && event.key == 'Enter') { server.send(['LOGIN', tui.inputEl.value]); tui.switch_mode(mode_login); + } else if (tui.mode == mode_portal && event.key == 'Enter') { + explorer.set_portal(tui.inputEl.value); + tui.switch_mode(mode_study, true); } else if (tui.mode == mode_annotate && event.key == 'Enter') { explorer.annotate(tui.inputEl.value); tui.switch_mode(mode_study, true); @@ -625,6 +641,9 @@ tui.inputEl.addEventListener('keydown', (event) => { tui.switch_mode(mode_chat); } else if (event.key == 'p') { tui.switch_mode(mode_play); + } else if (event.key === 'P') { + event.preventDefault(); + tui.switch_mode(mode_portal); } else if (event.key === tui.key_left) { explorer.move('left'); } else if (event.key === tui.key_right) {