X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=rogue_chat_curses.py;h=ff559246fe1cbdf22aec2879a41ecf3b7ab3777a;hb=9f83e41901f23e282737e7344c84e8a692d05ef0;hp=c26c3805a0ec092c6e4ff8affead14a222c7127f;hpb=feb0ffb7c7523ddee0cbd685cbc9c2e768a56cbd;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index c26c380..ff55924 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -256,14 +256,14 @@ def cmd_MAP(game, geometry, size, content): map_geometry_class = globals()['MapGeometry' + geometry] game.map_geometry_new = map_geometry_class(size) game.map_content_new = content - if type(game.map_geometry) == MapGeometrySquare: + if type(game.map_geometry_new) == MapGeometrySquare: game.tui.movement_keys = { game.tui.keys['square_move_up']: 'UP', game.tui.keys['square_move_left']: 'LEFT', game.tui.keys['square_move_down']: 'DOWN', game.tui.keys['square_move_right']: 'RIGHT', } - elif type(game.map_geometry) == MapGeometryHex: + elif type(game.map_geometry_new) == MapGeometryHex: game.tui.movement_keys = { game.tui.keys['hex_move_upleft']: 'UPLEFT', game.tui.keys['hex_move_upright']: 'UPRIGHT', @@ -724,26 +724,41 @@ class TUI: self.log_msg('@ enter username') elif self.mode.name == 'take_thing': self.log_msg('Portable things in reach for pick-up:') - select_range = [self.game.player.position, - self.game.player.position + YX(0,-1), - self.game.player.position + YX(0, 1), - self.game.player.position + YX(-1, 0), - self.game.player.position + YX(1, 0)] - if type(self.game.map_geometry) == MapGeometryHex: + 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: - select_range += [self.game.player.position + YX(-1, 1), - self.game.player.position + YX(1, 1)] + 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: - select_range += [self.game.player.position + YX(-1, -1), - self.game.player.position + YX(1, -1)] - self.selectables = [t.id_ for t in self.game.things - if t.portable and t.position in select_range] + 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(str(i) + ': ' + self.get_thing_info(t)) + 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 =\