Skip to content

Commit

Permalink
Extend account switching to 8 accounts (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stredy authored Dec 21, 2023
1 parent ba3ea29 commit bf4125e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions src/pyclashbot/bot/account_switching.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/pyclashbot/interface/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
Expand Down

0 comments on commit bf4125e

Please # to comment.