home · contact · privacy
Improve ASCII art input length error message.
[plomrogue2] / rogue_chat.html
index 304346d5abac55cb796dd04f28ccaaebc61a5381..1847c0904ec9f7452efc718fa9265521e0bd7686 100644 (file)
@@ -1213,34 +1213,34 @@ let tui = {
           return;
       }
       const start_x = tui.window_width - 10;
-      let t_char = ' ';
-      if (t.thing_char) {
-          t_char = t.thing_char;
-      }
       function draw_body_part(body_part, end_y) {
-          terminal.write(end_y - 4, start_x, ' _[ @' + t_char + ' ]_ ');
-          terminal.write(end_y - 3, start_x, '|        |');
+          terminal.write(end_y - 3, start_x, '----------');
           terminal.write(end_y - 2, start_x, '| ' + body_part.slice(0, 6) + ' |');
           terminal.write(end_y - 1, start_x, '| ' + body_part.slice(6, 12) + ' |');
           terminal.write(end_y, start_x, '| ' + body_part.slice(12, 18) + ' |');
       }
       if (t.face) {
-          draw_body_part(t.face, terminal.rows - 2);
+          draw_body_part(t.face, terminal.rows - 3);
       }
       if (t.hat) {
-          draw_body_part(t.hat, terminal.rows - 5);
+          draw_body_part(t.hat, terminal.rows - 6);
+      }
+      terminal.write(terminal.rows - 2, start_x, '----------');
+      let name = t.name_;
+      if (name.length > 6) {
+          name = name.slice(0, 6) + '…';
       }
-      terminal.write(terminal.rows - 1, start_x, '|        |');
+      terminal.write(terminal.rows - 1, start_x, '@' + t.thing_char + ':' + name);
   },
   draw_mode_line: function() {
       let help = 'hit [' + this.keys.help + '] for help';
       if (this.mode.has_input_prompt) {
           help = 'enter /help for help';
       }
-      terminal.write(0, this.window_width, 'MODE: ' + this.mode.short_desc + ' – ' + help);
+      terminal.write(1, this.window_width, 'MODE: ' + this.mode.short_desc + ' – ' + help);
   },
   draw_stats_line: function(n) {
-      terminal.write(1, this.window_width,
+      terminal.write(0, this.window_width,
                      'ENERGY: ' + game.energy +
                      ' BLADDER: ' + game.bladder_pressure);
   },
@@ -1500,37 +1500,7 @@ let explorer = {
             for (let t_id in game.things) {
                  let t = game.things[t_id];
                  if (t.position[0] == this.position[0] && t.position[1] == this.position[1]) {
-                     info_to_cache += "THING: " + this.get_thing_info(t);
-                     let protection = t.protection;
-                     if (protection == '.') {
-                         protection = 'none';
-                     }
-                     info_to_cache += " / protection: " + protection + "\n";
-                     if (t.hat) {
-                         info_to_cache += t.hat.slice(0, 6) + '\n';
-                         info_to_cache += t.hat.slice(6, 12) + '\n';
-                         info_to_cache += t.hat.slice(12, 18) + '\n';
-                     }
-                     if (t.face) {
-                         info_to_cache += t.face.slice(0, 6) + '\n';
-                         info_to_cache += t.face.slice(6, 12) + '\n';
-                         info_to_cache += t.face.slice(12, 18) + '\n';
-                     }
-                     if (t.design) {
-                         const line_length = t.design[0][1];
-                         if (t.type_ == 'Sign') {
-                             info_to_cache += '-'.repeat(line_length + 4) + '\n';
-                         }
-                         const regexp = RegExp('.{1,' + line_length + '}', 'g');
-                         const lines = t.design[1].match(regexp);
-                         console.log(lines);
-                         for (const line of lines) {
-                             info_to_cache += '| ' + line + ' |\n';
-                         }
-                         if (t.type_ == 'Sign') {
-                             info_to_cache += '-'.repeat(line_length + 4) + '\n';
-                         }
-                     }
+                     info_to_cache += this.get_thing_info(t, true);
                  }
             }
             let terrain_char = game.map[position_i]
@@ -1538,12 +1508,12 @@ let explorer = {
             if (game.terrains[terrain_char]) {
                 terrain_desc = game.terrains[terrain_char];
             };
-            info_to_cache += 'TERRAIN: "' + terrain_char + '" / ' + terrain_desc + "\n";
+            info_to_cache += 'TERRAIN: "' + terrain_char + '" (' + terrain_desc;
             let protection = game.map_control[position_i];
-            if (protection == '.') {
-                protection = 'unprotected';
+            if (protection != '.') {
+                info_to_cache += '/protection:' + protection;
             };
-            info_to_cache += 'PROTECTION: ' + protection + '\n';
+            info_to_cache += ')\n';
             if (this.position in game.portals) {
                 info_to_cache += "PORTAL: " + game.portals[this.position] + "\n";
             }
@@ -1554,17 +1524,61 @@ let explorer = {
         this.info_cached = info_to_cache;
         return this.info_cached;
     },
-    get_thing_info: function(t) {
-        const symbol = game.thing_types[t.type_];
-        let info = t.type_ + " / " + symbol;
+    get_thing_info: function(t, detailed=false) {
+        let info = '';
+        if (detailed) {
+            info += '- ';
+        }
+        info += game.thing_types[t.type_];
         if (t.thing_char) {
             info += t.thing_char;
         };
         if (t.name_) {
-            info += " (" + t.name_ + ")";
+            info += ": " + t.name_;
         }
+        info += ' (' + t.type_;
         if (t.installed) {
-            info += " / installed";
+            info += "/installed";
+        }
+        if (t.type_ == 'Bottle') {
+            if (t.thing_char == '_') {
+                info += '/empty';
+            } else if (t.thing_char == '~') {
+                info += '/full';
+            }
+        }
+        if (detailed) {
+            const protection = t.protection;
+            if (protection != '.') {
+                info += '/protection:' + protection;
+            }
+            info += ')\n';
+            if (t.hat || t.face) {
+                info += '----------\n';
+            }
+            if (t.hat) {
+                info += '| ' + t.hat.slice(0, 6) + ' |\n';
+                info += '| ' + t.hat.slice(6, 12) + ' |\n';
+                info += '| ' + t.hat.slice(12, 18) + ' |\n';
+            }
+            if (t.face) {
+                info += '| ' + t.face.slice(0, 6) + ' |\n';
+                info += '| ' + t.face.slice(6, 12) + ' |\n';
+                info += '| ' + t.face.slice(12, 18) + ' |\n';
+                info += '----------\n';
+            }
+            if (t.design) {
+                const line_length = t.design[0][1];
+                info += '-'.repeat(line_length + 4) + '\n';
+                const regexp = RegExp('.{1,' + line_length + '}', 'g');
+                const lines = t.design[1].match(regexp);
+                for (const line of lines) {
+                    info += '| ' + line + ' |\n';
+                }
+                info += '-'.repeat(line_length + 4) + '\n';
+            }
+        } else {
+            info += ')';
         }
         return info;
     },