Skip to content

Commit

Permalink
#6 - Fixed 2 bugs concerning EMP Mastery popups and Pending Battles.
Browse files Browse the repository at this point in the history
- Also prevented the incrementing of the amount of runs so far when collecting from Pending Battles because there is no certainty that a Pending Battle is the same mission that you are currently farming.
  • Loading branch information
steve1316 committed Feb 13, 2021
1 parent b1985e4 commit 429b7b0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
59 changes: 31 additions & 28 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,15 @@ def use_character_skill(self, character_selected: int, skill: int):

return None

def collect_loot(self):
def collect_loot(self, isPendingBattle: bool = False):
"""Collect the loot from the Results screen while clicking away any dialog popups. Primarily for raids.
Args:
isPendingBattle (bool): Skip the incrementation of runs attempted if this was a Pending Battle. Defaults to False.
Returns:
None
"""
self.print_and_save(f"\n{self.printtime()} [INFO] Detecting if any loot dropped...")

# Click away the EXP Gained popup and any other popups until the bot reaches the Loot Collected Screen.
if(self.image_tools.confirm_location("exp_gained") and not self.retreat_check):
while(not self.image_tools.confirm_location("loot_collected", tries=1)):
Expand All @@ -654,35 +655,37 @@ def collect_loot(self):
if(ok_button_location != None):
self.mouse_tools.move_and_click_point(ok_button_location[0], ok_button_location[1])

# Double click the screen to hopefully clear away any EMP Mastery level up popups.
self.mouse_tools.move_and_click_point(self.home_button_location[0], self.home_button_location[1] - 200, mouse_clicks=2)
# Search for and click on the Extended Mastery prompt.
self.find_and_click_button("new_extended_mastery_level", tries=1, suppress_error=True)

# Now that the bot is at the Loot Collected Screen, detect items.
if(not isPendingBattle):
self.print_and_save(f"\n{self.printtime()} [INFO] Detecting if any loot dropped...")
if(self.item_name != "EXP" and self.item_name != "Repeated Runs"):
temp_amount = self.image_tools.find_farmed_items([self.item_name])[0]
else:
temp_amount = 1

self.item_amount_farmed += temp_amount
self.amount_of_runs_finished += 1

if(not isPendingBattle):
if(self.item_name != "EXP" and self.item_name != "Repeated Runs"):
temp_amount = self.image_tools.find_farmed_items([self.item_name])[0]
self.print_and_save("\n\n********************************************************************************")
self.print_and_save(f"{self.printtime()} [FARM] Mode: {self.map_mode}")
self.print_and_save(f"{self.printtime()} [FARM] Mission: {self.mission_name}")
self.print_and_save(f"{self.printtime()} [FARM] Summon: {self.summon_name}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of {self.item_name} gained this run: {temp_amount}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of {self.item_name} gained in total: {self.item_amount_farmed} / {self.item_amount_to_farm}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of runs completed: {self.amount_of_runs_finished}")
self.print_and_save("********************************************************************************\n")
else:
temp_amount = 1

self.item_amount_farmed += temp_amount

self.amount_of_runs_finished += 1

if(self.item_name != "EXP" and self.item_name != "Repeated Runs"):
self.print_and_save("\n\n********************************************************************************")
self.print_and_save(f"{self.printtime()} [FARM] Mode: {self.map_mode}")
self.print_and_save(f"{self.printtime()} [FARM] Mission: {self.mission_name}")
self.print_and_save(f"{self.printtime()} [FARM] Summon: {self.summon_name}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of {self.item_name} gained this run: {temp_amount}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of {self.item_name} gained in total: {self.item_amount_farmed} / {self.item_amount_to_farm}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of runs completed: {self.amount_of_runs_finished}")
self.print_and_save("********************************************************************************\n")
else:
self.print_and_save("\n\n********************************************************************************")
self.print_and_save(f"{self.printtime()} [FARM] Mode: {self.map_mode}")
self.print_and_save(f"{self.printtime()} [FARM] Mission: {self.mission_name}")
self.print_and_save(f"{self.printtime()} [FARM] Summon: {self.summon_name}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of runs completed: {self.amount_of_runs_finished} / {self.item_amount_to_farm}")
self.print_and_save("********************************************************************************\n")
self.print_and_save("\n\n********************************************************************************")
self.print_and_save(f"{self.printtime()} [FARM] Mode: {self.map_mode}")
self.print_and_save(f"{self.printtime()} [FARM] Mission: {self.mission_name}")
self.print_and_save(f"{self.printtime()} [FARM] Summon: {self.summon_name}")
self.print_and_save(f"{self.printtime()} [FARM] Amount of runs completed: {self.amount_of_runs_finished} / {self.item_amount_to_farm}")
self.print_and_save("********************************************************************************\n")

return None

Expand Down
Binary file added images/buttons/new_extended_mastery_level.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions map_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def check_for_pending(self, map_mode: str, tries: int = 2):
self.raids_joined -= 1
raid_pending_battle_check = True
else:
self.game.collect_loot()
self.game.collect_loot(isPendingBattle=True)
if(self.raids_joined > 0):
self.raids_joined -= 1
raid_pending_battle_check = True
Expand All @@ -676,7 +676,7 @@ def check_for_pending(self, map_mode: str, tries: int = 2):
if(self.raids_joined > 0):
self.raids_joined -= 1
else:
self.game.collect_loot()
self.game.collect_loot(isPendingBattle=True)
if(self.raids_joined > 0):
self.raids_joined -= 1

Expand All @@ -690,7 +690,7 @@ def check_for_pending(self, map_mode: str, tries: int = 2):
self.game.print_and_save(f"{self.game.printtime()} [INFO] No loot can be collected.")
self.game.find_and_click_button("quests")
else:
self.game.collect_loot()
self.game.collect_loot(isPendingBattle=True)

if(self.game.image_tools.find_button("quest_results_pending_battles", tries=1)):
self.game.find_and_click_button("quest_results_pending_battles")
Expand All @@ -709,6 +709,7 @@ def check_for_pending(self, map_mode: str, tries: int = 2):
if(self.game.image_tools.find_button("quest_results_pending_battles", tries=tries, suppress_error=True)):
self.game.print_and_save(f"\n{self.game.printtime()} [INFO] Found pending battles that need collecting from.")
self.game.find_and_click_button("quest_results_pending_battles")
self.game.wait(1)
if(self.game.image_tools.confirm_location("pending_battles", tries=1)):
while(self.game.image_tools.find_button("tap_here_to_see_rewards", tries=2)):
self.game.find_and_click_button("tap_here_to_see_rewards")
Expand All @@ -718,7 +719,7 @@ def check_for_pending(self, map_mode: str, tries: int = 2):
self.game.print_and_save(f"{self.game.printtime()} [INFO] No loot can be collected.")
self.game.find_and_click_button("quests")
else:
self.game.collect_loot()
self.game.collect_loot(isPendingBattle=True)

if(self.game.image_tools.find_button("quest_results_pending_battles", tries=1)):
self.game.find_and_click_button("quest_results_pending_battles")
Expand Down

0 comments on commit 429b7b0

Please sign in to comment.