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
def start(first_run: bool) -> int: """Starts the process to complete a run for Raid 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: Raid._navigate() else: # Check for Pending Battles and then perform navigation again. Game.check_for_pending() Raid._navigate() # Check for EP. Game.check_for_ep() # 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. if Game.find_party_and_start_mission(Settings.group_number, Settings.party_number): # Handle the rare case where joining the Raid after selecting the Summon and Party led the bot to the Quest Results screen with no loot to collect. if ImageUtils.confirm_location("no_loot", tries=2): MessageLog.print_message( "\n[RAID] Seems that the Raid just ended. Moving back to the Home screen and joining another Raid..." ) elif CombatMode.start_combat_mode(): number_of_items_dropped = Game.collect_loot( is_completed=True) else: MessageLog.print_message( "\n[RAID] Seems that the Raid ended before the bot was able to join. Now looking for another Raid to join..." ) else: raise RaidException( "Failed to arrive at the Summon Selection screen.") return number_of_items_dropped
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
def test_combat_mode_old_lignoid(self): # Make sure the bot is at the Home screen and go to the Trial Battles screen. self.game_object.go_back_home(confirm_location_check=True) MouseUtils.scroll_screen_from_home_button(-600) self.game_object.find_and_click_button("gameplay_extras") while self.game_object.find_and_click_button("trial_battles") is False: MouseUtils.scroll_screen_from_home_button(-300) self.assertTrue(ImageUtils.confirm_location("trial_battles")) # Click on the "Old Lignoid" button. self.game_object.find_and_click_button("trial_battles_old_lignoid") # Select any detected "Play" button. self.game_object.find_and_click_button("play_round_button") # Now select the first Summon. choose_a_summon_location = ImageUtils.find_button("choose_a_summon") MouseUtils.move_and_click_point(choose_a_summon_location[0], choose_a_summon_location[1] + 187, "choose_a_summon") # Now start the Old Lignoid Trial Battle right away and then wait a few seconds. self.game_object.find_and_click_button("party_selection_ok") Game.wait(3) if ImageUtils.confirm_location("trial_battles_description"): self.game_object.find_and_click_button("close") self.assertFalse( CombatMode.start_combat_mode(script_commands=[ "Turn 1:", "\tsummon(6)", "\tcharacter1.useSkill(1)", "end", "", "Turn 5:", "\texit", "end" ])) self.assertTrue(ImageUtils.confirm_location("home")) return None
def check_for_event_nightmare(): """Checks for Event Nightmare and if it appears and the user enabled it in user settings, start it. Returns: (bool): Return True if Event Nightmare was detected and successfully completed. Otherwise, return False. """ from bot.game import Game if Settings.enable_nightmare and ImageUtils.confirm_location( "limited_time_quests", tries=1): # First check if the Event Nightmare is skippable. event_claim_loot_location = ImageUtils.find_button( "event_claim_loot", tries=1, suppress_error=True) if event_claim_loot_location is not None: MessageLog.print_message( "\n[EVENT] Skippable Event Nightmare detected. Claiming it now..." ) MouseUtils.move_and_click_point(event_claim_loot_location[0], event_claim_loot_location[1], "event_claim_loot") Game.collect_loot(is_completed=False, is_event_nightmare=True) return True else: MessageLog.print_message( "\n[EVENT] Detected Event Nightmare. Starting it now...") MessageLog.print_message( "\n********************************************************************************" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message(f"[EVENT] Event Nightmare") MessageLog.print_message( f"[EVENT] Event Nightmare Summon Elements: {Settings.nightmare_summon_elements_list}" ) MessageLog.print_message( f"[EVENT] Event Nightmare Summons: {Settings.nightmare_summon_list}" ) MessageLog.print_message( f"[EVENT] Event Nightmare Group Number: {Settings.nightmare_group_number}" ) MessageLog.print_message( f"[EVENT] Event Nightmare Party Number: {Settings.nightmare_party_number}" ) MessageLog.print_message( f"[EVENT] Event Nightmare Combat Script: {Settings.nightmare_combat_script_name}" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message( "********************************************************************************\n" ) # Click the "Play Next" button to head to the Summon Selection screen. Game.find_and_click_button("play_next") Game.wait(1) # Once the bot is at the Summon Selection screen, select your Summon and Party and start the mission. if ImageUtils.confirm_location("select_a_summon"): Game.select_summon(Settings.nightmare_summon_list, Settings.nightmare_summon_elements_list) start_check = Game.find_party_and_start_mission( int(Settings.nightmare_group_number), int(Settings.nightmare_party_number)) # Once preparations are completed, start Combat Mode. if start_check and CombatMode.start_combat_mode( is_nightmare=True): Game.collect_loot(is_completed=False, is_event_nightmare=True) return True elif not Settings.enable_nightmare and ImageUtils.confirm_location( "limited_time_quests", tries=1): # First check if the Event Nightmare is skippable. event_claim_loot_location = ImageUtils.find_button( "event_claim_loot", tries=1, suppress_error=True) if event_claim_loot_location is not None: MessageLog.print_message( "\n[EVENT] Skippable Event Nightmare detected but user opted to not run it. Claiming it regardless..." ) MouseUtils.move_and_click_point(event_claim_loot_location[0], event_claim_loot_location[1], "event_claim_loot") Game.collect_loot(is_completed=False, is_event_nightmare=True) return True else: MessageLog.print_message( "\n[EVENT] Event Nightmare detected but user opted to not run it. Moving on..." ) Game.find_and_click_button("close") else: MessageLog.print_message( "\n[EVENT] No Event Nightmare detected. Moving on...") return False
def check_for_dimensional_halo(): """Checks for Dimensional Halo and if it appears and the user enabled it in user settings, start it. Returns: (bool): Return True if Dimensional Halo was detected and successfully completed. Otherwise, return False. """ from bot.game import Game if Settings.enable_nightmare and ImageUtils.confirm_location( "limited_time_quests", tries=1): MessageLog.print_message( "\n[D.HALO] Detected Dimensional Halo. Starting it now...") Special._dimensional_halo_amount += 1 MessageLog.print_message( "\n********************************************************************************" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message(f"[D.HALO] Dimensional Halo") MessageLog.print_message( f"[D.HALO] Dimensional Halo Summon Elements: {Settings.nightmare_summon_elements_list}" ) MessageLog.print_message( f"[D.HALO] Dimensional Halo Summons: {Settings.nightmare_summon_list}" ) MessageLog.print_message( f"[D.HALO] Dimensional Halo Group Number: {Settings.nightmare_group_number}" ) MessageLog.print_message( f"[D.HALO] Dimensional Halo Party Number: {Settings.nightmare_party_number}" ) MessageLog.print_message( f"[D.HALO] Dimensional Halo Combat Script: {Settings.nightmare_combat_script_name}" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message( "********************************************************************************\n" ) # Click the "Play Next" button to head to the Summon Selection screen. Game.find_and_click_button("play_next") Game.wait(1) # Once the bot is at the Summon Selection screen, select your Summon and Party and start the mission. if ImageUtils.confirm_location("select_a_summon"): Game.select_summon(Settings.nightmare_summon_list, Settings.nightmare_summon_elements_list) start_check = Game.find_party_and_start_mission( int(Settings.nightmare_group_number), int(Settings.nightmare_party_number)) # Once preparations are completed, start Combat Mode. if start_check and CombatMode.start_combat_mode( is_nightmare=True): Game.collect_loot(is_completed=False, is_event_nightmare=True) return True elif not Settings.enable_nightmare and ImageUtils.confirm_location( "limited_time_quests", tries=1): MessageLog.print_message( "\n[D.HALO] Dimensional Halo detected but user opted to not run it. Moving on..." ) Game.find_and_click_button("close") else: MessageLog.print_message( "\n[D.HALO] No Dimensional Halo detected. Moving on...") return False
def check_for_rotb_extreme_plus(): """Checks for Extreme+ for Rise of the Beasts and if it appears and the user enabled it in user settings, start it. Returns: (bool): Return True if Extreme+ was detected and successfully completed. Otherwise, return False. """ from bot.game import Game if Settings.enable_nightmare and ImageUtils.confirm_location( "rotb_extreme_plus", tries=1): MessageLog.print_message( "\n[ROTB] Detected Extreme+. Starting it now...") MessageLog.print_message( "\n********************************************************************************" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message(f"[ROTB] Rise of the Beasts Extreme+") MessageLog.print_message( f"[ROTB] Rise of the Beasts Extreme+ Summon Elements: {Settings.nightmare_summon_elements_list}" ) MessageLog.print_message( f"[ROTB] Rise of the Beasts Extreme+ Summons: {Settings.nightmare_summon_list}" ) MessageLog.print_message( f"[ROTB] Rise of the Beasts Extreme+ Group Number: {Settings.nightmare_group_number}" ) MessageLog.print_message( f"[ROTB] Rise of the Beasts Extreme+ Party Number: {Settings.nightmare_party_number}" ) MessageLog.print_message( f"[ROTB] Rise of the Beasts Extreme+ Combat Script: {Settings.nightmare_combat_script_name}" ) MessageLog.print_message( "********************************************************************************" ) MessageLog.print_message( "********************************************************************************\n" ) # Click the "Play Next" button to head to the Summon Selection screen. Game.find_and_click_button("play_next") Game.wait(1) # Once the bot is at the Summon Selection screen, select your Summon and Party and start the mission. if ImageUtils.confirm_location("select_a_summon"): Game.select_summon(Settings.nightmare_summon_list, Settings.nightmare_summon_elements_list) start_check = Game.find_party_and_start_mission( int(Settings.nightmare_group_number), int(Settings.nightmare_party_number)) # Once preparations are completed, start Combat mode. if start_check and CombatMode.start_combat_mode( is_nightmare=True): Game.collect_loot(is_completed=False, is_event_nightmare=True) return True elif not Settings.enable_nightmare and ImageUtils.confirm_location( "rotb_extreme_plus", tries=2): MessageLog.print_message( "\n[ROTB] Rise of the Beasts Extreme+ detected but user opted to not run it. Moving on..." ) Game.find_and_click_button("close") else: MessageLog.print_message( "\n[ROTB] No Rise of the Beasts Extreme+ detected. Moving on..." ) return False
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
def start() -> int: """Starts the process of completing Arcarum expeditions. Returns: (int): Number of runs completed. """ from bot.game import Game runs_completed = 0 while runs_completed < Settings.item_amount_to_farm: Arcarum._navigate_to_map() while True: action = Arcarum._choose_action() MessageLog.print_message( f"[ARCARUM] Action to take will be: {action}") if action == "Combat": # Start Combat Mode. if Game.find_party_and_start_mission( Settings.group_number, Settings.party_number): if ImageUtils.confirm_location("elemental_damage", tries=1): raise ArcarumException( "Encountered an important mob for Arcarum and the selected party does not conform to the enemy's weakness. Perhaps you would like to do this battle yourself?" ) elif ImageUtils.confirm_location("arcarum_restriction", tries=1): raise ArcarumException( "Encountered a party restriction for Arcarum. Perhaps you would like to complete this section by yourself?" ) if CombatMode.start_combat_mode(): Game.collect_loot(is_completed=False, skip_info=True) Game.find_and_click_button("expedition") elif action == "Navigating": # Move to the next available node. Game.find_and_click_button("move") elif action == "Next Area": # Either navigate to the next area or confirm the expedition's conclusion. if Game.find_and_click_button("arcarum_next_stage"): Game.find_and_click_button("ok") MessageLog.print_message( f"[ARCARUM] Moving to the next area...") elif Game.find_and_click_button("arcarum_checkpoint"): Game.find_and_click_button("arcarum") MessageLog.print_message( f"[ARCARUM] Expedition is complete.") runs_completed += 1 Game.wait(1) Game.check_for_skyscope() break elif action == "Boss Detected": MessageLog.print_message( f"[ARCARUM] Boss has been detected. Stopping the bot.") raise ArcarumException( "Boss has been detected. Stopping the bot.") Game.wait(1) return runs_completed
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