mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 19:55:12 +00:00
Compare commits
5 Commits
79ea59d60c
...
61fa6ad28b
| Author | SHA1 | Date | |
|---|---|---|---|
| 61fa6ad28b | |||
| 0551207714 | |||
| 826a6b2348 | |||
| a05c4e8f2f | |||
| a20411071c |
@ -5,7 +5,7 @@ from tasks.base.assets.assets_base_page import LOADING_CHECK
|
|||||||
|
|
||||||
|
|
||||||
class PopupHandler(ModuleBase):
|
class PopupHandler(ModuleBase):
|
||||||
def handle_loading(self, interval=5) -> bool:
|
def handle_loading(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
interval:
|
interval:
|
||||||
@ -13,7 +13,7 @@ class PopupHandler(ModuleBase):
|
|||||||
Returns:
|
Returns:
|
||||||
If handled.
|
If handled.
|
||||||
"""
|
"""
|
||||||
if self.appear(LOADING_CHECK, interval=interval):
|
if self.appear(LOADING_CHECK):
|
||||||
timer = Timer(0.5).start()
|
timer = Timer(0.5).start()
|
||||||
while 1:
|
while 1:
|
||||||
if timer.reached_and_reset():
|
if timer.reached_and_reset():
|
||||||
@ -27,7 +27,7 @@ class PopupHandler(ModuleBase):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_reward(self, interval=5) -> bool:
|
def handle_reward(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
interval:
|
interval:
|
||||||
@ -35,15 +35,13 @@ class PopupHandler(ModuleBase):
|
|||||||
Returns:
|
Returns:
|
||||||
If handled.
|
If handled.
|
||||||
"""
|
"""
|
||||||
if self.appear_then_click(GET_REWARD, interval=interval):
|
if self.appear(GET_REWARD) or self.match_color(GET_REWARD, threshold=30):
|
||||||
timer = Timer(0.2).start()
|
|
||||||
while 1:
|
while 1:
|
||||||
if timer.reached_and_reset():
|
self.device.screenshot()
|
||||||
self.device.screenshot()
|
if self.appear(GET_REWARD) or self.match_color(GET_REWARD, threshold=30):
|
||||||
if self.appear(GET_REWARD):
|
self.click_with_interval(GET_REWARD, interval=0.5)
|
||||||
self.device.click(GET_REWARD)
|
else:
|
||||||
else:
|
break
|
||||||
break
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@ -52,13 +50,13 @@ class PopupHandler(ModuleBase):
|
|||||||
if self.appear_then_click(GET_REWARD_SKIP, interval=interval):
|
if self.appear_then_click(GET_REWARD_SKIP, interval=interval):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def handle_daily_news(self, interval=5) -> bool:
|
def handle_daily_news(self, interval=2) -> bool:
|
||||||
if self.appear_then_click(DAILY_NEWS, interval=interval):
|
if self.appear_then_click(DAILY_NEWS, interval=interval):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_daily_reward(self, interval=5) -> bool:
|
def handle_daily_reward(self, interval=2) -> bool:
|
||||||
if self.appear_then_click(DAILY_REWARD, interval=interval):
|
if self.appear_then_click(DAILY_REWARD, interval=interval):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -70,16 +68,14 @@ class PopupHandler(ModuleBase):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def handle_affection_level_up(self, interval=5) -> bool:
|
def handle_affection_level_up(self) -> bool:
|
||||||
if self.appear_then_click(AFFECTION_LEVEL_UP, interval=interval):
|
if self.appear_then_click(AFFECTION_LEVEL_UP):
|
||||||
timer = Timer(0.2).start()
|
|
||||||
while 1:
|
while 1:
|
||||||
if timer.reached_and_reset():
|
self.device.screenshot()
|
||||||
self.device.screenshot()
|
if self.appear(AFFECTION_LEVEL_UP):
|
||||||
if self.appear(AFFECTION_LEVEL_UP):
|
self.click_with_interval(AFFECTION_LEVEL_UP, interval=1)
|
||||||
self.device.click(AFFECTION_LEVEL_UP)
|
else:
|
||||||
else:
|
break
|
||||||
break
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class Cafe(UI):
|
|||||||
return [point for point in zip(*loc[::-1])]
|
return [point for point in zip(*loc[::-1])]
|
||||||
|
|
||||||
def _get_clickable_buttons(self, threshold=0.8, offset=(0, 0)):
|
def _get_clickable_buttons(self, threshold=0.8, offset=(0, 0)):
|
||||||
image = cv2.copyMakeBorder(self.device.image, 20, 20, 10, 60, cv2.BORDER_CONSTANT, value=(0, 0, 0))
|
image = cv2.copyMakeBorder(self.device.image, 20, 20, 10, 80, cv2.BORDER_CONSTANT, value=(0, 0, 0))
|
||||||
image = self._extract_clickable_from_image(image)
|
image = self._extract_clickable_from_image(image)
|
||||||
points = self._match_clickable_points(image, threshold)
|
points = self._match_clickable_points(image, threshold)
|
||||||
points = self.merge_points(points)
|
points = self.merge_points(points)
|
||||||
@ -133,13 +133,14 @@ class Cafe(UI):
|
|||||||
if self.appear_then_click(CHECK_REWARD):
|
if self.appear_then_click(CHECK_REWARD):
|
||||||
return CafeStatus.REWARD
|
return CafeStatus.REWARD
|
||||||
case CafeStatus.REWARD:
|
case CafeStatus.REWARD:
|
||||||
|
if not self.appear(GET_REWARD_CLOSE):
|
||||||
|
self.click_with_interval(CHECK_REWARD)
|
||||||
|
return status
|
||||||
if self.match_color(GOT_REWARD):
|
if self.match_color(GOT_REWARD):
|
||||||
self.device.click(GET_REWARD_CLOSE)
|
self.device.click(GET_REWARD_CLOSE)
|
||||||
return CafeStatus.GOT
|
return CafeStatus.GOT
|
||||||
if not self.appear(GET_REWARD):
|
|
||||||
return CafeStatus.OCR
|
|
||||||
if self.match_color(GET_REWARD):
|
if self.match_color(GET_REWARD):
|
||||||
self.device.click(GET_REWARD)
|
self.click_with_interval(GET_REWARD)
|
||||||
case CafeStatus.GOT:
|
case CafeStatus.GOT:
|
||||||
logger.info('Cafe reward have been got')
|
logger.info('Cafe reward have been got')
|
||||||
self.appear_then_click(GET_REWARD_CLOSE)
|
self.appear_then_click(GET_REWARD_CLOSE)
|
||||||
@ -193,7 +194,7 @@ class Cafe(UI):
|
|||||||
|
|
||||||
status = CafeStatus.STUDENT_LIST
|
status = CafeStatus.STUDENT_LIST
|
||||||
loading_timer = Timer(2).start()
|
loading_timer = Timer(2).start()
|
||||||
action_timer = Timer(1.5, count=1) # cant be too fast
|
action_timer = Timer(1, count=1) # cant be too fast
|
||||||
is_list = False
|
is_list = False
|
||||||
is_reset = False
|
is_reset = False
|
||||||
is_second = False
|
is_second = False
|
||||||
@ -208,6 +209,29 @@ class Cafe(UI):
|
|||||||
if self.ui_additional():
|
if self.ui_additional():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not loading_timer.reached():
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not is_list and status == CafeStatus.STUDENT_LIST and self.appear(STUDENT_LIST):
|
||||||
|
is_list = True
|
||||||
|
loading_timer = Timer(3).start()
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not is_reward_on and status == CafeStatus.OCR:
|
||||||
|
logger.info('Skip reward')
|
||||||
|
status = CafeStatus.CLICK
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not is_touch_on and status == CafeStatus.CLICK:
|
||||||
|
logger.info('Skip touch')
|
||||||
|
status = CafeStatus.FINISHED
|
||||||
|
continue
|
||||||
|
|
||||||
|
if is_touch_on and not is_reset and status == CafeStatus.CLICK:
|
||||||
|
self._reset_cafe_position('init')
|
||||||
|
is_reset = True
|
||||||
|
continue
|
||||||
|
|
||||||
if is_second_cafe_on and not is_second and status == CafeStatus.FINISHED:
|
if is_second_cafe_on and not is_second and status == CafeStatus.FINISHED:
|
||||||
if not SWITCH_CAFE.appear(main=self):
|
if not SWITCH_CAFE.appear(main=self):
|
||||||
logger.warning('Cafe switch not found')
|
logger.warning('Cafe switch not found')
|
||||||
@ -224,34 +248,12 @@ class Cafe(UI):
|
|||||||
continue
|
continue
|
||||||
case '2':
|
case '2':
|
||||||
logger.info('Cafe second arrived')
|
logger.info('Cafe second arrived')
|
||||||
|
SWITCH_CAFE.set('off', main=self)
|
||||||
status = CafeStatus.STUDENT_LIST
|
status = CafeStatus.STUDENT_LIST
|
||||||
is_list = False
|
is_list = False
|
||||||
is_second = True
|
is_second = True
|
||||||
self.check = 0
|
self.check = 0
|
||||||
|
|
||||||
if not loading_timer.reached():
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not is_list and status == CafeStatus.STUDENT_LIST and self.appear(STUDENT_LIST):
|
|
||||||
is_list = True
|
|
||||||
loading_timer = Timer(4).start()
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not is_reward_on and status == CafeStatus.OCR:
|
|
||||||
logger.info('Skip reward')
|
|
||||||
status = CafeStatus.CLICK
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not is_touch_on and status == CafeStatus.CLICK:
|
|
||||||
logger.info('Skip touch')
|
|
||||||
status = CafeStatus.FINISHED
|
|
||||||
continue
|
|
||||||
|
|
||||||
if is_touch_on and not is_reset and status == CafeStatus.CLICK:
|
|
||||||
self._reset_cafe_position('init')
|
|
||||||
is_reset = True
|
|
||||||
continue
|
|
||||||
|
|
||||||
if action_timer.reached_and_reset():
|
if action_timer.reached_and_reset():
|
||||||
logger.attr('Status', status)
|
logger.attr('Status', status)
|
||||||
status = self._handle_cafe(status)
|
status = self._handle_cafe(status)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user