def adjacent_moves(self): moves = [] if dungeon.room_exists(self.x + 1, self.y): moves.append(actions.MoveRight()) if dungeon.room_exists(self.x - 1, self.y): moves.append(actions.MoveLeft()) if dungeon.room_exists(self.x, self.y - 1): moves.append(actions.MoveUp()) if dungeon.room_exists(self.x, self.y + 1): moves.append(actions.MoveDown()) return moves
def play(): dungeon.load_rooms() player = Player() room = dungeon.room_exists(player.location_x, player.location_y) print(room.intro_text()) while player.is_alive() and not player.victory: room = dungeon.room_exists(player.location_x, player.location_y) room.modify_player(player) if player.is_alive() and not player.victory: print("Choose an action:\n") available_actions = room.available_actions() for action in available_actions: print(action) action_input = input("Action: ") for action in available_actions: if action_input == action.hotkey: player.do_action(action, **action.kwargs) break
def move(self, dx, dy): self.location_x += dx self.location_y += dy print(dungeon.room_exists(self.location_x, self.location_y).intro_text())