Fix: Retry synthesize_rarity_reset() if inv.wait_selected() failed

This commit is contained in:
LmeSzinc 2024-06-18 16:52:08 +08:00
parent 6be818dfd6
commit e60f4c2e5a

View File

@ -174,13 +174,18 @@ class Synthesize(CombatObtain, ItemUI):
return switched
def synthesize_rarity_reset(self, skip_first_screenshot=True):
def synthesize_rarity_reset(self, inv=None, skip_first_screenshot=True):
"""
Reset rarity switch, so current item will pin on the first row
Args:
inv: InventoryManager object if wait until item selected
skip_first_screenshot:
Returns:
bool: If success
"""
for _ in range(3):
logger.hr('synthesize rarity reset')
current = self.item_get_rarity_retry(ENTRY_ITEM_FROM)
if current == 'blue':
@ -193,7 +198,17 @@ class Synthesize(CombatObtain, ItemUI):
self.synthesize_rarity_set(r1, skip_first_screenshot=skip_first_screenshot)
self.synthesize_rarity_set(r2, skip_first_screenshot=True)
if inv is not None:
if inv.wait_selected():
return True
else:
continue
else:
logger.info('synthesize_rarity_reset ended without wait_selected()')
return True
logger.error('synthesize_rarity_reset failed 3 times')
return False
def synthesize_obtain_get(self) -> list[ObtainedAmmount]:
"""
@ -301,7 +316,6 @@ class Synthesize(CombatObtain, ItemUI):
if inv.selected.loca[1] >= 3:
logger.info('Reached inventory view end, reset view')
self.synthesize_rarity_reset()
inv.wait_selected()
logger.hr('Synthesize select view', level=2)
continue
else: