コード例 #1
0
    def start() -> int:
        """Starts the process of completing a generic setup that supports the 'Play Again' logic.

        Returns:
            (int): Number of runs completed.
        """
        from bot.game import Game

        runs_completed = 0

        MessageLog.print_message(
            f"\n[GENERIC] Now checking for run eligibility...")

        # Bot can start either at the Combat screen with the "Attack" button visible or the Loot Collection screen with the "Play Again" button visible.
        if ImageUtils.find_button("attack", tries=5):
            MessageLog.print_message(
                f"[GENERIC] Bot is at the Combat screen. Starting Combat Mode now..."
            )
            if CombatMode.start_combat_mode():
                runs_completed = Game.collect_loot(is_completed=True)
        else:
            MessageLog.print_message(
                f"[GENERIC] Bot is not at the Combat screen. Checking for the Loot Collection screen now..."
            )

            # Press the "Play Again" button if necessary, otherwise start Combat Mode.
            if Game.find_and_click_button("play_again"):
                Game.check_for_popups()
            else:
                raise GenericException(
                    "Failed to detect the 'Play Again' button. Bot can start either at the Combat screen with the 'Attack' button visible or the Loot Collection screen with the 'Play Again' button visible.."
                )

            # Check for AP.
            Game.check_for_ap()

            # Check if the bot is at the Summon Selection screen.
            if ImageUtils.confirm_location("select_a_summon", tries=30):
                summon_check = Game.select_summon(Settings.summon_list,
                                                  Settings.summon_element_list)
                if summon_check:
                    # Do not select party and just commence the mission.
                    MessageLog.print_message(
                        f"[GENERIC] Skipping party selection and immediately commencing mission..."
                    )
                    if Game.find_and_click_button("ok", tries=10):
                        # Now start Combat Mode and detect any item drops.
                        if CombatMode.start_combat_mode():
                            runs_completed = Game.collect_loot(
                                is_completed=True)
                    else:
                        raise GenericException(
                            "Failed to skip party selection.")
            else:
                raise GenericException(
                    "Failed to arrive at the Summon Selection screen.")

        return runs_completed
コード例 #2
0
    def start(first_run: bool) -> int:
        """Starts the process to complete a run for Quest Farming Mode and returns the number of items detected.

        Args:
            first_run (bool): Flag that determines whether or not to run the navigation process again. Should be False if the Farming Mode supports the "Play Again" feature for repeated runs.

        Returns:
            (int): Number of items detected.
        """
        from bot.game import Game

        number_of_items_dropped: int = 0

        # Start the navigation process.
        if first_run:
            Quest._navigate()
        elif Game.find_and_click_button("play_again"):
            Game.check_for_popups()
        else:
            # If the bot cannot find the "Play Again" button, check for Pending Battles and then perform navigation again.
            Game.check_for_pending()
            Quest._navigate()

        # Check for AP.
        Game.check_for_ap()

        # Check if the bot is at the Summon Selection screen.
        if ImageUtils.confirm_location("select_a_summon", tries=30):
            summon_check = Game.select_summon(Settings.summon_list,
                                              Settings.summon_element_list)
            if summon_check:
                # Select the Party.
                Game.find_party_and_start_mission(Settings.group_number,
                                                  Settings.party_number)

                # Close the "Item Picked Up" popup.
                if ImageUtils.confirm_location("items_picked_up"):
                    Game.find_and_click_button("ok")

                # Now start Combat Mode and detect any item drops.
                if CombatMode.start_combat_mode():
                    number_of_items_dropped = Game.collect_loot(
                        is_completed=True)
        else:
            raise QuestException(
                "Failed to arrive at the Summon Selection screen.")

        return number_of_items_dropped
コード例 #3
0
    def start(first_run: bool) -> int:
        """Starts the process to complete a run for Coop Farming Mode and returns the number of items detected.

        Args:
            first_run (bool): Flag that determines whether or not to run the navigation process again. Should be False if the Farming Mode supports the "Play Again" feature for repeated runs.

        Returns:
            (int): Number of items detected.
        """
        from bot.game import Game

        number_of_items_dropped: int = 0

        # Start the navigation process.
        if first_run:
            Coop._navigate()
        else:
            # Head back to the Coop Room.
            Game.find_and_click_button("coop_room")

            Game.wait(1)

            # Check for "Daily Missions" popup for Coop.
            if ImageUtils.confirm_location("coop_daily_missions", tries=1):
                Game.find_and_click_button("close")

            Game.wait(1)

            # Now that the bot is back at the Coop Room/Lobby, check if it closed due to time running out.
            if ImageUtils.confirm_location("coop_room_closed", tries=1):
                MessageLog.print_message(
                    "\n[COOP] Coop room has closed due to time running out.")
                return -1

            # Start the Coop Mission again.
            Game.find_and_click_button("coop_start")

            Game.wait(1)

        # Check for AP.
        Game.check_for_ap()

        # Check if the bot is at the Party Selection screen. Note that the bot is hosting solo so no support summon selection.
        if first_run and ImageUtils.confirm_location(
                "coop_without_support_summon", tries=30):
            # Select the Party.
            Game.find_party_and_start_mission(Settings.group_number,
                                              Settings.party_number)

            # Now click the "Start" button to start the Coop Mission.
            Game.find_and_click_button("coop_start")

            # Now start Combat Mode and detect any item drops.
            if CombatMode.start_combat_mode():
                number_of_items_dropped = Game.collect_loot(is_completed=True)
        elif first_run is False:
            MessageLog.print_message("\n[COOP] Starting Coop Mission again.")

            # Now start Combat Mode and detect any item drops.
            if CombatMode.start_combat_mode():
                number_of_items_dropped = Game.collect_loot(is_completed=True)
        else:
            raise CoopException(
                "Failed to arrive at the Summon Selection screen.")

        return number_of_items_dropped
