+ elif self.mode.name == 'take_thing':
+ self.log_msg('Portable things in reach for pick-up:')
+ directed_moves = {
+ 'HERE': YX(0, 0), 'LEFT': YX(0, -1), 'RIGHT': YX(0, 1)
+ }
+ if type(self.game.map_geometry) == MapGeometrySquare:
+ directed_moves['UP'] = YX(-1, 0)
+ directed_moves['DOWN'] = YX(1, 0)
+ elif type(self.game.map_geometry) == MapGeometryHex:
+ if self.game.player.position.y % 2:
+ directed_moves['UPLEFT'] = YX(-1, 0)
+ directed_moves['UPRIGHT'] = YX(-1, 1)
+ directed_moves['DOWNLEFT'] = YX(1, 0)
+ directed_moves['DOWNRIGHT'] = YX(1, 1)
+ else:
+ directed_moves['UPLEFT'] = YX(-1, -1)
+ directed_moves['UPRIGHT'] = YX(-1, 0)
+ directed_moves['DOWNLEFT'] = YX(1, -1)
+ directed_moves['DOWNRIGHT'] = YX(1, 0)
+ select_range = {}
+ for direction in directed_moves:
+ move = directed_moves[direction]
+ select_range[direction] = self.game.player.position + move
+ self.selectables = []
+ directions = []
+ for direction in select_range:
+ for t in [t for t in self.game.things
+ if t.portable and t.position == select_range[direction]]:
+ self.selectables += [t.id_]
+ directions += [direction]
+ if len(self.selectables) == 0:
+ return fail('nothing to pick-up')
+ else:
+ for i in range(len(self.selectables)):
+ t = self.game.get_thing(self.selectables[i])
+ self.log_msg('%s %s: %s' % (i, directions[i],
+ self.get_thing_info(t)))
+ elif self.mode.name == 'drop_thing':
+ self.log_msg('Direction to drop thing to:')
+ self.selectables =\
+ ['HERE'] + list(self.game.tui.movement_keys.values())
+ for i in range(len(self.selectables)):
+ self.log_msg(str(i) + ': ' + self.selectables[i])
+ elif self.mode.name == 'enter_design':
+ if self.game.player.carrying.type_ == 'Hat':
+ self.log_msg('@ The design you enter must be %s lines of max %s '
+ 'characters width each'
+ % (self.game.player.carrying.design[0].y,
+ self.game.player.carrying.design[0].x))
+ self.log_msg('@ Legal characters: ' + self.game.players_hat_chars)
+ self.log_msg('@ (Eat cookies to extend the ASCII characters available for drawing.)')
+ else:
+ self.log_msg('@ Width of first line determines maximum width for remaining design')
+ self.log_msg('@ Finish design by entering an empty line (multiple space characters do not count as empty)')
+ elif self.mode.name == 'command_thing':
+ self.send('TASK:COMMAND ' + quote('HELP'))
+ elif self.mode.name == 'control_pw_pw':
+ self.log_msg('@ enter protection password for "%s":' % self.tile_control_char)
+ elif self.mode.name == 'control_tile_draw':
+ self.log_msg('@ can draw protection character "%s", turn drawing on/off with [%s], finish with [%s].' % (self.tile_control_char, self.keys['toggle_tile_draw'], self.keys['switch_to_admin_enter']))
+ self.input_ = ""
+ self.restore_input_values()
+
+ def set_default_colors(self):
+ if curses.can_change_color():
+ curses.init_color(7, 1000, 1000, 1000)
+ curses.init_color(0, 0, 0, 0)
+ self.do_refresh = True
+
+ def set_random_colors(self):
+
+ def rand(offset):
+ import random
+ return int(offset + random.random()*375)
+
+ if curses.can_change_color():
+ curses.init_color(7, rand(625), rand(625), rand(625))
+ curses.init_color(0, rand(0), rand(0), rand(0))
+ self.do_refresh = True
+
+ def get_info(self):
+ if self.info_cached:
+ return self.info_cached
+ pos_i = self.explorer.y * self.game.map_geometry.size.x + self.explorer.x
+ info_to_cache = ''
+ if len(self.game.fov) > pos_i and self.game.fov[pos_i] != '.':
+ info_to_cache += 'outside field of view'
+ else:
+ for t in self.game.things:
+ if t.position == self.explorer:
+ 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:
+ terrain_desc = self.game.terrains[terrain_char]
+ info_to_cache += 'TERRAIN: %s (%s' % (terrain_char,
+ terrain_desc)
+ protection = self.game.map_control_content[pos_i]
+ 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'
+ if self.explorer in self.game.annotations:
+ info_to_cache += 'ANNOTATION: ' +\
+ self.game.annotations[self.explorer]
+ self.info_cached = info_to_cache
+ return self.info_cached
+
+ 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.name
+ info += ' (%s' % t.type_
+ if hasattr(t, 'installed'):
+ info += '/installed'
+ 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