|
14 | 14 | from __future__ import annotations |
15 | 15 |
|
16 | 16 | import time |
17 | | -from functools import lru_cache |
18 | 17 | from typing import TYPE_CHECKING |
19 | 18 |
|
20 | 19 | import cv2 |
|
55 | 54 |
|
56 | 55 |
|
57 | 56 | if TYPE_CHECKING: |
58 | | - from collections.abc import Callable |
59 | | - |
60 | 57 | from autowsgr.context import GameContext |
61 | 58 | from autowsgr.infra import DecisiveConfig |
62 | 59 | from autowsgr.vision.api_dll import ApiDll |
|
65 | 62 | _log = get_logger('ui.decisive') |
66 | 63 |
|
67 | 64 |
|
68 | | -@lru_cache(maxsize=1) |
69 | | -def _get_recognize_ship_drop() -> Callable: |
70 | | - from autowsgr.combat import recognize_ship_drop as _fn |
71 | | - |
72 | | - return _fn |
73 | | - |
74 | | - |
75 | 65 | SKILL_USED = PixelSignature( |
76 | 66 | name='skill_used', |
77 | 67 | strategy=MatchStrategy.ALL, |
@@ -590,6 +580,7 @@ def confirm_leave(self) -> None: |
590 | 580 |
|
591 | 581 | def confirm_stage_clear(self) -> list[str]: # noqa: PLR0912 |
592 | 582 | """小关通关后确认弹窗并收集掉落舰船。""" |
| 583 | + from autowsgr.combat import recognize_ship_drop |
593 | 584 | from autowsgr.image_resources import Templates |
594 | 585 | from autowsgr.ui.utils import confirm_operation |
595 | 586 |
|
@@ -629,7 +620,7 @@ def confirm_stage_clear(self) -> list[str]: # noqa: PLR0912 |
629 | 620 | if detail is None: |
630 | 621 | break |
631 | 622 |
|
632 | | - ship_drop = _get_recognize_ship_drop()(screen, ocr=self._ocr) |
| 623 | + ship_drop = recognize_ship_drop(screen, ocr=self._ocr) |
633 | 624 | _log.info(f'[地图控制器] 检测到掉落: {ship_drop.ship_name}({ship_drop.ship_type})') |
634 | 625 | collected.append(ship_drop.ship_name) |
635 | 626 | self._ctrl.click(0.953, 0.954) |
|
0 commit comments