From 6c884b2b033cd0182d7c0588e657a95c3c889bc9 Mon Sep 17 00:00:00 2001 From: KUAI Date: Tue, 30 Jun 2026 14:36:28 +0800 Subject: [PATCH] fix III A and format --- autowsgr/combat/actions.py | 2 +- autowsgr/emulator/controller/scrcpy.py | 64 +++++++++++++++----------- autowsgr/vision/ocr.py | 7 ++- 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/autowsgr/combat/actions.py b/autowsgr/combat/actions.py index 37ea0ca2..d59fcbb2 100644 --- a/autowsgr/combat/actions.py +++ b/autowsgr/combat/actions.py @@ -190,7 +190,7 @@ def click_speed_up(device: AndroidController, *, battle_mode: bool = False) -> N coords = Coords.SPEED_UP_BATTLE if battle_mode else Coords.SPEED_UP_NORMAL # 由于这个点击之后,马上就会进行画面识别,为了保证画面被正确识别,这里不加延迟 - device.click(*coords,delay=False) + device.click(*coords, delay=False) def click_skip_missile_animation(device: AndroidController) -> None: diff --git a/autowsgr/emulator/controller/scrcpy.py b/autowsgr/emulator/controller/scrcpy.py index 2f4dca20..b52848d9 100644 --- a/autowsgr/emulator/controller/scrcpy.py +++ b/autowsgr/emulator/controller/scrcpy.py @@ -23,7 +23,7 @@ from typing import TYPE_CHECKING from autowsgr.infra import EmulatorConfig, EmulatorConnectionError -from autowsgr.infra.config import OPERATION_DELAY_MIN, OPERATION_DELAY_MAX +from autowsgr.infra.config import OPERATION_DELAY_MAX, OPERATION_DELAY_MIN from autowsgr.infra.logger import caller_info, get_logger from ..detector import _find_adb, detect_emulators, prompt_user_select, resolve_serial @@ -430,10 +430,12 @@ def click(self, x: float, y: float, *, delay: bool = True) -> None: ) dev.shell(f'input tap {px} {py}') if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) def swipe( self, @@ -443,7 +445,7 @@ def swipe( y2: float, duration: float = 0.5, *, - delay: bool = True + delay: bool = True, ) -> None: dev = self._require_device() w, h = self._resolution @@ -467,10 +469,12 @@ def swipe( # 增加延迟,改动同 click_delay if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) def long_tap(self, x: float, y: float, duration: float = 1.0) -> None: self.swipe(x, y, x, y, duration=duration) @@ -483,10 +487,12 @@ def key_event(self, key_code: int, *, delay: bool = True) -> None: # 增加延迟,改动同 click_delay if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) def text(self, content: str, *, delay: bool = True) -> None: dev = self._require_device() @@ -495,10 +501,12 @@ def text(self, content: str, *, delay: bool = True) -> None: # 增加延迟,改动同 click_delay if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) # ── 应用管理 ── @@ -509,10 +517,12 @@ def start_app(self, package: str, *, delay: bool = True) -> None: # 增加延迟,改动同 click_delay if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) def stop_app(self, package: str, *, delay: bool = True) -> None: dev = self._require_device() @@ -521,10 +531,12 @@ def stop_app(self, package: str, *, delay: bool = True) -> None: # 增加延迟,改动同 click_delay if delay: # True 才走延迟 - time.sleep(random.uniform( - min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), - )) + time.sleep( + random.uniform( + min(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + max(OPERATION_DELAY_MIN, OPERATION_DELAY_MAX), + ) + ) def is_app_running(self, package: str) -> bool: try: diff --git a/autowsgr/vision/ocr.py b/autowsgr/vision/ocr.py index d2c2b65d..535b0497 100644 --- a/autowsgr/vision/ocr.py +++ b/autowsgr/vision/ocr.py @@ -32,7 +32,12 @@ # ── 结果数据类 ── -REPLACE_RULE: dict[str, str] = {'鲍鱼': '鲃鱼', '296': 'M-296', '维内托': '维托里奥·维内托'} +REPLACE_RULE: dict[str, str] = { + '鲍鱼': '鲃鱼', + '296': 'M-296', + '维内托': '维托里奥·维内托', + 'IA': 'IIIA', +} # ── 舰船名文本补丁管线 ──