From ad5fcc2abca66ea89b427bd6ba7242a0a3a685bf Mon Sep 17 00:00:00 2001 From: LmeSzinc Date: Mon, 1 Jun 2020 09:25:51 +0800 Subject: [PATCH] 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 --- module/retire/dock.py | 2 +- module/retire/enhancement.py | 6 +----- module/retire/retirement.py | 32 ++++++++++++++++++++++++-------- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/module/retire/dock.py b/module/retire/dock.py index d9ab4ca8f..027a242aa 100644 --- a/module/retire/dock.py +++ b/module/retire/dock.py @@ -36,7 +36,7 @@ class Dock(UI, Equipment): self.handle_dock_cards_loading() 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): self.ui_back(check_button=self._dock_quit_check_func, skip_first_screenshot=True) diff --git a/module/retire/enhancement.py b/module/retire/enhancement.py index a7fefa9f9..925adca46 100644 --- a/module/retire/enhancement.py +++ b/module/retire/enhancement.py @@ -72,7 +72,6 @@ class Enhancement(Dock): self.equip_sidebar_ensure(index=4) 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)) logger.attr('Reload_enhanced', f'{int(status * 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.config.DOCK_FULL_TRIGGERED = True - if total == 0: - logger.warning('No ship enhanced, exit') - raise ScriptError('No ship enhanced, exit') - return True + return total diff --git a/module/retire/retirement.py b/module/retire/retirement.py index 518aeb0a9..5ee4e0e80 100644 --- a/module/retire/retirement.py +++ b/module/retire/retirement.py @@ -22,6 +22,8 @@ CARD_RARITY_COLORS = { class Retirement(Enhancement): + _unable_to_enhance = False + def _retirement_choose(self, amount=10, target_rarity=('N',)): """ Args: @@ -114,7 +116,7 @@ class Retirement(Enhancement): executed = False while 1: 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(): continue if self.appear_then_click(SHIP_CONFIRM, offset=30, interval=2): @@ -238,10 +240,27 @@ class Retirement(Enhancement): if not self.retirement_appear(): return False - if self.config.RETIREMENT_METHOD == 'enhance': - return self._enhance_handler() + if self._unable_to_enhance: + 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: - 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): 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.config.DOCK_FULL_TRIGGERED = True - if total == 0: - logger.warning('No ship retired, exit') - raise ScriptError('No ship retired, exit') - return True + return total