mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-16 13:57:26 +08:00
Fix: Enhance process able to get trapped in loop if current screenshot doesn't match any condition. If detected, will perform a force check/swipe if applicable. Applied similar concept to both versions of _enhance_choose*.
Update: Swipe process with additional internal delay and wait_until_stable to ensure image is screen captured at approriate time. Update: Keep sidebar click index positive otherwise can click back button. Add PRY condition with sidebar only having 3 buttons, disable clicking the Research button as not supported. Maybe in the future.
This commit is contained in:
@@ -19,13 +19,14 @@ class Equipment(UI):
|
||||
def _view_swipe(self, distance, check_button=EQUIPMENT_OPEN):
|
||||
swipe_count = 0
|
||||
swipe_timer = Timer(5, count=10)
|
||||
self.ensure_no_info_bar()
|
||||
self.ensure_no_info_bar(timeout=3)
|
||||
SWIPE_CHECK.load_color(self.device.image)
|
||||
while 1:
|
||||
if not swipe_timer.started() or swipe_timer.reached():
|
||||
swipe_timer.reset()
|
||||
self.device.swipe(vector=(distance, 0), box=SWIPE_AREA.area, random_range=SWIPE_RANDOM_RANGE,
|
||||
padding=0, duration=(0.1, 0.12), name='EQUIP_SWIPE')
|
||||
self.wait_until_stable(check_button)
|
||||
swipe_count += 1
|
||||
|
||||
self.device.screenshot()
|
||||
@@ -94,19 +95,26 @@ class Equipment(UI):
|
||||
break
|
||||
if not current:
|
||||
logger.warning('No ship details sidebar active.')
|
||||
if total == 4:
|
||||
if total == 3:
|
||||
current = 4 - current
|
||||
elif total == 4:
|
||||
current = 5 - current
|
||||
elif total == 5:
|
||||
current = 6 - current
|
||||
else:
|
||||
logger.warning('Ship details sidebar total count error.')
|
||||
return True
|
||||
|
||||
logger.attr('Detail_sidebar', f'{current}/{total}')
|
||||
if current == index:
|
||||
return False
|
||||
|
||||
self.device.click(DETAIL_SIDEBAR[0, total - index])
|
||||
diff = total - index
|
||||
if total == 3 and index == 3:
|
||||
logger.warning('Ship is PRY, equipment research not supported')
|
||||
elif diff >= 0:
|
||||
self.device.click(DETAIL_SIDEBAR[0, diff])
|
||||
else:
|
||||
logger.warning(f'Target index {index} cannot be clicked for this ship')
|
||||
return True
|
||||
|
||||
def equip_sidebar_ensure(self, index, skip_first_screenshot=True):
|
||||
@@ -136,7 +144,7 @@ class Equipment(UI):
|
||||
self.device.screenshot()
|
||||
|
||||
if self._equip_sidebar_click(index):
|
||||
if counter > 2:
|
||||
if counter >= 2:
|
||||
logger.warning('Sidebar could not be ensured')
|
||||
return False
|
||||
counter += 1
|
||||
|
||||
Reference in New Issue
Block a user