Skip to content

Commit

Permalink
perf(popup): improve reward handle stability
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFunny committed Nov 4, 2023
1 parent 0551207 commit 61fa6ad
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tasks/base/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@ def handle_loading(self) -> bool:

return False

def handle_reward(self, interval=5) -> bool:
def handle_reward(self) -> bool:
"""
Args:
interval:
Returns:
If handled.
"""
if self.appear_then_click(GET_REWARD, interval=interval):
timer = Timer(0.2).start()
if self.appear(GET_REWARD) or self.match_color(GET_REWARD, threshold=30):
while 1:
if timer.reached_and_reset():
self.device.screenshot()
if self.appear(GET_REWARD):
self.device.click(GET_REWARD)
else:
break
self.device.screenshot()
if self.appear(GET_REWARD) or self.match_color(GET_REWARD, threshold=30):
self.click_with_interval(GET_REWARD, interval=0.5)
else:
break
return True

return False
Expand Down

0 comments on commit 61fa6ad

Please sign in to comment.