def _navigate_token_drawboxes(): """Navigates to the specified Event (Token Drawboxes) mission. Returns: None """ from bot.game import Game MessageLog.print_message( f"[EVENT.TOKEN.DRAWBOXES] Now beginning process to navigate to the mission: {Settings.mission_name}..." ) # Go to the Home screen. Game.go_back_home(confirm_location_check=True) # Go to the Event by clicking on the "Menu" button and then click the very first banner. Game.find_and_click_button("home_menu") banner_locations = ImageUtils.find_all("event_banner", custom_confidence=0.7) if len(banner_locations) == 0: banner_locations = ImageUtils.find_all("event_banner_blue", custom_confidence=0.7) if len(banner_locations) == 0: raise EventException("Failed to find the Event banner.") MouseUtils.move_and_click_point(banner_locations[0][0], banner_locations[0][1], "event_banner") Game.wait(1) # Check and click away the "Daily Missions" popup. if ImageUtils.confirm_location("event_daily_missions", tries=1): MessageLog.print_message( f"\n[EVENT.TOKEN.DRAWBOXES] Detected \"Daily Missions\" popup. Clicking it away..." ) Game.find_and_click_button("close") # Remove the difficulty prefix from the mission name. difficulty = "" formatted_mission_name = "" if Settings.mission_name.find("VH ") == 0: difficulty = "Very Hard" formatted_mission_name = Settings.mission_name[3:] elif Settings.mission_name.find("EX ") == 0: difficulty = "Extreme" formatted_mission_name = Settings.mission_name[3:] elif Settings.mission_name.find("EX+ ") == 0: difficulty = "Extreme+" formatted_mission_name = Settings.mission_name[4:] elif Settings.mission_name.find("IM ") == 0: difficulty = "Impossible" formatted_mission_name = Settings.mission_name[3:] # Scroll down the screen a little bit for this UI layout that has Token Drawboxes. MouseUtils.scroll_screen_from_home_button(-200) if formatted_mission_name == "Event Quest": MessageLog.print_message( f"[EVENT.TOKEN.DRAWBOXES] Now hosting Event Quest...") Game.find_and_click_button("event_quests") Game.wait(1) # Find all the round "Play" buttons. quest_play_locations = ImageUtils.find_all("play_round_button") # Only Extreme and Extreme+ difficulty is supported for farming efficiency. if difficulty == "Extreme": MouseUtils.move_and_click_point(quest_play_locations[3][0], quest_play_locations[3][1], "play_round_button") elif difficulty == "Extreme+": MouseUtils.move_and_click_point(quest_play_locations[4][0], quest_play_locations[4][1], "play_round_button") elif formatted_mission_name == "Event Raid": # Bring up the "Raid Battle" popup. Then scroll down the screen a bit for screens less than 1440p to see the entire popup. MessageLog.print_message( f"[EVENT.TOKEN.DRAWBOXES] Now hosting Event Raid...") if not Game.find_and_click_button("event_raid_battle"): ImageUtils.generate_alert( "Failed to detect Token Drawbox layout for this Event. Are you sure this Event has Token Drawboxes? If not, switch to \"Event\" Farming Mode." ) raise EventException( "Failed to detect Token Drawbox layout for this Event. Are you sure this Event has Token Drawboxes? If not, switch to \"Event\" Farming Mode." ) MouseUtils.scroll_screen_from_home_button(-200) Game.wait(1) ap_locations = ImageUtils.find_all("ap") if difficulty == "Very Hard": MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap") if not ImageUtils.wait_vanish("close", timeout=10): MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap") else: return None elif difficulty == "Extreme": MouseUtils.move_and_click_point(ap_locations[1][0], ap_locations[1][1], "ap") if not ImageUtils.wait_vanish("close", timeout=10): MouseUtils.move_and_click_point(ap_locations[1][0], ap_locations[1][1], "ap") else: return None elif difficulty == "Impossible": MouseUtils.move_and_click_point(ap_locations[2][0], ap_locations[2][1], "ap") if not ImageUtils.wait_vanish("close", timeout=10): MouseUtils.move_and_click_point(ap_locations[2][0], ap_locations[2][1], "ap") else: return None # If the user does not have enough Treasures to host a Extreme or an Impossible Raid, host a Very Hard Raid instead. MessageLog.print_message( f"[EVENT.TOKEN.DRAWBOXES] Not enough materials to host {difficulty}. Hosting Very Hard instead..." ) MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap") if not ImageUtils.wait_vanish("close", timeout=10): MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap") return None
def _navigate(): """Navigates to the specified Guild Wars mission. Returns: None """ from bot.game import Game # Go to the Home screen. Game.go_back_home(confirm_location_check = True) MessageLog.print_message(f"\n[GUILD.WARS] Now navigating to Guild Wars...") # Go to the Event by clicking on the "Menu" button and then click the very first banner. Game.find_and_click_button("home_menu") banner_locations = ImageUtils.find_all("event_banner", custom_confidence = 0.7) if len(banner_locations) == 0: banner_locations = ImageUtils.find_all("event_banner_blue", custom_confidence = 0.7) MouseUtils.move_and_click_point(banner_locations[0][0], banner_locations[0][1], "event_banner") Game.wait(1.0) difficulty = "" if Settings.mission_name == "Very Hard": difficulty = "Very Hard" elif Settings.mission_name == "Extreme": difficulty = "Extreme" elif Settings.mission_name == "Extreme+": difficulty = "Extreme+" elif Settings.mission_name == "NM90": difficulty = "NM90" elif Settings.mission_name == "NM95": difficulty = "NM95" elif Settings.mission_name == "NM100": difficulty = "NM100" elif Settings.mission_name == "NM150": difficulty = "NM150" if ImageUtils.confirm_location("guild_wars"): # Scroll the screen down a little bit. MouseUtils.scroll_screen_from_home_button(-200) Game.wait(1.0) raid_battle_locations = ImageUtils.find_all("event_raid_battle") # Perform different navigation actions based on whether the user wants to farm meat or to farm Nightmares. if difficulty == "Very Hard" or difficulty == "Extreme" or difficulty == "Extreme+": MessageLog.print_message(f"\n[GUILD.WARS] Now proceeding to farm meat.") # Click on the banner to farm meat. MouseUtils.move_and_click_point(raid_battle_locations[1][0], raid_battle_locations[1][1], "event_raid_battle") Game.wait(1.0) if ImageUtils.confirm_location("guild_wars_meat"): # Now click on the specified Mission to start. Also attempt at fixing the deadzone issue by looping. formatted_mission_name = difficulty.replace(" ", "_") tries = 10 MessageLog.print_message(f"[GUILD.WARS] Now hosting {difficulty} now...") ap_locations = ImageUtils.find_all("ap_30") if difficulty == "Very Hard": MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap_30") elif difficulty == "Extreme": MouseUtils.move_and_click_point(ap_locations[1][0], ap_locations[1][1], "ap_30") elif difficulty == "Extreme+": MouseUtils.move_and_click_point(ap_locations[2][0], ap_locations[2][1], "ap_30") Game.wait(3.0) while ImageUtils.wait_vanish("ap_30", timeout = 3) is False: if difficulty == "Very Hard": MouseUtils.move_and_click_point(ap_locations[0][0], ap_locations[0][1], "ap_30") elif difficulty == "Extreme": MouseUtils.move_and_click_point(ap_locations[1][0], ap_locations[1][1], "ap_30") elif difficulty == "Extreme+": MouseUtils.move_and_click_point(ap_locations[2][0], ap_locations[2][1], "ap_30") Game.wait(3.0) tries -= 1 if tries <= 0: if difficulty == "Extreme+": ImageUtils.generate_alert("You did not unlock Extreme+ yet!") raise GuildWarsException("You did not unlock Extreme+ yet!") else: raise GuildWarsException("There appears to be a deadzone issue that the bot failed 10 times to resolve. Please refresh the page and try again.") return None else: MessageLog.print_message(f"\n[GUILD.WARS] Now proceeding to farm Nightmares.") # Click on the banner to farm Nightmares. if difficulty != "NM150": MouseUtils.move_and_click_point(raid_battle_locations[0][0], raid_battle_locations[0][1], "event_raid_battle") if not ImageUtils.wait_vanish("guild_wars_nightmare", timeout = 10): MouseUtils.move_and_click_point(raid_battle_locations[0][0], raid_battle_locations[0][1], "event_raid_battle") else: MessageLog.print_message(f"\n[GUILD.WARS] Now hosting NM150 now...") Game.find_and_click_button("guild_wars_nightmare_150") if not ImageUtils.wait_vanish("guild_wars_nightmare_150", timeout = 10): Game.find_and_click_button("guild_wars_nightmare_150") if ImageUtils.confirm_location("guild_wars_nightmare"): Game.find_and_click_button("start") if difficulty != "NM150" and ImageUtils.confirm_location("guild_wars_nightmare"): nightmare_locations = ImageUtils.find_all("guild_wars_nightmares") # If today is the first/second day of Guild Wars, only NM90 will be available. if ImageUtils.confirm_location("guild_wars_nightmare_first_day", tries = 3): MessageLog.print_message(f"[GUILD.WARS] Today is the first/second day so hosting NM90.") Game.find_and_click_button("ok") # Alert the user if they lack the meat to host this and stop the bot. if not ImageUtils.wait_vanish("ok", timeout = 30): ImageUtils.generate_alert("You do not have enough meat to host this NM90!") raise GuildWarsException("You do not have enough meat to host this NM90!") # If it is not the first/second day of Guild Wars, that means that other difficulties are now available. elif difficulty == "NM90": MessageLog.print_message(f"[GUILD.WARS] Now hosting NM90 now...") MouseUtils.move_and_click_point(nightmare_locations[0][0], nightmare_locations[0][1], "guild_wars_nightmares") elif difficulty == "NM95": MessageLog.print_message(f"[GUILD.WARS] Now hosting NM95 now...") MouseUtils.move_and_click_point(nightmare_locations[1][0], nightmare_locations[1][1], "guild_wars_nightmares") elif difficulty == "NM100": MessageLog.print_message(f"[GUILD.WARS] Now hosting NM100 now...") MouseUtils.move_and_click_point(nightmare_locations[2][0], nightmare_locations[2][1], "guild_wars_nightmares") else: # If there is not enough meat to host, host Extreme+ instead. MessageLog.print_message(f"\n[GUILD.WARS] User lacks meat to host the Nightmare. Hosting Extreme+ instead...") if difficulty != "NM150": Game.find_and_click_button("close") else: Game.find_and_click_button("cancel") # Click on the banner to farm meat. Game.find_and_click_button("guild_wars_meat") if ImageUtils.confirm_location("guild_wars_meat"): MessageLog.print_message(f"[GUILD.WARS] Now hosting Extreme+ now...") Game.find_and_click_button("guild_wars_meat_extreme+") # Alert the user if they did not unlock Extreme+ and stop the bot. if not ImageUtils.wait_vanish("guild_wars_meat_extreme+", timeout = 30): ImageUtils.generate_alert("You did not unlock Extreme+ yet!") raise GuildWarsException("You did not unlock Extreme+ yet!") return None