1
0
mirror of https://github.com/TheFunny/ArisuAutoSweeper synced 2026-02-06 08:55:13 +00:00

Compare commits

..

No commits in common. "61fa6ad28b712de6d56a0f83a002103255ae8b79" and "96b5f1db8567aff2b82379951ec610eef72f6537" have entirely different histories.

16 changed files with 48 additions and 146 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -43,8 +43,7 @@
"Cafe": { "Cafe": {
"Reward": true, "Reward": true,
"Touch": true, "Touch": true,
"AutoAdjust": true, "AutoAdjust": true
"SecondCafe": true
} }
}, },
"Mail": { "Mail": {

View File

@ -128,14 +128,6 @@ class ModuleBase:
self.device.click(button) self.device.click(button)
return appear return appear
def click_with_interval(self, button, interval=5):
if interval and not self.interval_is_reached(button, interval=interval):
return False
self.device.click(button)
if interval:
self.interval_reset(button, interval=interval)
return True
def wait_until_stable(self, button, timer=Timer(0.3, count=1), timeout=Timer(5, count=10)): def wait_until_stable(self, button, timer=Timer(0.3, count=1), timeout=Timer(5, count=10)):
""" """
A terrible method, don't rely too much on it. A terrible method, don't rely too much on it.

View File

@ -194,10 +194,6 @@
"AutoAdjust": { "AutoAdjust": {
"type": "checkbox", "type": "checkbox",
"value": true "value": true
},
"SecondCafe": {
"type": "checkbox",
"value": true
} }
} }
}, },

View File

@ -79,7 +79,6 @@ Cafe:
Reward: true Reward: true
Touch: true Touch: true
AutoAdjust: true AutoAdjust: true
SecondCafe: true
TacticalChallenge: TacticalChallenge:
PlayerSelect: PlayerSelect:

View File

@ -43,7 +43,6 @@ class GeneratedConfig:
Cafe_Reward = True Cafe_Reward = True
Cafe_Touch = True Cafe_Touch = True
Cafe_AutoAdjust = True Cafe_AutoAdjust = True
Cafe_SecondCafe = True
# Group `TacticalChallenge` # Group `TacticalChallenge`
TacticalChallenge_PlayerSelect = 0 # 0, 1, 2, 3 TacticalChallenge_PlayerSelect = 0 # 0, 1, 2, 3

View File

@ -201,10 +201,6 @@
"AutoAdjust": { "AutoAdjust": {
"name": "Cafe.AutoAdjust.name", "name": "Cafe.AutoAdjust.name",
"help": "Cafe.AutoAdjust.help" "help": "Cafe.AutoAdjust.help"
},
"SecondCafe": {
"name": "Cafe.SecondCafe.name",
"help": "Cafe.SecondCafe.help"
} }
}, },
"TacticalChallenge": { "TacticalChallenge": {

View File

@ -201,10 +201,6 @@
"AutoAdjust": { "AutoAdjust": {
"name": "自动调整界面", "name": "自动调整界面",
"help": "在进行学生互动点击前对咖啡馆界面进行缩放和位置调整,以增加互动成功率" "help": "在进行学生互动点击前对咖啡馆界面进行缩放和位置调整,以增加互动成功率"
},
"SecondCafe": {
"name": "第二咖啡厅",
"help": "自动切换第二咖啡厅进行互动点击"
} }
}, },
"TacticalChallenge": { "TacticalChallenge": {

View File

@ -5,7 +5,7 @@ from tasks.base.assets.assets_base_page import LOADING_CHECK
class PopupHandler(ModuleBase): class PopupHandler(ModuleBase):
def handle_loading(self) -> bool: def handle_loading(self, interval=5) -> bool:
""" """
Args: Args:
interval: interval:
@ -13,7 +13,7 @@ class PopupHandler(ModuleBase):
Returns: Returns:
If handled. If handled.
""" """
if self.appear(LOADING_CHECK): if self.appear(LOADING_CHECK, interval=interval):
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) -> bool: def handle_reward(self, interval=5) -> bool:
""" """
Args: Args:
interval: interval:
@ -35,11 +35,13 @@ class PopupHandler(ModuleBase):
Returns: Returns:
If handled. If handled.
""" """
if self.appear(GET_REWARD) or self.match_color(GET_REWARD, threshold=30): if self.appear_then_click(GET_REWARD, interval=interval):
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
@ -50,13 +52,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=2) -> bool: def handle_daily_news(self, interval=5) -> 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=2) -> bool: def handle_daily_reward(self, interval=5) -> bool:
if self.appear_then_click(DAILY_REWARD, interval=interval): if self.appear_then_click(DAILY_REWARD, interval=interval):
return True return True
@ -68,12 +70,14 @@ class PopupHandler(ModuleBase):
return False return False
def handle_affection_level_up(self) -> bool: def handle_affection_level_up(self, interval=5) -> bool:
if self.appear_then_click(AFFECTION_LEVEL_UP): if self.appear_then_click(AFFECTION_LEVEL_UP, interval=interval):
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

