+ 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_hat':
+ self.log_msg('legal characters: ' + self.game.players_hat_chars)
+ 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):
+ curses.init_color(1, 1000, 1000, 1000)
+ curses.init_color(2, 0, 0, 0)
+ self.do_refresh = True
+
+ def set_random_colors(self):
+
+ def rand(offset):
+ import random
+ return int(offset + random.random()*375)
+
+ curses.init_color(1, rand(625), rand(625), rand(625))
+ curses.init_color(2, 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 += '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'
+ 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,
+ terrain_desc)
+ protection = self.game.map_control_content[pos_i]
+ if protection == '.':
+ protection = 'unprotected'
+ info_to_cache += 'PROTECTION: %s\n' % protection
+ 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]
+ self.info_cached = info_to_cache
+ return self.info_cached
+
+ def get_thing_info(self, t):
+ info = '%s / %s' %\
+ (t.type_, self.game.thing_types[t.type_])
+ if hasattr(t, 'thing_char'):
+ info += t.thing_char
+ if hasattr(t, 'name'):
+ info += ' (%s)' % t.name
+ if hasattr(t, 'installed'):
+ info += ' / installed'
+ return info