Skip to content

Commit

Permalink
Fix Discord notifications having the wrong item amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
steve1316 committed Feb 12, 2022
1 parent 32fd6c9 commit a7155f3
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 95 deletions.
32 changes: 16 additions & 16 deletions src-tauri/backend/bot/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/backend/bot/game_modes/arcarum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
10 changes: 4 additions & 6 deletions src-tauri/backend/bot/game_modes/arcarum_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
12 changes: 5 additions & 7 deletions src-tauri/backend/bot/game_modes/coop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
10 changes: 4 additions & 6 deletions src-tauri/backend/bot/game_modes/dread_barrage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
8 changes: 3 additions & 5 deletions src-tauri/backend/bot/game_modes/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
14 changes: 6 additions & 8 deletions src-tauri/backend/bot/game_modes/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
10 changes: 4 additions & 6 deletions src-tauri/backend/bot/game_modes/guild_wars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
14 changes: 6 additions & 8 deletions src-tauri/backend/bot/game_modes/proving_grounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"):
Expand All @@ -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"):
Expand All @@ -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:
Expand All @@ -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
10 changes: 4 additions & 6 deletions src-tauri/backend/bot/game_modes/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Loading

0 comments on commit a7155f3

Please sign in to comment.