mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-04-03 12:21:21 +08:00
Fix: Getting index of a digit chapter when looking for a non-digit chapter (#4504)
This commit is contained in:
parent
40a9e901e2
commit
2176fdf803
@ -27,7 +27,7 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
|
||||
@ -39,11 +39,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in ['t', 'ts', 'ht', 'hts']:
|
||||
self.ui_goto_event()
|
||||
@ -60,7 +60,7 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
# Get stage
|
||||
self.campaign_ensure_chapter(index=1)
|
||||
self.campaign_ensure_chapter(1)
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
||||
|
@ -44,10 +44,10 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in 'abcd' or chapter == 'ex_sp':
|
||||
self.ui_goto_event()
|
||||
@ -57,11 +57,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
pass # Difference
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_event() # Difference
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
@ -54,7 +54,7 @@ class CampaignBase(CampaignBase_):
|
||||
|
||||
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
|
||||
def campaign_get_entrance(self, name):
|
||||
|
@ -15,10 +15,10 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_weigh_anchor()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in 'abcd' or chapter == 'ex_sp' or chapter in ['as', 'cs']:
|
||||
self.ui_goto_event()
|
||||
@ -28,11 +28,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
@ -72,10 +72,10 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in ['a', 'b', 'c', 'd', 'ex_sp', 'as', 'bs', 'cs', 'ds']:
|
||||
self.ui_goto_event()
|
||||
@ -86,12 +86,12 @@ class CampaignBase(CampaignBase_):
|
||||
elif chapter == 'ex_sp':
|
||||
# self.campaign_ensure_mode('ex')
|
||||
pass # Difference
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
# self.ui_goto_sp()
|
||||
self.ui_goto_event() # Difference
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
@ -5,7 +5,7 @@ class CampaignBase(CampaignBase_):
|
||||
def campaign_set_chapter_sp(self, chapter, mode='normal'):
|
||||
if chapter == 'sp':
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -8,7 +8,7 @@ class CampaignBase(CampaignBase_):
|
||||
logger.info('Set chapter SP')
|
||||
if chapter in ['sp', 'sp_sp']:
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -15,7 +15,7 @@ class CampaignBase(CampaignBase_):
|
||||
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
||||
if chapter.startswith('t'):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
|
||||
return super().campaign_set_chapter_event(chapter, mode=mode)
|
||||
|
@ -29,7 +29,7 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
|
||||
@ -41,11 +41,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in ['t', 'ts', 'ht', 'hts']:
|
||||
self.ui_goto_event()
|
||||
@ -68,7 +68,7 @@ class CampaignBase(CampaignBase_):
|
||||
else:
|
||||
self._campaign_ball_set('red')
|
||||
# Get stage
|
||||
self.campaign_ensure_chapter(index=1)
|
||||
self.campaign_ensure_chapter(1)
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
||||
|
@ -13,7 +13,7 @@ class CampaignBase(CampaignBase_):
|
||||
|
||||
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
|
||||
def _campaign_get_chapter_index(self, name):
|
||||
|
@ -13,7 +13,7 @@ class CampaignBase(CampaignBase_):
|
||||
|
||||
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
|
||||
def _campaign_get_chapter_index(self, name):
|
||||
|
@ -14,7 +14,7 @@ class CampaignBase(CampaignBase_):
|
||||
|
||||
def campaign_set_chapter_event(self, chapter, mode='normal'):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
|
||||
def _campaign_get_chapter_index(self, name):
|
||||
|
@ -42,6 +42,6 @@ class CampaignBase(CampaignBase_):
|
||||
ASIDE_SWITCH_20241219.set('part2', main=self)
|
||||
else:
|
||||
logger.warning(f'Stage {chapter}{stage} is not in event_20241024')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
return super().campaign_set_chapter_20241219(chapter, stage, mode)
|
||||
|
@ -26,11 +26,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.ui_goto_event()
|
||||
MODE_SWITCH_20241219.set('combat', main=self)
|
||||
ASIDE_SWITCH_20241219.set('part1', main=self)
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if chapter == 'ttl':
|
||||
self.ui_goto_event()
|
||||
MODE_SWITCH_20241219.set('combat', main=self)
|
||||
ASIDE_SWITCH_20241219.set('part2', main=self)
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
return super().campaign_set_chapter_20241219(chapter, stage, mode)
|
||||
|
@ -25,10 +25,10 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in 'abcd' or chapter == 'ex_sp' or chapter in ['as', 'cs']:
|
||||
self.ui_goto_event()
|
||||
@ -38,11 +38,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
@ -27,7 +27,7 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
|
||||
@ -39,11 +39,11 @@ class CampaignBase(CampaignBase_):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
|
||||
elif chapter in ['t', 'ts', 'ht', 'hts']:
|
||||
self.ui_goto_event()
|
||||
@ -60,7 +60,7 @@ class CampaignBase(CampaignBase_):
|
||||
if chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
# Get stage
|
||||
self.campaign_ensure_chapter(index=1)
|
||||
self.campaign_ensure_chapter(1)
|
||||
else:
|
||||
logger.warning(f'Unknown campaign chapter: {name}')
|
||||
|
||||
|
@ -13,7 +13,7 @@ from module.template.assets import *
|
||||
|
||||
class CampaignOcr(ModuleBase):
|
||||
stage_entrance = {}
|
||||
campaign_chapter = 0
|
||||
campaign_chapter: str = '0'
|
||||
# An approximate area where stages will appear for faster template matching
|
||||
_stage_detect_area = (87, 117, 1151, 636)
|
||||
|
||||
|
@ -36,16 +36,33 @@ ASIDE_SWITCH_20241219.add_state('sp', CHAPTER_20241219_SP)
|
||||
ASIDE_SWITCH_20241219.add_state('ex', CHAPTER_20241219_EX)
|
||||
|
||||
|
||||
def is_digit_chapter(chapter):
|
||||
"""
|
||||
Args:
|
||||
chapter (int, str): Chapter. Such as 7, 'd', 'sp'.
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
if isinstance(chapter, int):
|
||||
return True
|
||||
try:
|
||||
return chapter[0].isdigit()
|
||||
except IndexError:
|
||||
return False
|
||||
|
||||
|
||||
class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
ENTRANCE = Button(area=(), color=(), button=(), name='default_button')
|
||||
|
||||
def campaign_ensure_chapter(self, index, skip_first_screenshot=True):
|
||||
def campaign_ensure_chapter(self, chapter, skip_first_screenshot=True):
|
||||
"""
|
||||
Args:
|
||||
index (int, str): Chapter. Such as 7, 'd', 'sp'.
|
||||
chapter (int, str): Chapter. Such as 7, 'd', 'sp'.
|
||||
skip_first_screenshot:
|
||||
"""
|
||||
index = self._campaign_get_chapter_index(index)
|
||||
index = self._campaign_get_chapter_index(chapter)
|
||||
isdigit = is_digit_chapter(chapter)
|
||||
|
||||
# A copy of use ui_ensure_index.
|
||||
logger.hr("UI ensure index")
|
||||
@ -61,12 +78,17 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
continue
|
||||
|
||||
current = self.get_chapter_index()
|
||||
current_isdigit = is_digit_chapter(self.campaign_chapter)
|
||||
|
||||
logger.attr("Index", current)
|
||||
diff = index - current
|
||||
if diff == 0:
|
||||
break
|
||||
|
||||
# Getting 3-7 when looking for D3
|
||||
if not (isdigit == current_isdigit):
|
||||
continue
|
||||
|
||||
# 14-4 may be OCR as 4-1 due to slow animation, confirm if it is 4-1
|
||||
if index >= 11 and index % 10 == current:
|
||||
error_confirm.start()
|
||||
@ -214,13 +236,13 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
if chapter.isdigit():
|
||||
self.ui_goto_campaign()
|
||||
self.campaign_ensure_mode('normal')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
if mode == 'hard':
|
||||
self.campaign_ensure_mode('hard')
|
||||
# info_bar shows: Hard mode for this map is not available yet.
|
||||
# There's also a game bug in EN, HM12 shows not available but it's actually available.
|
||||
self.handle_info_bar()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -234,7 +256,7 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
self.campaign_ensure_mode('hard')
|
||||
elif chapter == 'ex_sp':
|
||||
self.campaign_ensure_mode('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -242,7 +264,7 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
def campaign_set_chapter_sp(self, chapter, mode='normal'):
|
||||
if chapter == 'sp':
|
||||
self.ui_goto_sp()
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -261,25 +283,25 @@ class CampaignUI(MapOperation, CampaignEvent, CampaignOcr):
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_mode_20241219('combat')
|
||||
self.campaign_ensure_aside_20241219('part1')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
if chapter in ['b', 'd', 'ttl']:
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_mode_20241219('combat')
|
||||
self.campaign_ensure_aside_20241219('part2')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
if chapter in ['ex_sp']:
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_mode_20241219('combat')
|
||||
self.campaign_ensure_aside_20241219('sp')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
if chapter in ['ex_ex']:
|
||||
self.ui_goto_event()
|
||||
self.campaign_ensure_mode_20241219('combat')
|
||||
self.campaign_ensure_aside_20241219('ex')
|
||||
self.campaign_ensure_chapter(index=chapter)
|
||||
self.campaign_ensure_chapter(chapter)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user