mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2026-06-09 20:04:52 +00:00
feat: add support for second cafe
This commit is contained in:
@@ -13,6 +13,46 @@ BOX_CAFE = ButtonWrapper(
|
||||
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(
|
||||
name='CHECK_REWARD',
|
||||
jp=Button(
|
||||
@@ -47,20 +87,20 @@ GET_REWARD_CLOSE = ButtonWrapper(
|
||||
name='GET_REWARD_CLOSE',
|
||||
jp=Button(
|
||||
file='./assets/jp/cafe/GET_REWARD_CLOSE.png',
|
||||
area=(891, 144, 917, 170),
|
||||
search=(871, 124, 937, 190),
|
||||
color=(173, 179, 189),
|
||||
button=(891, 144, 917, 170),
|
||||
area=(970, 134, 996, 160),
|
||||
search=(950, 114, 1016, 180),
|
||||
color=(172, 179, 188),
|
||||
button=(970, 134, 996, 160),
|
||||
),
|
||||
)
|
||||
GOT_REWARD = ButtonWrapper(
|
||||
name='GOT_REWARD',
|
||||
jp=Button(
|
||||
file='./assets/jp/cafe/GOT_REWARD.png',
|
||||
area=(609, 507, 672, 535),
|
||||
search=(589, 487, 692, 555),
|
||||
color=(174, 175, 174),
|
||||
button=(609, 507, 672, 535),
|
||||
area=(561, 501, 718, 556),
|
||||
search=(541, 481, 738, 576),
|
||||
color=(209, 210, 209),
|
||||
button=(561, 501, 718, 556),
|
||||
),
|
||||
)
|
||||
OCR_CAFE = ButtonWrapper(
|
||||
|
||||
+43
-3
@@ -7,11 +7,21 @@ from module.base.timer import Timer
|
||||
from module.base.button import ClickButton
|
||||
from module.base.utils.utils import area_offset
|
||||
from module.ocr.ocr import Digit
|
||||
from module.ui.switch import Switch
|
||||
from tasks.base.page import page_cafe
|
||||
from tasks.base.ui import UI
|
||||
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):
|
||||
STUDENT_LIST = 0
|
||||
OCR = 1
|
||||
@@ -177,6 +187,7 @@ class Cafe(UI):
|
||||
is_reward_on = self.config.Cafe_Reward
|
||||
is_touch_on = self.config.Cafe_Touch
|
||||
self.is_adjust_on = self.config.Cafe_AutoAdjust
|
||||
is_second_cafe_on = self.config.Cafe_SecondCafe
|
||||
|
||||
self.ui_ensure(page_cafe)
|
||||
|
||||
@@ -186,14 +197,39 @@ class Cafe(UI):
|
||||
check_timer = Timer(1, count=1)
|
||||
is_list = False
|
||||
is_reset = False
|
||||
is_second = False
|
||||
is_enable = is_reward_on or is_touch_on
|
||||
|
||||
while is_enable:
|
||||
while 1:
|
||||
if not is_enable:
|
||||
break
|
||||
|
||||
self.device.screenshot()
|
||||
|
||||
if self.ui_additional():
|
||||
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')
|
||||
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')
|
||||
status = CafeStatus.STUDENT_LIST
|
||||
is_list = False
|
||||
is_second = True
|
||||
self.check = 0
|
||||
|
||||
if not loading_timer.reached():
|
||||
continue
|
||||
|
||||
@@ -224,7 +260,11 @@ class Cafe(UI):
|
||||
status = self._handle_cafe(status)
|
||||
logger.attr('Status', status)
|
||||
|
||||
if status is CafeStatus.FINISHED:
|
||||
break
|
||||
if not is_second_cafe_on:
|
||||
if status is CafeStatus.FINISHED:
|
||||
break
|
||||
else:
|
||||
if is_second and status is CafeStatus.FINISHED:
|
||||
break
|
||||
|
||||
self.config.task_delay(server_update=True, minute=180)
|
||||
|
||||
Reference in New Issue
Block a user