Zebartin 2023-06-22 13:51:50 +08:00
parent c2b935f946
commit e5c57dc9b0
6 changed files with 39 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -33,6 +33,16 @@ CHARACTER_1 = ButtonWrapper(
button=(116, 212, 206, 312),
),
)
CHARACTER_1_SELECTED = ButtonWrapper(
name='CHARACTER_1_SELECTED',
share=Button(
file='./assets/share/assignment/dispatch/CHARACTER_1_SELECTED.png',
area=(114, 207, 134, 225),
search=(94, 187, 154, 245),
color=(192, 204, 193),
button=(114, 207, 134, 225),
),
)
CHARACTER_2 = ButtonWrapper(
name='CHARACTER_2',
share=Button(
@ -43,6 +53,16 @@ CHARACTER_2 = ButtonWrapper(
button=(228, 211, 318, 311),
),
)
CHARACTER_2_SELECTED = ButtonWrapper(
name='CHARACTER_2_SELECTED',
share=Button(
file='./assets/share/assignment/dispatch/CHARACTER_2_SELECTED.png',
area=(226, 207, 245, 225),
search=(206, 187, 265, 245),
color=(179, 194, 187),
button=(226, 207, 245, 225),
),
)
CHARACTER_LIST = ButtonWrapper(
name='CHARACTER_LIST',
cn=Button(

View File

@ -64,12 +64,11 @@ class Assignment(AssignmentClaim, SynthesizeUI):
self.dispatched[assignment] = datetime.now() + Duration(
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
continue
if self.appear(EMPTY_SLOT):
if remain > 0:
self.dispatch(assignment, duration)
remain -= 1
else:
yield assignment
if remain > 0:
self.dispatch(assignment, duration)
remain -= 1
else:
yield assignment
def _check_all(self):
"""
@ -99,8 +98,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
self.dispatched[assignment] = datetime.now() + Duration(
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
continue
if self.appear(EMPTY_SLOT):
break
break
return remain
def _dispatch_remain(self, duration: int, remain: int):

View File

@ -47,25 +47,28 @@ class AssignmentDispatch(AssignmentUI):
out: CHARACTER_LIST
"""
skip_first_screenshot = True
click_timer = Timer(1, count=3).start()
list_timer = Timer(1, count=3)
select_timer = Timer(2, count=3)
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
# End
if not self.appear(EMPTY_SLOT):
logger.info('Assignment slots are all filled')
if self.match_template_color(CONFIRM_ASSIGNMENT):
logger.info('Characters are all selected')
break
# Ensure character list
if not self.appear(CHARACTER_LIST):
if click_timer.reached_and_reset():
if list_timer.reached_and_reset():
self.device.click(EMPTY_SLOT)
continue
# Select
if click_timer.reached_and_reset():
self.device.click(CHARACTER_1)
self.device.click(CHARACTER_2)
if select_timer.reached_and_reset():
if not self.image_color_count(CHARACTER_1_SELECTED, (240, 240, 240)):
self.device.click(CHARACTER_1)
if not self.image_color_count(CHARACTER_2_SELECTED, (240, 240, 240)):
self.device.click(CHARACTER_2)
def _select_duration(self, duration: int):
if duration not in {4, 8, 12, 20}:

View File

@ -155,10 +155,6 @@ class AssignmentUI(UI):
"""
Iterate entries from top to bottom
"""
while 1:
ASSIGNMENT_ENTRY_LIST.load_rows(self)
for button in ASSIGNMENT_ENTRY_LIST.cur_buttons:
yield button.matched_keyword
ASSIGNMENT_ENTRY_LIST.drag_page('down', self)
self.wait_until_stable(ASSIGNMENT_ENTRY_LIST.search_button, timer=Timer(
0, count=0), timeout=Timer(1.5, count=5))
ASSIGNMENT_ENTRY_LIST.load_rows(main=self)
for button in ASSIGNMENT_ENTRY_LIST.cur_buttons:
yield button.matched_keyword