def run_frame(dun_map, position):
    """
    :param dun_map: map for game
    :type dun_map: list[list[]]

    :param position: position of plauer on the map
    :type position: list[x, y]

    :return: game state from dungeon_logic.GAME_STATE
    :rtype: str
    """

    print('\n')
    command = ''
    while command not in dungeon_logic.COMMANDS:
        command = input("Type valid input \n")

        if command == 'save':
            dungeon_serializer.serialize_dungeon_game(dun_map, position)

        elif command == 'load':
            data = dungeon_serializer.deserialize_dungeon_game()
            dun_map = data[0]
            position = data[1]

    game_state = dungeon_logic.make_move(dun_map, position, len(dun_map),
                                         command)

    return game_state
Example #2
0
    def run_game(self):
        """
        :description: run game frame
        """

        while self.player.hit_points > 0 and self.player.treasure_picked < 3:

            self.player.get_command()

            if self.player.command in dun_map.COMMANDS:

                self.dun_map.process_move(self.player)
                self.dun_map.print_map()

            elif self.player.command in dun_player.MENU_COMMANDS:

                if self.player.command == 'save':

                    game = Game()
                    game.player = self.player
                    game.dun_map = self.dun_map
                    dungeon_serializer.serialize_dungeon_game(game)
                else:

                    game = dungeon_serializer.deserialize_dungeon_game()
                    self.player = game.player
                    self.dun_game = game.dun_map

        if self.player.hit_points == 0:
            dungeon_logger.logger.info('You LOST')
        elif self.player.treasure_picked == 3:
            dungeon_logger.logger.info('You WON')
Example #3
0
    def run_game(self):
        """
        :description: run game frame
        """

        while self.player.hit_points > 0 and self.player.treasure_picked < 3:

            self.player.get_command()

            if self.player.command in dun_player.COMMANDS:

                try:
                    self.player.process_move(self.dun_map)
                except (dungeon_exception.CommandError,
                        dungeon_exception.MapCageError) as error:
                    dungeon_logger.logger.info(
                        f'Invalid Player command: {error}')

                self.dun_map.print_map()

            elif self.player.command in dun_player.MENU_COMMANDS:

                if self.player.command == 'save':

                    game = Game()
                    game.player = self.player
                    game.dun_map = self.dun_map
                    dungeon_serializer.serialize_dungeon_game(game)
                else:

                    game = dungeon_serializer.deserialize_dungeon_game()
                    self.player = game.player
                    self.dun_game = game.dun_map

        self.closing = True
        if self.player.hit_points == 0:
            dungeon_logger.logger.info('You LOST')
        elif self.player.treasure_picked == 3:
            dungeon_logger.logger.info('You WON')