Fix: No ship to enhance

- When there ship to enhance, but dock full, try one_click_retire
- Fix retire SR ship when using one_click_retire
This commit is contained in:
LmeSzinc 2020-06-01 09:25:51 +08:00
parent f406022da0
commit ad5fcc2abc
3 changed files with 26 additions and 14 deletions

View File

@ -36,7 +36,7 @@ class Dock(UI, Equipment):
self.handle_dock_cards_loading() self.handle_dock_cards_loading()
def _dock_quit_check_func(self): def _dock_quit_check_func(self):
return not self.appear(DOCK_CHECK) return not self.appear(DOCK_CHECK, offset=(20, 20))
def dock_quit(self): def dock_quit(self):
self.ui_back(check_button=self._dock_quit_check_func, skip_first_screenshot=True) self.ui_back(check_button=self._dock_quit_check_func, skip_first_screenshot=True)

View File

@ -72,7 +72,6 @@ class Enhancement(Dock):
self.equip_sidebar_ensure(index=4) self.equip_sidebar_ensure(index=4)
self.wait_until_appear(ENHANCE_RECOMMEND, offset=(5, 5), skip_first_screenshot=True) self.wait_until_appear(ENHANCE_RECOMMEND, offset=(5, 5), skip_first_screenshot=True)
status = color_bar_percentage(self.device.image, area=ENHANCE_RELOAD.area, prev_color=(231, 178, 74)) status = color_bar_percentage(self.device.image, area=ENHANCE_RELOAD.area, prev_color=(231, 178, 74))
logger.attr('Reload_enhanced', f'{int(status * 100)}%') logger.attr('Reload_enhanced', f'{int(status * 100)}%')
choose = np.sum(np.array(self.device.image.crop(ENHANCE_FILLED.area)) > 200) > 100 choose = np.sum(np.array(self.device.image.crop(ENHANCE_FILLED.area)) > 200) > 100
@ -134,7 +133,4 @@ class Enhancement(Dock):
self.dock_quit() self.dock_quit()
self.config.DOCK_FULL_TRIGGERED = True self.config.DOCK_FULL_TRIGGERED = True
if total == 0: return total
logger.warning('No ship enhanced, exit')
raise ScriptError('No ship enhanced, exit')
return True

View File

@ -22,6 +22,8 @@ CARD_RARITY_COLORS = {
class Retirement(Enhancement): class Retirement(Enhancement):
_unable_to_enhance = False
def _retirement_choose(self, amount=10, target_rarity=('N',)): def _retirement_choose(self, amount=10, target_rarity=('N',)):
""" """
Args: Args:
@ -114,7 +116,7 @@ class Retirement(Enhancement):
executed = False executed = False
while 1: while 1:
self.device.screenshot() self.device.screenshot()
if self.config.RETIRE_SR or self.config.RETIRE_SSR or self.config.USE_ONE_CLICK_RETIREMENT: if self.config.RETIRE_SR or self.config.RETIRE_SSR or self.config.RETIREMENT_METHOD == 'one_click_retire':
if self.handle_popup_confirm(): if self.handle_popup_confirm():
continue continue
if self.appear_then_click(SHIP_CONFIRM, offset=30, interval=2): if self.appear_then_click(SHIP_CONFIRM, offset=30, interval=2):
@ -238,10 +240,27 @@ class Retirement(Enhancement):
if not self.retirement_appear(): if not self.retirement_appear():
return False return False
if self.config.RETIREMENT_METHOD == 'enhance': if self._unable_to_enhance:
return self._enhance_handler() self.config.RETIREMENT_METHOD = 'one_click_retire'
total = self._retire_handler()
self.config.RETIREMENT_METHOD = 'enhance'
self._unable_to_enhance = False
if not total:
logger.warning('No ship retired, exit')
raise ScriptError('No ship retired, exit')
elif 'retire' in self.config.RETIREMENT_METHOD or self._unable_to_enhance:
total = self._retire_handler()
self._unable_to_enhance = False
if not total:
logger.warning('No ship retired, exit')
raise ScriptError('No ship retired, exit')
else: else:
return self._retire_handler() total = self._enhance_handler()
if not total:
logger.info('No ship to enhance, but dock full, will try retire')
self._unable_to_enhance = True
return True
def _retire_handler(self): def _retire_handler(self):
self.ui_click(RETIRE_APPEAR_1, check_button=IN_RETIREMENT_CHECK, skip_first_screenshot=True) self.ui_click(RETIRE_APPEAR_1, check_button=IN_RETIREMENT_CHECK, skip_first_screenshot=True)
@ -252,7 +271,4 @@ class Retirement(Enhancement):
self._retirement_quit() self._retirement_quit()
self.config.DOCK_FULL_TRIGGERED = True self.config.DOCK_FULL_TRIGGERED = True
if total == 0: return total
logger.warning('No ship retired, exit')
raise ScriptError('No ship retired, exit')
return True