home · contact · privacy
Minor client improvements.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 4 Nov 2020 04:36:29 +0000 (05:36 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 4 Nov 2020 04:36:29 +0000 (05:36 +0100)
new2/rogue_chat_curses.py
new2/rogue_chat_nocanvas_monochrome.html

index 6f27256a728e3a8f56db9c5d171173ff03e14036..e272fb2efb2cc53ef5796d8fa2064ee268565518 100755 (executable)
@@ -330,15 +330,32 @@ class TUI:
                     self.input_ = self.input_[:max_length]
             elif self.mode == self.mode_login and key == '\n':
                 self.socket.send('LOGIN ' + quote(self.input_))
+                self.input_ = ""
             elif self.mode == self.mode_chat and key == '\n':
                 # TODO: query, nick, help, reconnect, unknown command
-                if self.input_ == ':p':
-                    self.switch_mode('play')
-                elif self.input_ == ':?':
-                    self.switch_mode('study')
+                if self.input_[0] == ':':
+                    if self.input_ in {':p', ':play'}:
+                        self.switch_mode('play')
+                    elif self.input_ in {':?', ':study'}:
+                        self.switch_mode('study')
+                    elif self.input_.startswith(':nick'):
+                        tokens = self.input_.split(maxsplit=1)
+                        if len(tokens) == 2:
+                            self.socket.send('LOGIN ' + quote(tokens[1]))
+                        else:
+                            self.log_msg('? need login name')
+                    elif self.input_.startswith(':msg'):
+                        tokens = self.input_.split(maxsplit=2)
+                        if len(tokens) == 3:
+                            self.socket.send('QUERY %s %s' % (quote(tokens[1]),
+                                                              quote(tokens[2])))
+                        else:
+                            self.log_msg('? need message target and message')
+                    else:
+                        self.log_msg('? unknown command')
                 else:
                     self.socket.send('ALL ' + quote(self.input_))
-                    self.input_ = ""
+                self.input_ = ""
             elif self.mode == self.mode_annotate and key == '\n':
                 if (self.input_ == ''):
                     self.input_ = ' '
index bb1ecdaeedb13de65bb93ff2b2bf9dd950bf40f9..f513ad9f39a311fa86dc56d369ca4fa33536abd0 100644 (file)
@@ -201,6 +201,7 @@ let server = {
         } else if (tokens[0] === 'LOGIN_OK') {
             this.send(['GET_GAMESTATE']);
             tui.log_help();
+            // TODO wait for game state for this switch, use intermediary mode?
             tui.switch_mode(mode_play);
         } else if (tokens[0] === 'PORTAL') {
             let position = parser.parse_yx(tokens[1]);
@@ -591,7 +592,7 @@ tui.inputEl.addEventListener('input', (event) => {
 }, false);
 tui.inputEl.addEventListener('keydown', (event) => {
     if (event.key == 'Enter') {
-       event.preventDefault();
+        event.preventDefault();
     }
     if (tui.mode == mode_login && event.key == 'Enter') {
         server.send(['LOGIN', tui.inputEl.value]);