Skip to content

Commit

Permalink
perf: sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
moesnow committed Oct 14, 2023
1 parent eb03563 commit 1f75eb3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions assets/config/screens.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@
"image",
0.95
]
},
{
"action": "time.sleep",
"args": [
1
]
}
]
},
Expand Down
1 change: 0 additions & 1 deletion module/automation/automation.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def click_element_with_pos(self, coordinates, offset=(0, 0), action="click"):
(left, top), (right, bottom) = coordinates
x = (left + right) // 2 + offset[0]
y = (top + bottom) // 2 + offset[1]
time.sleep(0.5)
if action == "click":
self.mouse_click(x, y)
elif action == "down":
Expand Down
4 changes: 3 additions & 1 deletion module/screen/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ def change_to(self, target_screen, max_recursion=2):
if action["target_screen"] == next_screen][0]
self.perform_operations(operations)

for i in range(10):
for i in range(20):
logger.debug(_("等待:{next_screen}").format(next_screen=self.get_name(next_screen)))
if self.check_screen(next_screen):
break
else:
time.sleep(0.5)

if self.current_screen != next_screen:
if max_recursion > 0:
Expand Down
4 changes: 2 additions & 2 deletions tasks/power/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ def run_instances(instance_type, instance_name, power_need, number):

screen.change_to('guide3')
instance_type_crop = (262.0 / 1920, 289.0 / 1080, 422.0 / 1920, 624.0 / 1080)
if not auto.click_element(instance_type, "text", crop=instance_type_crop, take_screenshot=False):
if not auto.click_element(instance_type, "text", crop=instance_type_crop):
if auto.click_element("侵蚀隧洞", "text", max_retries=10, crop=instance_type_crop):
auto.mouse_scroll(12, -1)
auto.click_element(instance_type, "text", crop=instance_type_crop, take_screenshot=True)
auto.click_element(instance_type, "text", crop=instance_type_crop)
# 截图过快会导致结果不可信
time.sleep(1)

Expand Down
2 changes: 1 addition & 1 deletion tasks/reward/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ def _click_complete_dispatch(crop):
# width, height = auto.get_image_info("./assets/images/dispatch/reward.png")
# offset = (-2 * width, 2 * height)
offset = (-34, 34) # 以后改相对坐标偏移
return auto.click_element("./assets/images/dispatch/reward.png", "image", 0.9, max_retries=5, offset=offset, crop=crop)
return auto.click_element("./assets/images/dispatch/reward.png", "image", 0.9, max_retries=8, offset=offset, crop=crop)

0 comments on commit 1f75eb3

Please sign in to comment.