From a7155f32b53b78be4587e0a3f2fd7beae384d62d Mon Sep 17 00:00:00 2001 From: Steve Tu Date: Sat, 12 Feb 2022 00:10:05 -0800 Subject: [PATCH] Fix Discord notifications having the wrong item amounts --- src-tauri/backend/bot/game.py | 32 +++++++++---------- src-tauri/backend/bot/game_modes/arcarum.py | 6 ++-- .../backend/bot/game_modes/arcarum_sandbox.py | 10 +++--- src-tauri/backend/bot/game_modes/coop.py | 12 +++---- .../backend/bot/game_modes/dread_barrage.py | 10 +++--- src-tauri/backend/bot/game_modes/event.py | 8 ++--- src-tauri/backend/bot/game_modes/generic.py | 14 ++++---- .../backend/bot/game_modes/guild_wars.py | 10 +++--- .../backend/bot/game_modes/proving_grounds.py | 14 ++++---- src-tauri/backend/bot/game_modes/quest.py | 10 +++--- src-tauri/backend/bot/game_modes/raid.py | 10 +++--- src-tauri/backend/bot/game_modes/rotb.py | 10 +++--- src-tauri/backend/bot/game_modes/special.py | 10 +++--- .../backend/bot/game_modes/xeno_clash.py | 10 +++--- 14 files changed, 71 insertions(+), 95 deletions(-) diff --git a/src-tauri/backend/bot/game.py b/src-tauri/backend/bot/game.py index 278613fd..ca78e80e 100644 --- a/src-tauri/backend/bot/game.py +++ b/src-tauri/backend/bot/game.py @@ -579,7 +579,7 @@ def check_for_ep(): @staticmethod def collect_loot(is_completed: bool, is_pending_battle: bool = False, is_event_nightmare: bool = False, skip_info: bool = False, skip_popup_check: bool = False): - """Collect the loot from the Results screen while clicking away any dialog popups. Primarily for raids. + """Collects the loot from the Results screen while clicking away any dialog popups while updating the internal item count. Args: is_completed (bool): Allows incrementing of number of runs completed. This is for Farming Modes who have multi-part sections to them to prevent unnecessary incrementing of runs when it wasn't finished with 1 yet. @@ -589,7 +589,7 @@ def collect_loot(is_completed: bool, is_pending_battle: bool = False, is_event_n skip_popup_check (bool): Skip checking for popups to get to the Loot Collected screen. Defaults to False. Returns: - (int): Number of specified items dropped. + None """ temp_amount = 0 @@ -691,7 +691,7 @@ def collect_loot(is_completed: bool, is_pending_battle: bool = False, is_event_n Game._discord_queue.put(discord_string) - return temp_amount + return None @staticmethod def check_for_popups() -> bool: @@ -916,31 +916,31 @@ def start_farming_mode(self): first_run = True while Settings.item_amount_farmed < Settings.item_amount_to_farm: if Settings.farming_mode == "Quest": - Settings.item_amount_farmed += Quest.start(first_run) + Quest.start(first_run) elif Settings.farming_mode == "Special": - Settings.item_amount_farmed += Special.start(first_run) + Special.start(first_run) elif Settings.farming_mode == "Coop": - Settings.item_amount_farmed += Coop.start(first_run) + Coop.start(first_run) elif Settings.farming_mode == "Raid": - Settings.item_amount_farmed += Raid.start(first_run) + Raid.start(first_run) elif Settings.farming_mode == "Event" or Settings.farming_mode == "Event (Token Drawboxes)": - Settings.item_amount_farmed += Event.start(first_run) + Event.start(first_run) elif Settings.farming_mode == "Rise of the Beasts": - Settings.item_amount_farmed += RiseOfTheBeasts.start(first_run) + RiseOfTheBeasts.start(first_run) elif Settings.farming_mode == "Guild Wars": - Settings.item_amount_farmed += GuildWars.start(first_run) + GuildWars.start(first_run) elif Settings.farming_mode == "Dread Barrage": - Settings.item_amount_farmed += DreadBarrage.start(first_run) + DreadBarrage.start(first_run) elif Settings.farming_mode == "Proving Grounds": - Settings.item_amount_farmed += ProvingGrounds.start(first_run) + ProvingGrounds.start(first_run) elif Settings.farming_mode == "Xeno Clash": - Settings.item_amount_farmed += XenoClash.start(first_run) + XenoClash.start(first_run) elif Settings.farming_mode == "Arcarum": - Settings.item_amount_farmed += Arcarum.start() + Arcarum.start() elif Settings.farming_mode == "Arcarum Sandbox": - Settings.item_amount_farmed += ArcarumSandbox.start() + ArcarumSandbox.start() elif Settings.farming_mode == "Generic": - Settings.item_amount_farmed += Generic.start() + Generic.start() if Settings.item_amount_farmed < Settings.item_amount_to_farm: # Generate a resting period if the user enabled it. diff --git a/src-tauri/backend/bot/game_modes/arcarum.py b/src-tauri/backend/bot/game_modes/arcarum.py index c3bac4bf..135163b4 100644 --- a/src-tauri/backend/bot/game_modes/arcarum.py +++ b/src-tauri/backend/bot/game_modes/arcarum.py @@ -159,11 +159,11 @@ def _check_for_boss() -> bool: return False @staticmethod - def start() -> int: + def start(): """Starts the process of completing Arcarum expeditions. Returns: - (int): Number of runs completed. + None """ from bot.game import Game @@ -207,4 +207,4 @@ def start() -> int: MessageLog.print_message(f"[ARCARUM] Boss has been detected. Stopping the bot.") raise ArcarumException("Boss has been detected. Stopping the bot.") - return runs_completed + return None diff --git a/src-tauri/backend/bot/game_modes/arcarum_sandbox.py b/src-tauri/backend/bot/game_modes/arcarum_sandbox.py index 8bc891ad..5fbc8699 100644 --- a/src-tauri/backend/bot/game_modes/arcarum_sandbox.py +++ b/src-tauri/backend/bot/game_modes/arcarum_sandbox.py @@ -347,16 +347,14 @@ def _refill_aap(): return None @staticmethod - def start() -> int: + def start(): """Starts the process of completing Arcarum Replicard Sandbox missions. Returns: - (int): Number of items detected. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if ArcarumSandbox._first_run: ArcarumSandbox._navigate_to_zone() @@ -385,6 +383,6 @@ def start() -> int: if Game.find_party_and_start_mission(Settings.group_number, Settings.party_number): if CombatMode.start_combat_mode(): - number_of_items_dropped = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) - return number_of_items_dropped + return None diff --git a/src-tauri/backend/bot/game_modes/coop.py b/src-tauri/backend/bot/game_modes/coop.py index 3d7601cb..2024ab97 100644 --- a/src-tauri/backend/bot/game_modes/coop.py +++ b/src-tauri/backend/bot/game_modes/coop.py @@ -135,19 +135,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """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. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if first_run: Coop._navigate() @@ -186,14 +184,14 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - number_of_items_dropped = Game.collect_loot(is_completed = True) + 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) + Game.collect_loot(is_completed = True) else: raise CoopException("Failed to arrive at the Summon Selection screen.") - return number_of_items_dropped + return None diff --git a/src-tauri/backend/bot/game_modes/dread_barrage.py b/src-tauri/backend/bot/game_modes/dread_barrage.py index 7f4261f5..becdadf8 100644 --- a/src-tauri/backend/bot/game_modes/dread_barrage.py +++ b/src-tauri/backend/bot/game_modes/dread_barrage.py @@ -92,19 +92,17 @@ def _navigate(): Game.wait(2) @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """Starts the process to complete a run for Dread Barrage 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. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if first_run: DreadBarrage._navigate() @@ -127,8 +125,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - number_of_items_dropped = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise DreadBarrageException("Failed to arrive at the Summon Selection screen.") - return number_of_items_dropped + return None diff --git a/src-tauri/backend/bot/game_modes/event.py b/src-tauri/backend/bot/game_modes/event.py index 65293788..5048cd2a 100644 --- a/src-tauri/backend/bot/game_modes/event.py +++ b/src-tauri/backend/bot/game_modes/event.py @@ -287,12 +287,10 @@ def start(first_run: bool): 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. + None """ from bot.game import Game - runs_completed: int = 0 - # Start the navigation process. if first_run: Event._navigate() @@ -317,8 +315,8 @@ def start(first_run: bool): # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise EventException("Failed to arrive at the Summon Selection screen.") - return runs_completed + return None diff --git a/src-tauri/backend/bot/game_modes/generic.py b/src-tauri/backend/bot/game_modes/generic.py index 767cc90f..03665916 100644 --- a/src-tauri/backend/bot/game_modes/generic.py +++ b/src-tauri/backend/bot/game_modes/generic.py @@ -15,30 +15,28 @@ class Generic: """ @staticmethod - def start() -> int: + def start(): """Starts the process of completing a generic setup that supports the 'Play Again' logic. Returns: - (int): Number of runs completed. + None """ 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, the Loot Collection screen with the "Play Again" button visible, or the Coop Room screen. if ImageUtils.find_button("attack", tries = 10): 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) + Game.collect_loot(is_completed = True) elif Game.find_and_click_button("coop_start", tries = 10): MessageLog.print_message(f"[GENERIC] Bot is at the Coop Room screen. Starting the Coop mission and Combat Mode now...") Game.wait(3.0) if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) # Head back to the Coop Room. Game.find_and_click_button("coop_room") @@ -69,10 +67,10 @@ def start() -> int: if Game.find_and_click_button("ok", tries = 30): # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + 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 + return None diff --git a/src-tauri/backend/bot/game_modes/guild_wars.py b/src-tauri/backend/bot/game_modes/guild_wars.py index 6221a512..a0b8e209 100644 --- a/src-tauri/backend/bot/game_modes/guild_wars.py +++ b/src-tauri/backend/bot/game_modes/guild_wars.py @@ -184,19 +184,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """Starts the process to complete a run for Guild Wars 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. + None """ from bot.game import Game - runs_completed: int = 0 - # Start the navigation process. if first_run: GuildWars._navigate() @@ -219,8 +217,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise GuildWarsException("Failed to arrive at the Summon Selection screen.") - return runs_completed + return None diff --git a/src-tauri/backend/bot/game_modes/proving_grounds.py b/src-tauri/backend/bot/game_modes/proving_grounds.py index 0c098630..2db9e7db 100644 --- a/src-tauri/backend/bot/game_modes/proving_grounds.py +++ b/src-tauri/backend/bot/game_modes/proving_grounds.py @@ -66,19 +66,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """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. + None """ from bot.game import Game - runs_completed: int = 0 - # Start the navigation process. if first_run and ProvingGrounds._first_time: ProvingGrounds._navigate() @@ -104,7 +102,7 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = False) + 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"): @@ -114,7 +112,7 @@ def start(first_run: bool) -> int: 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) + 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"): @@ -136,7 +134,7 @@ def start(first_run: bool) -> int: 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) + 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: @@ -146,4 +144,4 @@ def start(first_run: bool) -> int: else: raise ProvingGroundsException("Failed to arrive at the Summon Selection screen.") - return runs_completed + return None diff --git a/src-tauri/backend/bot/game_modes/quest.py b/src-tauri/backend/bot/game_modes/quest.py index 30baa0b1..a16158f4 100644 --- a/src-tauri/backend/bot/game_modes/quest.py +++ b/src-tauri/backend/bot/game_modes/quest.py @@ -193,19 +193,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """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. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if first_run: Quest._navigate() @@ -232,8 +230,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - number_of_items_dropped = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise QuestException("Failed to arrive at the Summon Selection screen.") - return number_of_items_dropped + return None diff --git a/src-tauri/backend/bot/game_modes/raid.py b/src-tauri/backend/bot/game_modes/raid.py index 3d9c28ca..ba7a1528 100644 --- a/src-tauri/backend/bot/game_modes/raid.py +++ b/src-tauri/backend/bot/game_modes/raid.py @@ -169,19 +169,17 @@ def _navigate(): raise RaidException("Failed to reach the Backup Requests screen.") @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """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. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if first_run: Raid._navigate() @@ -204,10 +202,10 @@ def start(first_run: bool) -> int: if ImageUtils.confirm_location("no_loot", disable_adjustment = True): 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) + 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 + return None diff --git a/src-tauri/backend/bot/game_modes/rotb.py b/src-tauri/backend/bot/game_modes/rotb.py index 5bc54cdd..6ef9f471 100644 --- a/src-tauri/backend/bot/game_modes/rotb.py +++ b/src-tauri/backend/bot/game_modes/rotb.py @@ -162,19 +162,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """Starts the process to complete a run for Rise of the Beasts 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. + None """ from bot.game import Game - runs_completed: int = 0 - # Start the navigation process. if first_run: RiseOfTheBeasts._navigate() @@ -198,8 +196,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise RiseOfTheBeastsException("Failed to arrive at the Summon Selection screen.") - return runs_completed + return None diff --git a/src-tauri/backend/bot/game_modes/special.py b/src-tauri/backend/bot/game_modes/special.py index 2ad78e58..fc5d20a6 100644 --- a/src-tauri/backend/bot/game_modes/special.py +++ b/src-tauri/backend/bot/game_modes/special.py @@ -265,19 +265,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """Starts the process to complete a run for Special 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. + None """ from bot.game import Game - number_of_items_dropped: int = 0 - # Start the navigation process. if first_run: Special._navigate() @@ -301,8 +299,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - number_of_items_dropped = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise SpecialException("Failed to arrive at the Summon Selection screen.") - return number_of_items_dropped + return None diff --git a/src-tauri/backend/bot/game_modes/xeno_clash.py b/src-tauri/backend/bot/game_modes/xeno_clash.py index 8d6a649b..2fe167e6 100644 --- a/src-tauri/backend/bot/game_modes/xeno_clash.py +++ b/src-tauri/backend/bot/game_modes/xeno_clash.py @@ -141,19 +141,17 @@ def _navigate(): return None @staticmethod - def start(first_run: bool) -> int: + def start(first_run: bool): """Starts the process to complete a run for Xeno Clash 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. + None """ from bot.game import Game - runs_completed: int = 0 - # Start the navigation process. if first_run: XenoClash._navigate() @@ -177,8 +175,8 @@ def start(first_run: bool) -> int: # Now start Combat Mode and detect any item drops. if CombatMode.start_combat_mode(): - runs_completed = Game.collect_loot(is_completed = True) + Game.collect_loot(is_completed = True) else: raise XenoClashException("Failed to arrive at the Summon Selection screen.") - return runs_completed + return None