mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-16 06:25:24 +00:00
Fix: salvage_relic should exit to GOTO_SALVAGE if failed
This commit is contained in:
parent
e8cd2ee948
commit
e5261ca9fb
@ -11,7 +11,43 @@ class RelicsUI(ItemUI):
|
|||||||
def _is_in_salvage(self) -> bool:
|
def _is_in_salvage(self) -> bool:
|
||||||
return self.appear(ORDER_ASCENDING) or self.appear(ORDER_DESCENDING)
|
return self.appear(ORDER_ASCENDING) or self.appear(ORDER_DESCENDING)
|
||||||
|
|
||||||
|
def salvage_exit(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: rewards claimed
|
||||||
|
or _is_in_salvage()
|
||||||
|
out: GOTO_SALVAGE
|
||||||
|
"""
|
||||||
|
interval = Timer(1)
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
if self.appear(GOTO_SALVAGE):
|
||||||
|
logger.info("Salvage page exited")
|
||||||
|
break
|
||||||
|
if self.handle_reward(interval=2):
|
||||||
|
continue
|
||||||
|
if interval.reached() and self._is_in_salvage():
|
||||||
|
logger.info(f'_is_in_salvage -> {CLOSE}')
|
||||||
|
self.device.click(CLOSE)
|
||||||
|
interval.reset()
|
||||||
|
continue
|
||||||
|
|
||||||
def salvage_relic(self, skip_first_screenshot=True) -> bool:
|
def salvage_relic(self, skip_first_screenshot=True) -> bool:
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
skip_first_screenshot:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: If success
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: Any
|
||||||
|
out: page_item, GOTO_SALVAGE
|
||||||
|
"""
|
||||||
logger.hr('Salvage Relic', level=2)
|
logger.hr('Salvage Relic', level=2)
|
||||||
self.item_goto(KEYWORD_ITEM_TAB.Relics, wait_until_stable=False)
|
self.item_goto(KEYWORD_ITEM_TAB.Relics, wait_until_stable=False)
|
||||||
while 1: # relic tab -> salvage
|
while 1: # relic tab -> salvage
|
||||||
@ -37,6 +73,7 @@ class RelicsUI(ItemUI):
|
|||||||
|
|
||||||
if timeout.reached():
|
if timeout.reached():
|
||||||
logger.warning('Timeout when selecting first relic')
|
logger.warning('Timeout when selecting first relic')
|
||||||
|
self.salvage_exit()
|
||||||
return False
|
return False
|
||||||
# The first frame entering relic page, SALVAGE is a white button as it's the default state.
|
# The first frame entering relic page, SALVAGE is a white button as it's the default state.
|
||||||
# At the second frame, SALVAGE is disabled since no items are selected.
|
# At the second frame, SALVAGE is disabled since no items are selected.
|
||||||
@ -67,22 +104,5 @@ class RelicsUI(ItemUI):
|
|||||||
if self.handle_popup_confirm():
|
if self.handle_popup_confirm():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
skip_first_screenshot = True
|
self.salvage_exit()
|
||||||
interval = Timer(1)
|
|
||||||
while 1: # rewards claimed -> relic tab page
|
|
||||||
if skip_first_screenshot:
|
|
||||||
skip_first_screenshot = False
|
|
||||||
else:
|
|
||||||
self.device.screenshot()
|
|
||||||
|
|
||||||
if self.appear(GOTO_SALVAGE):
|
|
||||||
logger.info("Salvage page exited")
|
|
||||||
break
|
|
||||||
if self.handle_reward(interval=2):
|
|
||||||
continue
|
|
||||||
if interval.reached() and self._is_in_salvage():
|
|
||||||
logger.info(f'_is_in_salvage -> {CLOSE}')
|
|
||||||
self.device.click(CLOSE)
|
|
||||||
interval.reset()
|
|
||||||
continue
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user