home · contact · privacy
Refactor parser code.
[plomrogue2] / rogue_chat.html
index 9f02d8dc790675dd29a7047ff8fae2d53d8ffdec..d6a86e096dbada3c123e0c953981ea99b737b34a 100644 (file)
@@ -465,6 +465,7 @@ let server = {
         this.websocket.onopen = function(event) {
             game.thing_types = {};
             game.terrains = {};
+            tui.is_admin = false;
             server.send(['TASKS']);
             server.send(['TERRAINS']);
             server.send(['THING_TYPES']);
@@ -577,8 +578,6 @@ let server = {
             this.send(['GET_GAMESTATE']);
             tui.switch_mode('post_login_wait');
             tui.log_msg('@ welcome!')
-            tui.log_msg('@ hint: see top of terminal for how to get help.')
-            tui.log_msg('@ hint: enter study mode to understand your environment.')
         } else if (tokens[0] === 'DEFAULT_COLORS') {
             terminal.set_default_colors();
         } else if (tokens[0] === 'RANDOM_COLORS') {
@@ -816,6 +815,8 @@ let tui = {
     }
     this.draw_face = false;
     this.tile_draw = false;
+    this.ascii_draw_stage = 0;
+    this.full_ascii_draw = '';
     if (mode_name == 'command_thing' && (!game.player.carrying
                                          || !game.player.carrying.commandable)) {
         return fail('not carrying anything commandable');
@@ -1237,6 +1238,40 @@ let tui = {
         terminal.write(term_y, term_x, to_draw);
     }
   },
+  draw_names: function() {
+      let players = [];
+      for (const thing_id in game.things) {
+           let t = game.things[thing_id];
+           if (t.type_ == 'Player') {
+               players.push(t);
+           }
+      };
+      function compare(a, b) {
+          if (a.name_.length > b.name_.length) {
+              return -1;
+          } else if (a.name_.length < b.name_.length) {
+              return 1;
+          } else {
+              return 0;
+          }
+      }
+      players.sort(compare);
+      const shrink_offset = Math.max(0, (terminal.rows - tui.left_window_width / 2) / 2);
+      let y = 0;
+      for (const player of players) {
+          let name = player.name_;
+          const offset_y = y - shrink_offset;
+          const max_len = Math.max(5, (tui.left_window_width / 2) - (offset_y * 2) - 8);
+          if (name.length > max_len) {
+              name = name.slice(0, max_len - 1) + '…';
+          }
+          terminal.write(y, 0, '@' + player.thing_char + ':' + name);
+          y += 1;
+          if (y >= terminal.rows) {
+              break;
+          }
+      }
+  },
   draw_face_popup: function() {
       const t = game.things[this.draw_face];
       if (!t || !t.face) {
@@ -1258,7 +1293,7 @@ let tui = {
       }
       terminal.write(terminal.rows - 2, start_x, '----------');
       let name = t.name_;
-      if (name.length > 6) {
+      if (name.length > 7) {
           name = name.slice(0, 6) + '…';
       }
       terminal.write(terminal.rows - 1, start_x, '@' + t.thing_char + ':' + name);
@@ -1406,8 +1441,11 @@ let tui = {
     if (this.show_help) {
         this.draw_help();
     }
-    if (this.draw_face && ['chat', 'play'].includes(this.mode.name)) {
-        this.draw_face_popup();
+    if (['chat', 'play'].includes(this.mode.name)) {
+        this.draw_names();
+        if (this.draw_face) {
+            this.draw_face_popup();
+        }
     }
     if (!this.draw_links) {
         this.links = {};