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 += this.get_thing_info(t);
+ info_to_cache += this.get_thing_info(t, true);
}
}
let terrain_char = game.map[position_i]
this.info_cached = info_to_cache;
return this.info_cached;
},
- get_thing_info: function(t) {
- const symbol = game.thing_types[t.type_];
- let info = '- ' + 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.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';
+ if (detailed) {
+ const protection = t.protection;
+ if (protection != '.') {
+ info += '/protection:' + protection;
}
- info += '-'.repeat(line_length + 4) + '\n';
+ 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;
},
else:
for t in self.game.things:
if t.position == self.explorer:
- info_to_cache += '%s' % self.get_thing_info(t)
+ info_to_cache += '%s' % self.get_thing_info(t, True)
terrain_char = self.game.map_content[pos_i]
terrain_desc = '?'
if terrain_char in self.game.terrains:
self.info_cached = info_to_cache
return self.info_cached
- def get_thing_info(self, t):
- info = '- %s' % self.game.thing_types[t.type_]
+ def get_thing_info(self, t, detailed=False):
+ info = ''
+ if detailed:
+ info += '- '
+ info += self.game.thing_types[t.type_]
if hasattr(t, 'thing_char'):
info += t.thing_char
if hasattr(t, 'name'):
info += ' (%s' % t.type_
if hasattr(t, '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'
+ if t.type_ == 'Bottle':
+ if t.thing_char == '_':
+ info += '/empty'
+ elif t.thing_char == '~':
+ info += '/full'
+ if detailed:
+ 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'
+ else:
+ info += ')'
return info
def loop(self, stdscr):