Skip to content

Commit

Permalink
fixing check_vm_size(), adjusting GUI job increments
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmiglio committed Mar 10, 2024
1 parent d51005a commit 607e346
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
45 changes: 22 additions & 23 deletions src/pyclashbot/interface/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,8 @@ def make_job_increment_control_object(key):
)


job_increments_titles_column = [



controls = [

# whole box
[
# title column
sg.Column(
[
[sg.Text("Request Random Card Every:")],
[sg.Text("Donate Cards Every:")],
[sg.Text("Collect Free Offer Every:")],
Expand All @@ -38,7 +30,26 @@ def make_job_increment_control_object(key):
[sg.Text("Collect Battlepass Every:")],
[sg.Text("Collect Level Up Chest Every:")],
[sg.Text("Switch Account Every:")],
],

]


games_titles_column = [


]

for _ in range(len(job_increments_titles_column)):
games_titles_column.append([sg.Text("games")])


controls = [

# whole box
[
# title column
sg.Column(
job_increments_titles_column,
justification="left",
),
# input text column
Expand Down Expand Up @@ -82,19 +93,7 @@ def make_job_increment_control_object(key):
),
# end titles column
sg.Column(
[
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
[sg.Text("games")],
],
games_titles_column,
justification="left",
),
],
Expand Down
21 changes: 13 additions & 8 deletions src/pyclashbot/memu/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,26 @@

def check_vm_size(vm_index):
try:
home_button_press(vm_index,clicks=4)
home_button_press(vm_index,clicks=1)

image = screenshot(vm_index)
width, height = image.size
print(image.size)
print(image.shape)

height,width,_ = image.shape


if width != 419 or height != 633:
print(f"Size is bad: {width},{height}")
return False

print(f"Size is good: {width},{height}")
return True
except:
pass
except Exception as e:
print("sizing error:",e)

return False
#in the case of errors, just return True to avoid infinite loop
return True


def restart_emulator(logger, start_time=time.time(), open_clash=True):
Expand Down Expand Up @@ -77,6 +82,7 @@ def restart_emulator(logger, start_time=time.time(), open_clash=True):
logger.log("Error 99 Failed to skip ads")
return restart_emulator(logger, start_time)

print(check_vm_size(vm_index))
if not check_vm_size(vm_index):
logger.log("Error 1010 VM size is bad")
return restart_emulator(logger, start_time)
Expand Down Expand Up @@ -151,7 +157,7 @@ def check_for_vm(logger: Logger) -> int:
"""
start_time = time.time()

find_vm_timeout = 20 # s
find_vm_timeout = 10 # s
find_vm_start_time = time.time()
find_vm_tries = 0
while time.time() - find_vm_start_time < find_vm_timeout:
Expand Down Expand Up @@ -181,7 +187,7 @@ def check_for_vm(logger: Logger) -> int:
f"Created and configured new pyclashbot emulator in {str(time.time() - start_time)[:5]}s"
)

return create_vm()
return new_vm_index


def start_clash_royale(logger: Logger, vm_index):
Expand Down Expand Up @@ -448,5 +454,4 @@ def reset_clashbot_emulator(logger):


if __name__ == "__main__":
# reset_clashbot_emulator(logger)
pass

0 comments on commit 607e346

Please sign in to comment.