mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 12:07:36 +08:00
Fix: _get_stage_name should before handle_get_chapter_additional (#4094)
so loop can be break
This commit is contained in:
parent
f12ccb87ef
commit
c9349b1bba
@ -331,28 +331,33 @@ class CampaignOcr(ModuleBase):
|
||||
logger.warning(f'get_chapter_index: WITHDRAW appears')
|
||||
raise CampaignNameError
|
||||
|
||||
def get_chapter_index(self, image):
|
||||
def get_chapter_index(self, skip_first_screenshot=True):
|
||||
"""
|
||||
A tricky method for ui_ensure_index
|
||||
|
||||
Args:
|
||||
image: Screenshot
|
||||
skip_first_screenshot:
|
||||
|
||||
Returns:
|
||||
int: Chapter index.
|
||||
"""
|
||||
timeout = Timer(2, count=4).start()
|
||||
while 1:
|
||||
if skip_first_screenshot:
|
||||
skip_first_screenshot = False
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if timeout.reached():
|
||||
raise CampaignNameError
|
||||
if self.handle_get_chapter_additional():
|
||||
continue
|
||||
image = self.device.image
|
||||
try:
|
||||
self._get_stage_name(image)
|
||||
break
|
||||
except (IndexError, CampaignNameError):
|
||||
self.device.screenshot()
|
||||
image = self.device.image
|
||||
pass
|
||||
|
||||
if self.handle_get_chapter_additional():
|
||||
continue
|
||||
|
||||
return self._campaign_get_chapter_index(self.campaign_chapter)
|
||||
|
@ -49,7 +49,7 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
if self.handle_chapter_additional():
|
||||
continue
|
||||
|
||||
current = self.get_chapter_index(self.device.image)
|
||||
current = self.get_chapter_index()
|
||||
|
||||
logger.attr("Index", current)
|
||||
diff = index - current
|
||||
|
Loading…
Reference in New Issue
Block a user