X-Git-Url: https://plomlompom.com/repos/unset_cookie?a=blobdiff_plain;f=rogue_chat.html;h=1b62a81ad77c63aa1fc8b3f37697aab52c8f3759;hb=f519c96298473525a7bb006e9ef7efa34cb43a46;hp=9740fff34c7b251509d4e7b40d341fdf98282481;hpb=52b01fc00d6ea2c053f9022981498b97ebd05839;p=plomrogue2 diff --git a/rogue_chat.html b/rogue_chat.html index 9740fff..1b62a81 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -19,7 +19,7 @@ terminal rows:
@@ -454,7 +454,6 @@ let server = { this.url = url; this.websocket = new WebSocket(this.url); this.websocket.onopen = function(event) { - server.connected = true; game.thing_types = {}; game.terrains = {}; server.send(['TASKS']); @@ -464,7 +463,6 @@ let server = { tui.switch_mode('login'); }; this.websocket.onclose = function(event) { - server.connected = false; tui.switch_mode('waiting_for_server'); tui.log_msg("@ server disconnected :("); }; @@ -1472,11 +1470,12 @@ tui.inputEl.addEventListener('keydown', (event) => { if (event.key == 'Enter') { event.preventDefault(); } - if (tui.mode.has_input_prompt && event.key == 'Enter' - && tui.inputEl.value.length == 0 - && ['chat', 'command_thing', 'take_thing', 'drop_thing', - 'admin_enter'].includes(tui.mode.name)) { - if (tui.mode.name != 'chat') { + if ((!tui.mode.is_intro && event.key == 'Escape') + || (tui.mode.has_input_prompt && event.key == 'Enter' + && tui.inputEl.value.length == 0 + && ['chat', 'command_thing', 'take_thing', 'drop_thing', + 'admin_enter'].includes(tui.mode.name))) { + if (!['chat', 'play', 'study', 'edit'].includes(tui.mode.name)) { tui.log_msg('@ aborted'); } tui.switch_mode('play'); @@ -1659,13 +1658,13 @@ for (let key_selector of key_selectors) { }, false); } window.setInterval(function() { - if (server.connected) { + if (server.websocket.readyState == 1) { server.send(['PING']); } else { server.reconnect_to(server.url); tui.log_msg('@ attempting reconnect â¦') } -}, 5000); +}, 1000); window.setInterval(function() { let val = "?"; let span_decoration = "none"; |