From: Christian Heller Date: Sat, 19 Dec 2020 03:19:40 +0000 (+0100) Subject: Re-style study detail view. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance?a=commitdiff_plain;h=fb52d96afadba85295054b18eec101b2665c1278;p=plomrogue2 Re-style study detail view. --- diff --git a/rogue_chat.html b/rogue_chat.html index d644d62..f9a6a01 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -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); } } 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"; } @@ -1556,15 +1526,45 @@ let explorer = { }, get_thing_info: function(t) { const symbol = game.thing_types[t.type_]; - let info = t.type_ + " / " + symbol; + let info = '- ' + symbol; 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"; + } + 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'; } return info; }, diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 7ae6f67..d91c517 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -827,49 +827,20 @@ class TUI: else: for t in self.game.things: if t.position == self.explorer: - info_to_cache += 'THING: %s' % self.get_thing_info(t) - protection = t.protection - if protection == '.': - protection = 'none' - info_to_cache += ' / protection: %s\n' % protection - if hasattr(t, 'hat'): - info_to_cache += t.hat[0:6] + '\n' - info_to_cache += t.hat[6:12] + '\n' - info_to_cache += t.hat[12:18] + '\n' - if hasattr(t, 'face'): - info_to_cache += t.face[0:6] + '\n' - info_to_cache += t.face[6:12] + '\n' - info_to_cache += t.face[12:18] + '\n' - if hasattr(t, 'design'): - line_length = t.design[0].x - lines = [] - for i in range(t.design[0].y): - start = i * line_length - end = (i + 1) * line_length - lines += [t.design[1][start:end]] - if t.type_ == 'Sign': - info_to_cache += '-' * (line_length + 4) + '\n' - for line in lines: - info_to_cache += '| %s |\n' % line - info_to_cache += '-' * (line_length + 4) + '\n' - else: - for line in lines: - info_to_cache += '%s\n' % line + info_to_cache += '%s' % self.get_thing_info(t) terrain_char = self.game.map_content[pos_i] terrain_desc = '?' if terrain_char in self.game.terrains: terrain_desc = self.game.terrains[terrain_char] - info_to_cache += 'TERRAIN: "%s" / %s\n' % (terrain_char, + info_to_cache += 'TERRAIN: %s (%s' % (terrain_char, terrain_desc) protection = self.game.map_control_content[pos_i] - if protection == '.': - protection = 'unprotected' - info_to_cache += 'PROTECTION: %s\n' % protection + if protection != '.': + info_to_cache += '/protection:%s' % protection + info_to_cache += ')\n' if self.explorer in self.game.portals: info_to_cache += 'PORTAL: ' +\ self.game.portals[self.explorer] + '\n' - else: - info_to_cache += 'PORTAL: (none)\n' if self.explorer in self.game.annotations: info_to_cache += 'ANNOTATION: ' +\ self.game.annotations[self.explorer] @@ -877,14 +848,40 @@ class TUI: return self.info_cached def get_thing_info(self, t): - info = '%s / %s' %\ - (t.type_, self.game.thing_types[t.type_]) + info = '- %s' % self.game.thing_types[t.type_] if hasattr(t, 'thing_char'): info += t.thing_char if hasattr(t, 'name'): - info += ' (%s)' % t.name + info += ': %s' % t.name + info += ' (%s' % t.type_ if hasattr(t, 'installed'): - info += ' / installed' + info += '/installed' + protection = t.protection + if protection != '.': + info += '/protection:%s' % protection + info += ')\n' + if hasattr(t, 'hat') or hasattr(t, 'face'): + info += '----------\n' + if hasattr(t, 'hat'): + info += '| %s |\n' % t.hat[0:6] + info += '| %s |\n' % t.hat[6:12] + info += '| %s |\n' % t.hat[12:18] + if hasattr(t, 'face'): + info += '| %s |\n' % t.face[0:6] + info += '| %s |\n' % t.face[6:12] + info += '| %s |\n' % t.face[12:18] + info += '----------\n' + if hasattr(t, 'design'): + line_length = t.design[0].x + lines = [] + for i in range(t.design[0].y): + start = i * line_length + end = (i + 1) * line_length + lines += [t.design[1][start:end]] + info += '-' * (line_length + 4) + '\n' + for line in lines: + info += '| %s |\n' % line + info += '-' * (line_length + 4) + '\n' return info def loop(self, stdscr):