1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-04-03 12:19:41 +08:00

Fix: Confirm selected to the correct commission before starting it

This commit is contained in:
LmeSzinc
2022-03-10 12:13:53 +08:00
parent 0fe3cd65d6
commit 48295585ba

View File

@@ -59,6 +59,7 @@ class RewardCommission(UI, InfoHandler):
Returns: Returns:
SelectedGrids: SelectedGrids:
""" """
logger.hr('Commission detect')
commission = [] commission = []
for y in lines_detect(image): for y in lines_detect(image):
comm = Commission(image, y=y, config=self.config) comm = Commission(image, y=y, config=self.config)
@@ -155,6 +156,7 @@ class RewardCommission(UI, InfoHandler):
return False return False
def _commission_mode_reset(self): def _commission_mode_reset(self):
logger.hr('Commission mode reset')
if self.appear(COMMISSION_DAILY): if self.appear(COMMISSION_DAILY):
current, another = 'daily', 'urgent' current, another = 'daily', 'urgent'
elif self.appear(COMMISSION_URGENT): elif self.appear(COMMISSION_URGENT):
@@ -244,10 +246,14 @@ class RewardCommission(UI, InfoHandler):
Args: Args:
comm (Commission): comm (Commission):
Returns:
bool: If success
Pages: Pages:
in: page_commission in: page_commission
out: page_commission, info_bar, commission details unfold out: page_commission, info_bar, commission details unfold
""" """
logger.hr('Commission start')
self.interval_clear(COMMISSION_ADVICE) self.interval_clear(COMMISSION_ADVICE)
self.interval_clear(COMMISSION_START) self.interval_clear(COMMISSION_START)
comm_timer = Timer(7) comm_timer = Timer(7)
@@ -261,7 +267,19 @@ class RewardCommission(UI, InfoHandler):
if self.handle_popup_confirm(): if self.handle_popup_confirm():
comm_timer.reset() comm_timer.reset()
pass pass
if self.appear_then_click(COMMISSION_ADVICE, offset=(5, 20), interval=7): if self.appear(COMMISSION_ADVICE, offset=(5, 20), interval=7):
area = (0, 0, image_size(self.device.image)[0], COMMISSION_ADVICE.button[1])
current = self._commission_detect(crop(self.device.image, area))
if current.count >= 1:
current = current[0]
if current == comm:
logger.info('Selected to the correct commission')
else:
logger.warning('Selected to the wrong commission')
return False
else:
logger.warning('No selected commission detected, assuming correct')
self.device.click(COMMISSION_ADVICE)
count += 1 count += 1
comm_timer.reset() comm_timer.reset()
pass pass
@@ -289,33 +307,53 @@ class RewardCommission(UI, InfoHandler):
comm (Commission): comm (Commission):
is_urgent (bool): is_urgent (bool):
""" """
logger.hr('Commission find and start', level=2)
self.device.click_record_clear() self.device.click_record_clear()
comm = copy.deepcopy(comm) comm = copy.deepcopy(comm)
comm.repeat_count = 1 comm.repeat_count = 1
for _ in range(3):
logger.hr('Commission find and start', level=2)
logger.info(f'Finding commission {comm}') logger.info(f'Finding commission {comm}')
failed = True
for _ in range(15): for _ in range(15):
new = self._commission_detect(self.device.image) new = self._commission_detect(self.device.image)
if is_urgent: if is_urgent:
new.call('convert_to_night') # Convert extra commission to night new.call('convert_to_night') # Convert extra commission to night
if comm in new:
# Update commission position. # Update commission position.
# In different scans, they have the same information, but have different locations. # In different scans, they have the same information, but have different locations.
current = None
for new_comm in new: for new_comm in new:
if comm == new_comm: if new_comm == comm:
comm = new_comm current = new_comm
self._commission_start_click(comm) if current is not None:
if self._commission_start_click(current):
self.device.click_record_clear() self.device.click_record_clear()
return True return True
else:
self._commission_mode_reset()
self._commission_swipe_to_top()
failed = False
break
# End # End
if not self._commission_swipe(): if not self._commission_swipe():
break break
if failed:
logger.warning(f'Failed to select commission: {comm}')
self.device.click_record_clear()
continue
else:
logger.warning(f'Commission not found: {comm}') logger.warning(f'Commission not found: {comm}')
self.device.click_record_clear() self.device.click_record_clear()
return False return False
logger.warning(f'Failed to select commission after 3 trial')
self.device.click_record_clear()
return False
def commission_start(self): def commission_start(self):
""" """
Scan and Start all chosen commissions. Scan and Start all chosen commissions.