Skip to content

Commit f5c55b0

Browse files
Fix/map page recognition and acquisition api (#353)
* fix: map page recognition with loot badge & add acquisition API - Move TAB_PROBES[0] y from 0.0417 to 0.0650 to avoid loot badge overlay - Add GET /api/game/acquisition - OCR recognition of ship/loot counts - Add GET /api/game/context - game context runtime counters - Bump version to 2.0.4 * fix: move tab probe[1] down & add debug logging, bump to 2.0.4.post1 - Move TAB_PROBES[1] y from 0.0486 to 0.0650 to avoid tab text pixels - Add debug logging to is_tabbed_page() for diagnosis - Bump version to 2.0.4.post1 * chore: comment out debug logging in is_tabbed_page() * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent de5800a commit f5c55b0

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

autowsgr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""AutoWSGR — 战舰少女R 自动化框架 (v2)"""
22

3-
__version__ = '2.0.4'
3+
__version__ = '2.0.4.post1'

autowsgr/ui/tabbed_page.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@
7474
from autowsgr.vision import Color, PixelChecker
7575

7676

77+
# from autowsgr.infra.logger import get_logger
78+
79+
# _log = get_logger('ui.tabbed')
80+
81+
7782
if TYPE_CHECKING:
7883
from collections.abc import Callable
7984

@@ -99,15 +104,15 @@ class TabbedPageType(enum.Enum):
99104

100105
TAB_PROBES: list[tuple[float, float]] = [
101106
(0.1415, 0.0650),
102-
(0.2727, 0.0486),
107+
(0.2727, 0.0650),
103108
(0.4031, 0.0486),
104109
(0.5352, 0.0486),
105110
(0.6617, 0.0542),
106111
]
107112
"""5 个固定标签栏探测点 (相对坐标)。
108113
109114
激活标签处显示蓝色 ≈ (15, 132, 228),其余为深色 (max < 80)。
110-
第 0 号探测点 y 下移至 0.065 以避开 "战利品▲" 徽标遮挡区域。
115+
第 0、1 号探测点 y 下移至 0.065 以避开标签文字及 "战利品▲" 徽标遮挡区域。
111116
"""
112117

113118
TAB_BLUE = Color.of(15, 132, 228)
@@ -296,13 +301,21 @@ def is_tabbed_page(screen: np.ndarray) -> bool:
296301
"""
297302
blue_count = 0
298303
dark_count = 0
299-
for x, y in TAB_PROBES:
304+
for i, (x, y) in enumerate(TAB_PROBES):
300305
pixel = PixelChecker.get_pixel(screen, x, y)
301-
if pixel.near(TAB_BLUE, TAB_BLUE_TOLERANCE):
306+
is_blue = pixel.near(TAB_BLUE, TAB_BLUE_TOLERANCE)
307+
is_dark = max(pixel.r, pixel.g, pixel.b) < TAB_DARK_MAX
308+
# _log.debug(
309+
# '[TabCheck] probe[{}] ({:.4f},{:.4f}) → ({},{},{}) blue={} dark={}',
310+
# i, x, y, pixel.r, pixel.g, pixel.b, is_blue, is_dark,
311+
# )
312+
if is_blue:
302313
blue_count += 1
303-
elif max(pixel.r, pixel.g, pixel.b) < TAB_DARK_MAX:
314+
elif is_dark:
304315
dark_count += 1
305-
return blue_count == 1 and dark_count == len(TAB_PROBES) - 1
316+
result = blue_count == 1 and dark_count == len(TAB_PROBES) - 1
317+
# _log.debug('[TabCheck] blue={} dark={} → is_tabbed={}', blue_count, dark_count, result)
318+
return result
306319

307320

308321
def get_active_tab_index(screen: np.ndarray) -> int | None:

0 commit comments

Comments
 (0)