Skip to content

Commit

Permalink
trophy road collection needs to handle being on queens mode fights at…
Browse files Browse the repository at this point in the history
… start of collect_trophy_road_rewards()
  • Loading branch information
matthewmiglio committed Sep 22, 2024
1 parent 90c5903 commit e124547
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/pyclashbot/bot/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,26 +648,26 @@ def state_tree_tester(vm_index):
job_list = {
# job toggles
"open_battlepass_user_toggle": False,
"open_chests_user_toggle": True,
"request_user_toggle": True,
"donate_toggle": True,
"open_chests_user_toggle": False,
"request_user_toggle": False,
"donate_toggle": False,
"free_donate_toggle": False,
"card_mastery_user_toggle": True,
"free_offer_user_toggle": True,
"gold_offer_user_toggle": True,
"card_mastery_user_toggle": False,
"free_offer_user_toggle": False,
"gold_offer_user_toggle": False,
"trophy_road_1v1_battle_user_toggle": False,
"path_of_legends_1v1_battle_user_toggle": False,
"goblin_queens_journey_1v1_battle_user_toggle": False,
"2v2_battle_user_toggle": True,
"upgrade_user_toggle": True,
"2v2_battle_user_toggle": False,
"upgrade_user_toggle": False,
"war_user_toggle": False,
"random_decks_user_toggle": True,
"random_decks_user_toggle": False,
"open_bannerbox_user_toggle": False,
"daily_rewards_user_toggle": False,
"battlepass_collect_user_toggle": True,
"level_up_chest_user_toggle": True,
"battlepass_collect_user_toggle": False,
"level_up_chest_user_toggle": False,
"trophy_road_rewards_user_toggle": True,
"season_shop_buys_user_toggle": True,
"season_shop_buys_user_toggle": False,
# keep these off
"disable_win_track_toggle": False,
"skip_fight_if_full_chests_user_toggle": False,
Expand Down
11 changes: 8 additions & 3 deletions src/pyclashbot/bot/trophy_road_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ def collect_trophy_road_rewards_state(vm_index: int, logger: Logger, next_state:
)
# Return "restart" if still in Path of Legends after clicking.
return "restart"

rewards_collected_result = 0
# Checks if Trophy Road rewards are available and attempts to collect them.
while check_for_trophy_road_rewards(vm_index):
logger.change_status("Trophy Road rewards detected. Attempting to collect...")
trophy_road_state, rewards_collected = collect_trophy_road_rewards(
vm_index, logger,
)

if trophy_road_state is not True:
logger.change_status("Failed to collect Trophy Road rewards.")
return "restart"
Expand Down Expand Up @@ -126,18 +128,19 @@ def collect_trophy_road_rewards(vm_index, logger):
bool: True if rewards collection was successful or no rewards were available, False if an error occurred.
"""
print('running collect_trophy_road_rewards()')
rewards_collected = 0
# Click to potentially open the Trophy Road rewards menu.
click(vm_index, 210, 250)
time.sleep(2) # Wait for the menu to potentially open.

# Check if successfully entered the Trophy Road rewards menu.
if check_if_on_trophy_road_rewards_menu(vm_index):
logger.change_status("Successfully entered Trophy Road rewards menu.")
logger.change_status("Entered Trophy Road rewards menu...")
time.sleep(2)

# Loop until no more collect buttons are found or limit is reached
while find_collect_button(vm_index) != None:
while find_collect_button(vm_index) is not None:
collecting_attempts = 0
collect_side = find_collect_button(vm_index)
if collect_side == "left":
Expand Down Expand Up @@ -210,6 +213,7 @@ def find_collect_button(vm_index):

# Check the left position for expected colors.
left_pixel_color = iar[left_position[1]][left_position[0]]
# print('left_pixel_color',left_pixel_color)
if any(
pixel_is_equal(left_pixel_color, color, tol=35) for color in expected_colors
):
Expand All @@ -218,6 +222,7 @@ def find_collect_button(vm_index):

# Check the right position for expected colors.
right_pixel_color = iar[right_position[1]][right_position[0]]
print('right_pixel_color',right_pixel_color)
if any(
pixel_is_equal(right_pixel_color, color, tol=35) for color in expected_colors
):
Expand Down Expand Up @@ -312,4 +317,4 @@ def check_if_on_trophy_road_rewards_menu(vm_index):


if __name__ == "__main__":
pass
print(find_collect_button(1))

0 comments on commit e124547

Please sign in to comment.