View File

@ -13,46 +13,6 @@ BOX_CAFE = ButtonWrapper(
button=(33, 130, 1247, 569), button=(33, 130, 1247, 569),
), ),
) )
CAFE_FIRST = ButtonWrapper(
name='CAFE_FIRST',
jp=Button(
file='./assets/jp/cafe/CAFE_FIRST.png',
area=(82, 152, 136, 175),
search=(62, 132, 156, 195),
color=(111, 127, 147),
button=(82, 152, 136, 175),
),
)
CAFE_SECOND = ButtonWrapper(
name='CAFE_SECOND',
jp=Button(
file='./assets/jp/cafe/CAFE_SECOND.png',
area=(219, 152, 279, 175),
search=(199, 132, 299, 195),
color=(110, 126, 146),
button=(219, 152, 279, 175),
),
)
CHANGE_CAFE_NOT_SELECTED = ButtonWrapper(
name='CHANGE_CAFE_NOT_SELECTED',
jp=Button(
file='./assets/jp/cafe/CHANGE_CAFE_NOT_SELECTED.png',
area=(84, 89, 178, 109),
search=(64, 69, 198, 129),
color=(185, 193, 203),
button=(84, 89, 178, 109),
),
)
CHANGE_CAFE_SELECTED = ButtonWrapper(
name='CHANGE_CAFE_SELECTED',
jp=Button(
file='./assets/jp/cafe/CHANGE_CAFE_SELECTED.png',
area=(40, 87, 191, 112),
search=(20, 67, 211, 132),
color=(82, 105, 130),
button=(40, 87, 191, 112),
),
)
CHECK_REWARD = ButtonWrapper( CHECK_REWARD = ButtonWrapper(
name='CHECK_REWARD', name='CHECK_REWARD',
jp=Button( jp=Button(
@ -87,20 +47,20 @@ GET_REWARD_CLOSE = ButtonWrapper(
name='GET_REWARD_CLOSE', name='GET_REWARD_CLOSE',
jp=Button( jp=Button(
file='./assets/jp/cafe/GET_REWARD_CLOSE.png', file='./assets/jp/cafe/GET_REWARD_CLOSE.png',
area=(970, 134, 996, 160), area=(891, 144, 917, 170),
search=(950, 114, 1016, 180), search=(871, 124, 937, 190),
color=(172, 179, 188), color=(173, 179, 189),
button=(970, 134, 996, 160), button=(891, 144, 917, 170),
), ),
) )
GOT_REWARD = ButtonWrapper( GOT_REWARD = ButtonWrapper(
name='GOT_REWARD', name='GOT_REWARD',
jp=Button( jp=Button(
file='./assets/jp/cafe/GOT_REWARD.png', file='./assets/jp/cafe/GOT_REWARD.png',
area=(561, 501, 718, 556), area=(609, 507, 672, 535),
search=(541, 481, 738, 576), search=(589, 487, 692, 555),
color=(209, 210, 209), color=(174, 175, 174),
button=(561, 501, 718, 556), button=(609, 507, 672, 535),
), ),
) )
OCR_CAFE = ButtonWrapper( OCR_CAFE = ButtonWrapper(

View File

@ -7,21 +7,11 @@ from module.base.timer import Timer
from module.base.button import ClickButton from module.base.button import ClickButton
from module.base.utils.utils import area_offset from module.base.utils.utils import area_offset
from module.ocr.ocr import Digit from module.ocr.ocr import Digit
from module.ui.switch import Switch
from tasks.base.page import page_cafe from tasks.base.page import page_cafe
from tasks.base.ui import UI from tasks.base.ui import UI
from tasks.cafe.assets.assets_cafe import * from tasks.cafe.assets.assets_cafe import *
SWITCH_CAFE = Switch('Cafe_switch')
SWITCH_CAFE.add_state('off', CHANGE_CAFE_NOT_SELECTED)
SWITCH_CAFE.add_state('on', CHANGE_CAFE_SELECTED)
SWITCH_CAFE_SELECT = Switch('Cafe_switch_select')
SWITCH_CAFE_SELECT.add_state('1', CAFE_FIRST)
SWITCH_CAFE_SELECT.add_state('2', CAFE_SECOND)
class CafeStatus(Enum): class CafeStatus(Enum):
STUDENT_LIST = 0 STUDENT_LIST = 0
OCR = 1 OCR = 1
@ -71,7 +61,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, 80, cv2.BORDER_CONSTANT, value=(0, 0, 0)) image = cv2.copyMakeBorder(self.device.image, 20, 20, 10, 60, 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,18 +123,16 @@ 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.click_with_interval(GET_REWARD) self.device.click(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)
if not self.appear(GET_REWARD_CLOSE):
return CafeStatus.CLICK return CafeStatus.CLICK
case CafeStatus.CLICK: case CafeStatus.CLICK:
buttons = self._get_clickable_buttons(offset=(45, 10)) buttons = self._get_clickable_buttons(offset=(45, 10))
@ -152,7 +140,7 @@ class Cafe(UI):
logger.attr('Clickable', self.click) logger.attr('Clickable', self.click)
if not buttons: if not buttons:
return CafeStatus.CHECK return CafeStatus.CHECK
self.click_with_interval(buttons[0], interval=1) self.device.click(buttons[0])
case CafeStatus.CHECK: case CafeStatus.CHECK:
buttons = self._get_clickable_buttons() buttons = self._get_clickable_buttons()
if not self.is_adjust_on: if not self.is_adjust_on:
@ -188,22 +176,18 @@ class Cafe(UI):
is_reward_on = self.config.Cafe_Reward is_reward_on = self.config.Cafe_Reward
is_touch_on = self.config.Cafe_Touch is_touch_on = self.config.Cafe_Touch
self.is_adjust_on = self.config.Cafe_AutoAdjust self.is_adjust_on = self.config.Cafe_AutoAdjust
is_second_cafe_on = self.config.Cafe_SecondCafe
self.ui_ensure(page_cafe) self.ui_ensure(page_cafe)
status = CafeStatus.STUDENT_LIST status = CafeStatus.STUDENT_LIST
loading_timer = Timer(2).start() loading_timer = Timer(2).start()
action_timer = Timer(1, count=1) # cant be too fast action_timer = Timer(1.5, count=1) # cant be too fast
check_timer = Timer(1, count=1)
is_list = False is_list = False
is_reset = False is_reset = False
is_second = False
is_enable = is_reward_on or is_touch_on is_enable = is_reward_on or is_touch_on
while 1: while is_enable:
if not is_enable:
break
self.device.screenshot() self.device.screenshot()
if self.ui_additional(): if self.ui_additional():
@ -214,7 +198,7 @@ class Cafe(UI):
if not is_list and status == CafeStatus.STUDENT_LIST and self.appear(STUDENT_LIST): if not is_list and status == CafeStatus.STUDENT_LIST and self.appear(STUDENT_LIST):
is_list = True is_list = True
loading_timer = Timer(3).start() loading_timer = Timer(5).start()
continue continue
if not is_reward_on and status == CafeStatus.OCR: if not is_reward_on and status == CafeStatus.OCR:
@ -232,37 +216,14 @@ class Cafe(UI):
is_reset = True is_reset = True
continue continue
if is_second_cafe_on and not is_second and status == CafeStatus.FINISHED: if status == CafeStatus.CHECK and not check_timer.reached_and_reset():
if not SWITCH_CAFE.appear(main=self):
logger.warning('Cafe switch not found')
continue continue
if SWITCH_CAFE.get(main=self) == 'off':
SWITCH_CAFE.set('on', main=self)
logger.info('Switching to second cafe')
if not SWITCH_CAFE_SELECT.appear(main=self):
logger.info('Cafe switch select not found')
continue
match (SWITCH_CAFE_SELECT.get(main=self)):
case '1':
if self.click_with_interval(CAFE_SECOND):
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 action_timer.reached_and_reset(): if action_timer.reached_and_reset():
logger.attr('Status', status)
status = self._handle_cafe(status) status = self._handle_cafe(status)
logger.attr('Status', status)
if not is_second_cafe_on:
if status is CafeStatus.FINISHED: if status is CafeStatus.FINISHED:
break break
else:
if is_second and status is CafeStatus.FINISHED:
break
self.config.task_delay(server_update=True, minute=180) self.config.task_delay(server_update=True, minute=180)

View File

@ -47,8 +47,8 @@ class Circle(UI):
status = CircleStatus.GOT status = CircleStatus.GOT
if action_timer.reached_and_reset(): if action_timer.reached_and_reset():
logger.attr('Status', status)
status = self._handle_circle(status) status = self._handle_circle(status)
logger.attr('Status', status)
if status is CircleStatus.FINISHED: if status is CircleStatus.FINISHED:
break break

View File

@ -146,8 +146,8 @@ class TacticalChallenge(UI):
if not ui_timer.reached(): if not ui_timer.reached():
continue continue
if action_timer.reached_and_reset(): if action_timer.reached_and_reset():
logger.attr('Status', status.name)
status = self._handle_challenge(status) status = self._handle_challenge(status)
logger.attr('Status', status.name)
if status in (TCStatus.FINAL, TCStatus.FINISHED): if status in (TCStatus.FINAL, TCStatus.FINISHED):
break break