コード例 #4
0
    def start(first_run: bool) -> int:
        """Starts the process to complete a run for Proving Grounds Farming Mode and returns the number of items detected.

        Args:
            first_run (bool): Flag that determines whether or not to run the navigation process again. Should be False if the Farming Mode supports the "Play Again" feature for repeated runs.

        Returns:
            (int): Number of runs completed.
        """
        from bot.game import Game

        runs_completed: int = 0

        # Start the navigation process.
        if first_run and ProvingGrounds._first_time:
            ProvingGrounds._navigate()
        elif ProvingGrounds._first_time and Game.find_and_click_button(
                "play_again"):
            MessageLog.print_message(
                "\n[PROVING.GROUNDS] Starting Proving Grounds Mission again..."
            )

        # Check for AP.
        Game.check_for_ap()

        # Check if the bot is at the Summon Selection screen.
        if (first_run
                or ProvingGrounds._first_time) and ImageUtils.confirm_location(
                    "proving_grounds_summon_selection", tries=30):
            summon_check = Game.select_summon(Settings.summon_list,
                                              Settings.summon_element_list)
            if summon_check:
                Game.wait(2.0)

                # No need to select a Party. Just click "OK" to start the mission and confirming the selected summon.
                Game.find_and_click_button("ok")

                Game.wait(2.0)

                MessageLog.print_message(
                    "\n[PROVING.GROUNDS] Now starting Mission for Proving Grounds..."
                )
                Game.find_and_click_button("proving_grounds_start")

                # Now start Combat Mode and detect any item drops.
                if CombatMode.start_combat_mode():
                    runs_completed = Game.collect_loot(is_completed=False)

                    # Click the "Next Battle" button if there are any battles left.
                    if Game.find_and_click_button(
                            "proving_grounds_next_battle"):
                        MessageLog.print_message(
                            "\n[PROVING.GROUNDS] Moving onto the next battle for Proving Grounds..."
                        )
                        Game.find_and_click_button("ok")
                        ProvingGrounds._first_time = False
        elif first_run is False and ProvingGrounds._first_time is False:
            # No need to select a Summon again as it is reused.
            if CombatMode.start_combat_mode():
                runs_completed = Game.collect_loot(is_completed=False)

                # Click the "Next Battle" button if there are any battles left.
                if Game.find_and_click_button("proving_grounds_next_battle"):
                    MessageLog.print_message(
                        "\n[PROVING.GROUNDS] Moving onto the next battle for Proving Grounds..."
                    )
                    Game.find_and_click_button("ok")
                else:
                    # Otherwise, all battles for the Mission has been completed. Collect the completion rewards at the end.
                    MessageLog.print_message(
                        "\n[PROVING.GROUNDS] Proving Grounds Mission has been completed."
                    )
                    Game.find_and_click_button("event")

                    # Check for friend request.
                    Game.find_and_click_button("cancel",
                                               tries=1,
                                               suppress_error=True)

                    # Check for trophy.
                    Game.find_and_click_button("close",
                                               tries=1,
                                               suppress_error=True)

                    Game.wait(2.0)
                    Game.find_and_click_button("proving_grounds_open_chest")

                    if ImageUtils.confirm_location(
                            "proving_grounds_completion_loot"):
                        MessageLog.print_message(
                            "\n[PROVING.GROUNDS] Completion rewards has been acquired."
                        )
                        runs_completed = Game.collect_loot(
                            is_completed=True, skip_popup_check=True)

                        # Reset the First Time flag so the bot can select a Summon and select the Mission again.
                        if Settings.item_amount_farmed < Settings.item_amount_to_farm:
                            ProvingGrounds._first_time = True
                    else:
                        raise ProvingGroundsException(
                            "Failed to detect the Completion Loot screen for completing this Proving Grounds mission."
                        )
        else:
            raise ProvingGroundsException(
                "Failed to arrive at the Summon Selection screen.")

        return runs_completed