From bf4125ead0f27de1142fb5d36ad00f61046e4ff8 Mon Sep 17 00:00:00 2001 From: Stredy <154539352+Stredy@users.noreply.github.com> Date: Thu, 21 Dec 2023 18:55:46 +0100 Subject: [PATCH] Extend account switching to 8 accounts (#348) --- src/pyclashbot/bot/account_switching.py | 27 ++++++++++++++++++++----- src/pyclashbot/interface/layout.py | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/pyclashbot/bot/account_switching.py b/src/pyclashbot/bot/account_switching.py index 618d01e78..66151137b 100644 --- a/src/pyclashbot/bot/account_switching.py +++ b/src/pyclashbot/bot/account_switching.py @@ -1,14 +1,22 @@ from pyclashbot.bot.nav import check_if_on_clash_main_menu, wait_for_clash_main_menu -from pyclashbot.memu.client import click, save_screenshot +from pyclashbot.memu.client import click, save_screenshot, send_swipe import time SSID_COORDS = [ - (48, 305), - (48, 387), - (53, 471), - (48, 553), + (48, 305), # 1st account, index 0 + (48, 387), # 2nd account, index 1 + (48, 471), # 3rd account, index 2 + (48, 553), # 4th account, index 3 + (48, 631), # 5th account, index 4 + (48, 631), # 6th account, index 5 + (48, 631), # 7th account, index 6 + (48, 631), # 8th account, index 7 ] +def custom_swipe(vm_index, start_x, start_y, end_x, end_y, repeat, delay): + for _ in range(repeat): + send_swipe(vm_index, start_x, start_y, end_x, end_y) + time.sleep(delay) def switch_accounts(vm_index, logger, account_index_to_switch_to): logger.add_switch_account_attempt() @@ -28,6 +36,15 @@ def switch_accounts(vm_index, logger, account_index_to_switch_to): click(vm_index, 221, 368) time.sleep(4) + # Perform the scrolling + logger.change_status(f"Scrolling down to reach account #{account_index_to_switch_to}") + if account_index_to_switch_to == 5: # 6th account + custom_swipe(vm_index, 215, 400, 215, 350, 2, 1) + elif account_index_to_switch_to == 6: # 7th account + custom_swipe(vm_index, 215, 400, 215, 350, 4, 1) + elif account_index_to_switch_to == 7: # 8th account + custom_swipe(vm_index, 215, 400, 215, 350, 6, 1) + # click the account index in question account_coord = SSID_COORDS[account_index_to_switch_to] logger.change_status( diff --git a/src/pyclashbot/interface/layout.py b/src/pyclashbot/interface/layout.py index b8b6d949f..e872bd257 100644 --- a/src/pyclashbot/interface/layout.py +++ b/src/pyclashbot/interface/layout.py @@ -116,7 +116,7 @@ def get_random_donate_image_path(): default=False, ), sg.Slider( - range=(1, 4), + range=(1, 8), orientation="h", key="account_switching_slider", ),