mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: Character selecting in assignment
- https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235537186 - https://github.com/LmeSzinc/StarRailCopilot/pull/23#discussion_r1235549827
This commit is contained in:
parent
c2b935f946
commit
e5c57dc9b0
BIN
assets/share/assignment/dispatch/CHARACTER_1_SELECTED.png
Normal file
BIN
assets/share/assignment/dispatch/CHARACTER_1_SELECTED.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
BIN
assets/share/assignment/dispatch/CHARACTER_2_SELECTED.png
Normal file
BIN
assets/share/assignment/dispatch/CHARACTER_2_SELECTED.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
@ -33,6 +33,16 @@ CHARACTER_1 = ButtonWrapper(
|
|||||||
button=(116, 212, 206, 312),
|
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(
|
CHARACTER_2 = ButtonWrapper(
|
||||||
name='CHARACTER_2',
|
name='CHARACTER_2',
|
||||||
share=Button(
|
share=Button(
|
||||||
@ -43,6 +53,16 @@ CHARACTER_2 = ButtonWrapper(
|
|||||||
button=(228, 211, 318, 311),
|
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(
|
CHARACTER_LIST = ButtonWrapper(
|
||||||
name='CHARACTER_LIST',
|
name='CHARACTER_LIST',
|
||||||
cn=Button(
|
cn=Button(
|
||||||
|
@ -64,12 +64,11 @@ class Assignment(AssignmentClaim, SynthesizeUI):
|
|||||||
self.dispatched[assignment] = datetime.now() + Duration(
|
self.dispatched[assignment] = datetime.now() + Duration(
|
||||||
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
|
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
|
||||||
continue
|
continue
|
||||||
if self.appear(EMPTY_SLOT):
|
if remain > 0:
|
||||||
if remain > 0:
|
self.dispatch(assignment, duration)
|
||||||
self.dispatch(assignment, duration)
|
remain -= 1
|
||||||
remain -= 1
|
else:
|
||||||
else:
|
yield assignment
|
||||||
yield assignment
|
|
||||||
|
|
||||||
def _check_all(self):
|
def _check_all(self):
|
||||||
"""
|
"""
|
||||||
@ -99,8 +98,7 @@ class Assignment(AssignmentClaim, SynthesizeUI):
|
|||||||
self.dispatched[assignment] = datetime.now() + Duration(
|
self.dispatched[assignment] = datetime.now() + Duration(
|
||||||
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
|
OCR_ASSIGNMENT_TIME).ocr_single_line(self.device.image)
|
||||||
continue
|
continue
|
||||||
if self.appear(EMPTY_SLOT):
|
break
|
||||||
break
|
|
||||||
return remain
|
return remain
|
||||||
|
|
||||||
def _dispatch_remain(self, duration: int, remain: int):
|
def _dispatch_remain(self, duration: int, remain: int):
|
||||||
|
@ -47,25 +47,28 @@ class AssignmentDispatch(AssignmentUI):
|
|||||||
out: CHARACTER_LIST
|
out: CHARACTER_LIST
|
||||||
"""
|
"""
|
||||||
skip_first_screenshot = True
|
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:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
skip_first_screenshot = False
|
skip_first_screenshot = False
|
||||||
else:
|
else:
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
# End
|
# End
|
||||||
if not self.appear(EMPTY_SLOT):
|
if self.match_template_color(CONFIRM_ASSIGNMENT):
|
||||||
logger.info('Assignment slots are all filled')
|
logger.info('Characters are all selected')
|
||||||
break
|
break
|
||||||
# Ensure character list
|
# Ensure character list
|
||||||
if not self.appear(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)
|
self.device.click(EMPTY_SLOT)
|
||||||
continue
|
continue
|
||||||
# Select
|
# Select
|
||||||
if click_timer.reached_and_reset():
|
if select_timer.reached_and_reset():
|
||||||
self.device.click(CHARACTER_1)
|
if not self.image_color_count(CHARACTER_1_SELECTED, (240, 240, 240)):
|
||||||
self.device.click(CHARACTER_2)
|
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):
|
def _select_duration(self, duration: int):
|
||||||
if duration not in {4, 8, 12, 20}:
|
if duration not in {4, 8, 12, 20}:
|
||||||
|
@ -155,10 +155,6 @@ class AssignmentUI(UI):
|
|||||||
"""
|
"""
|
||||||
Iterate entries from top to bottom
|
Iterate entries from top to bottom
|
||||||
"""
|
"""
|
||||||
while 1:
|
ASSIGNMENT_ENTRY_LIST.load_rows(main=self)
|
||||||
ASSIGNMENT_ENTRY_LIST.load_rows(self)
|
for button in ASSIGNMENT_ENTRY_LIST.cur_buttons:
|
||||||
for button in ASSIGNMENT_ENTRY_LIST.cur_buttons:
|
yield button.matched_keyword
|
||||||
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))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user