1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-08-19 04:50:43 +08:00

Fix: ensure dock top before finding island character (#5890)

This commit is contained in:
guoh064
2026-08-16 14:19:00 +08:00
parent 16ef6e3dae
commit 1789952e94
3 changed files with 33 additions and 15 deletions

View File

@@ -229,6 +229,8 @@ class IslandProduction(IslandRecipe, IslandDock):
logger.warning(f'Failed to select character {worker} for slot {slot_id}, try to select manjuu instead')
worker = 'manjuu'
self.ensure_dock_page_at_top()
else:
self.island_dock_select_one(character.button)
if worker == 'manjuu':
self.island_dock_select_manjuu()
self.island_dock_select_confirm(self.is_in_recipe_menu)

View File

@@ -97,13 +97,17 @@ class IslandDock(IslandUI):
def ensure_dock_page_at_top(self):
ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=10):
self.prev_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached top of dock page')
return True
if drag_count >= 2:
logger.info('Reached top of dock page')
return True
else:
ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
return False
def island_dock_select_one(self, button, skip_first=False):
@@ -137,6 +141,7 @@ class IslandDock(IslandUI):
def island_dock_select_manjuu(self):
self.island_dock_sort_method_dsc_set(enable=False, wait_loading=True)
# self.ensure_dock_page_at_top() # not necessary for now since usually Manjuu is searched first
scanner = CharacterScanner(self.dock_grid, identity=['Manjuu'], status='free')
candidates = scanner.scan(self.device.image)
if candidates:
@@ -147,9 +152,11 @@ class IslandDock(IslandUI):
return False
def island_dock_find_character(self, identity):
self.ensure_dock_page_at_top()
self.island_dock_sort_method_dsc_set(enable=True)
ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=40, skip_first=False):
# dock_grid needs refresh after each page swipe, so we need to get a new scanner each time
scanner = CharacterScanner(self.dock_grid, identity=identity, status=None)
@@ -159,19 +166,24 @@ class IslandDock(IslandUI):
continue
return candidate
self.next_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached end of dock page')
break
if drag_count >= 2:
logger.warning('Reached end of dock page')
break
else:
ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
else:
logger.warning('Failed to find all requested characters')
return None
def island_dock_select_character_with_blacklist(self, blacklist):
def island_dock_find_character_with_blacklist(self, blacklist):
self.ensure_dock_page_at_top()
self.island_dock_sort_method_dsc_set(enable=True)
ISLAND_DOCK_DETECT.load_color(self.device.image)
ISLAND_DOCK_DETECT._match_init = True
drag_count = 0
for _ in self.loop(timeout=40, skip_first=False):
# dock_grid needs refresh after each page swipe, so we need to get a new scanner each time
scanner = CharacterScanner(self.dock_grid, identity='any', status='free')
@@ -191,13 +203,15 @@ class IslandDock(IslandUI):
elif self.is_button_selected(candidate.button, color=(19, 181, 231)):
continue
else:
self.island_dock_select_one(candidate.button)
return candidate.identity
return candidate
self.next_dock_page()
drag_count += 1
if self.appear(ISLAND_DOCK_DETECT, offset=(20, 20)):
logger.warning('Reached end of dock page')
break
if drag_count >= 2:
logger.warning('Reached end of dock page')
break
else:
ISLAND_DOCK_DETECT.load_color(self.device.image)
drag_count = 0
logger.warning('Failed to find any character not in blacklist')
return None

View File

@@ -397,19 +397,21 @@ class IslandRestaurant(IslandDock):
| selected_waitresses
| all_named_waitresses
)
selected = self.island_dock_select_character_with_blacklist(fallback_blacklist)
if selected is None:
candidate = self.island_dock_find_character_with_blacklist(fallback_blacklist)
if candidate is None:
success = False
else:
selected_waitresses.add(selected)
self.island_dock_select_one(candidate.button)
selected_waitresses.add(candidate.identity)
for _ in range(active_waitresses.count(WAITRESS_ANY)):
blacklist = unavailable_waitress_list | selected_waitresses | all_named_waitresses
selected = self.island_dock_select_character_with_blacklist(blacklist)
if selected is None:
candidate = self.island_dock_find_character_with_blacklist(blacklist)
if candidate is None:
success = False
else:
selected_waitresses.add(selected)
self.island_dock_select_one(candidate.button)
selected_waitresses.add(candidate.identity)
if not success:
logger.warning("Failed to choose waitress")
self.ui_back(check_button=self.is_in_island_restaurant)