From fc84f5e61046933abc0ec0d70709c84d8160b0fb Mon Sep 17 00:00:00 2001 From: LmeSzinc Date: Mon, 27 Apr 2020 19:32:58 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8D=E5=BC=80=E8=8D=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复低级图出BOSS后报错的问题 - 修复了开荒进度0%时的章节名OCR - 修复打完BOSS有时会卡住的问题 --- module/campaign/campaign_ocr.py | 2 +- module/combat/combat.py | 2 +- module/config/config.py | 2 +- module/device/control.py | 8 +++++--- module/device/screenshot.py | 2 +- module/handler/enemy_searching.py | 6 +++++- module/map/map.py | 3 ++- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/module/campaign/campaign_ocr.py b/module/campaign/campaign_ocr.py index 61ad70772..4f1c81afb 100644 --- a/module/campaign/campaign_ocr.py +++ b/module/campaign/campaign_ocr.py @@ -94,7 +94,7 @@ class CampaignOcr: @staticmethod def extract_stage_name(image): - x_skip = 7 + x_skip = 10 interval = 5 x_color = np.convolve(np.mean(image, axis=0), np.ones(interval), 'valid') / interval x_list = np.where(x_color[x_skip:] > 235)[0] diff --git a/module/combat/combat.py b/module/combat/combat.py index af4f79b7a..aca6d6b2c 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -309,7 +309,7 @@ class Combat(HPBalancer, UrgentCommissionHandler, EnemySearchingHandler, Retirem break if expected_end == 'with_searching' and self.handle_in_map_with_enemy_searching(): break - if expected_end == 'no_searching' and self.handle_in_map(): + if expected_end == 'no_searching' and self.handle_in_map_no_enemy_searching(): break if expected_end == 'in_ui' and self.appear(BACK_ARROW, offset=(20, 20)): break diff --git a/module/config/config.py b/module/config/config.py index 21f2d7ab0..e71ef10c1 100644 --- a/module/config/config.py +++ b/module/config/config.py @@ -319,7 +319,7 @@ class AzurLaneConfig: self.SCREEN_SHOT_SAVE_FOLDER = self.SCREEN_SHOT_SAVE_FOLDER_BASE + '/' + self.CAMPAIGN_NAME for folder in [self.SCREEN_SHOT_SAVE_FOLDER_BASE, self.ASSETS_FOLDER, self.SCREEN_SHOT_SAVE_FOLDER, self.PERSPECTIVE_ERROR_LOG_FOLDER, self.ERROR_LOG_FOLDER]: - if not os.path.exists(folder): + if folder and not os.path.exists(folder): os.mkdir(folder) def merge(self, other): diff --git a/module/device/control.py b/module/device/control.py index 7bc03971f..fe9816c53 100644 --- a/module/device/control.py +++ b/module/device/control.py @@ -1,11 +1,13 @@ import time from collections import deque +from retrying import retry + from module.base.timer import Timer from module.base.utils import * from module.device.connection import Connection -from module.logger import logger from module.exception import ScriptError +from module.logger import logger class Control(Connection): @@ -62,11 +64,11 @@ class Control(Connection): self._click_uiautomator2(x, y) self.sleep(self.config.SLEEP_AFTER_CLICK) - # @retry() + @retry() def _click_uiautomator2(self, x, y): self.device.click(int(x), int(y)) - # @retry() + @retry() def _click_adb(self, x, y): self.adb_shell(['input', 'tap', str(x), str(y)], serial=self.serial) diff --git a/module/device/screenshot.py b/module/device/screenshot.py index 197364ac1..4b37e5817 100644 --- a/module/device/screenshot.py +++ b/module/device/screenshot.py @@ -47,7 +47,7 @@ class Screenshot(Connection): screenshot = self.adb_shell(['screencap', '-p'], serial=self.serial) return self._process_screenshot(screenshot) - # @retry() + @retry() # @timer def screenshot(self): """ diff --git a/module/handler/enemy_searching.py b/module/handler/enemy_searching.py index 0e006410a..accf21b79 100644 --- a/module/handler/enemy_searching.py +++ b/module/handler/enemy_searching.py @@ -42,6 +42,8 @@ class EnemySearchingHandler(InfoBarHandler): def handle_in_map_with_enemy_searching(self): if not self.is_in_map(): return False + if self.handle_in_stage(): + return True timeout = Timer(self.MAP_ENEMY_SEARCHING_TIMEOUT_SECOND) appeared = False @@ -67,9 +69,11 @@ class EnemySearchingHandler(InfoBarHandler): self.device.screenshot() return True - def handle_in_map(self): + def handle_in_map_no_enemy_searching(self): if not self.is_in_map(): return False + if self.handle_in_stage(): + return True self.device.sleep((1, 1.2)) return True diff --git a/module/map/map.py b/module/map/map.py index 9bc197e3a..090a5c99d 100644 --- a/module/map/map.py +++ b/module/map/map.py @@ -267,7 +267,8 @@ class Map(Fleet): logger.info('Brute clear BOSS') if self.brute_fleet_meet(): return True - grids = self.brute_find_roadblocks(boss[0], fleet=self.config.FLEET_BOSS) + fleet = 2 if self.config.FLEET_BOSS == 2 and self.config.FLEET_2 else 1 + grids = self.brute_find_roadblocks(boss[0], fleet=fleet) if grids: logger.info('Brute clear BOSS roadblocks') grids = grids.sort(cost=True, weight=True)