1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2025-12-16 19:55:12 +00:00

Compare commits

..

5 Commits

2 changed files with 46 additions and 49 deletions

View File

@ -5,7 +5,7 @@ from tasks.base.assets.assets_base_page import LOADING_CHECK
class PopupHandler(ModuleBase):
def handle_loading(self, interval=5) -> bool:
def handle_loading(self) -> bool:
"""
Args:
interval:
@ -13,7 +13,7 @@ class PopupHandler(ModuleBase):
Returns:
If handled.
"""
if self.appear(LOADING_CHECK, interval=interval):
if self.appear(LOADING_CHECK):
timer = Timer(0.5).start()
while 1:
if timer.reached_and_reset():
@ -27,7 +27,7 @@ class PopupHandler(ModuleBase):
return False
def handle_reward(self, interval=5) -> bool:
def handle_reward(self) -> bool:
"""
Args:
interval:
@ -35,15 +35,13 @@ class PopupHandler(ModuleBase):
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
@ -52,13 +50,13 @@ class PopupHandler(ModuleBase):
if self.appear_then_click(GET_REWARD_SKIP, interval=interval):
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):
return True
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):
return True
@ -70,16 +68,14 @@ class PopupHandler(ModuleBase):
return False
def handle_affection_level_up(self, interval=5) -> bool:
if self.appear_then_click(AFFECTION_LEVEL_UP, interval=interval):
timer = Timer(0.2).start()
def handle_affection_level_up(self) -> bool:
if self.appear_then_click(AFFECTION_LEVEL_UP):
while 1:
if timer.reached_and_reset():
self.device.screenshot()
if self.appear(AFFECTION_LEVEL_UP):
self.device.click(AFFECTION_LEVEL_UP)
else:
break
self.device.screenshot()
if self.appear(AFFECTION_LEVEL_UP):
self.click_with_interval(AFFECTION_LEVEL_UP, interval=1)
else:
break
return True
return False

View File

@ -71,7 +71,7 @@ class Cafe(UI):
return [point for point in zip(*loc[::-1])]
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)
points = self._match_clickable_points(image, threshold)
points = self.merge_points(points)
@ -133,8 +133,8 @@ class Cafe(UI):
if self.appear_then_click(CHECK_REWARD):
return CafeStatus.REWARD
case CafeStatus.REWARD:
if not self.appear(GET_REWARD):
self.click_with_interval(CHECK_REWARD, interval=6)
if not self.appear(GET_REWARD_CLOSE):
self.click_with_interval(CHECK_REWARD)
return status
if self.match_color(GOT_REWARD):
self.device.click(GET_REWARD_CLOSE)
@ -194,7 +194,7 @@ class Cafe(UI):
status = CafeStatus.STUDENT_LIST
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_reset = False
is_second = False
@ -209,6 +209,29 @@ class Cafe(UI):
if self.ui_additional():
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 not SWITCH_CAFE.appear(main=self):
logger.warning('Cafe switch not found')
@ -225,34 +248,12 @@ class Cafe(UI):
continue
case '2':
logger.info('Cafe second arrived')
SWITCH_CAFE.set('off', main=self)
status = CafeStatus.STUDENT_LIST
is_list = False
is_second = True
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():
logger.attr('Status', status)
status = self._handle_cafe(status)