Skip to content

Commit e0b67b6

Browse files
feat: 添加决战提示&修复bug (#459)
* feat * [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 7578cfd commit e0b67b6

9 files changed

Lines changed: 18 additions & 8 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.1.9.post9'
3+
__version__ = '2.1.9.post10'

autowsgr/ops/decisive/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import TYPE_CHECKING
1111

1212
from autowsgr.constants import DECISIVE_SKILL_NAMES, update_shipnames
13-
from autowsgr.infra import DecisiveConfig
13+
from autowsgr.infra import DecisiveConfig, get_logger
1414
from autowsgr.ops.decisive.logic import DecisiveLogic
1515
from autowsgr.ops.decisive.state import DecisiveState
1616
from autowsgr.ui.decisive import DecisiveBattlePage, DecisiveMapController
@@ -19,6 +19,8 @@
1919
if TYPE_CHECKING:
2020
from autowsgr.context import GameContext
2121

22+
_log = get_logger('ops.decisive')
23+
2224

2325
class DecisiveBase:
2426
"""决战控制器基类。
@@ -65,6 +67,9 @@ def __init__(
6567
}
6668
merged_config = DecisiveConfig(**merged_config_dict)
6769
self._config = merged_config
70+
_log.info('[决战] 当前运行配置: {}', merged_config)
71+
if len(merged_config.level1) < 6:
72+
_log.warning('[决战] 一级舰队小于6艘, 请检查配置是否有误')
6873

6974
# 将决战配置中的舰船名 + 技能名合并到全局 SHIPNAMES,
7075
# 后续 OCR 识别无需再临时拼接候选列表。

autowsgr/ops/decisive/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,14 @@ def _handle_choose_fleet(self) -> None:
245245
if name not in {'长跑训练', '肌肉记忆', '黑科技'}:
246246
self._state.ships.add(name)
247247

248+
self._state.phase = DecisivePhase.PREPARE_COMBAT
248249
if not self._map.close_fleet_overlay():
249250
_log.info('[决战] 关闭决战选船界面失败, 选择第一艘后撤退')
250251
self._state.phase = DecisivePhase.RETREAT
251252
_, first_value = next(iter(selections.items()))
252253
self._map.buy_fleet_option(first_value.click_position)
253254
if not self._map.close_fleet_overlay():
254255
raise RuntimeError('关闭决战选船界面失败')
255-
self._state.phase = DecisivePhase.PREPARE_COMBAT
256256

257257
def _handle_advance_choice(self) -> None:
258258
"""选择前进点。"""

autowsgr/ui/battle/fleet_change/_change.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,8 @@ def _change_single_ship(
633633
self._ctrl,
634634
ChooseShipPage.is_current_page,
635635
timeout=_CHOOSE_PAGE_TIMEOUT,
636+
source='编队',
637+
target='编队选船',
636638
)
637639
choose_page = ChooseShipPage(self._ctx)
638640
return choose_page.change_single_ship(

autowsgr/ui/choose_ship_page.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def is_current_page(screen: np.ndarray) -> bool:
144144
return result.matched
145145

146146
def _wait_leave_current_page(self, timeout: float = 5.0):
147-
wait_leave_page(self._ctrl, self.is_current_page, timeout=timeout)
147+
wait_leave_page(
148+
self._ctrl, self.is_current_page, timeout=timeout, source='编队选船', target='编队'
149+
)
148150

149151
# ── 操作 ──────────────────────────────────────────────────────────────
150152
def ensure_search_box(self) -> None:

autowsgr/ui/decisive/battle_page.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
PixelRule.of(0.9695, 0.8500, (15, 31, 56), tolerance=30.0),
5353
PixelRule.of(0.7641, 0.8611, (22, 46, 84), tolerance=30.0),
5454
PixelRule.of(0.0453, 0.0667, (38, 39, 43), tolerance=30.0),
55-
# 底部“重置关卡”按钮文字(白色)—— 与战役/出征地图区分的关键点
56-
PixelRule.of(0.500, 0.925, (255, 255, 255), tolerance=30.0),
5755
],
5856
)
5957
"""决战页面像素签名。"""

autowsgr/ui/decisive/fleet_ocr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def recognize_fleet_options(
134134
continue
135135
costs.append(cost)
136136
_log.debug('[舰队OCR] 识别到 {} 项费用: {}', len(costs), costs)
137+
if any(c < 4 for c in costs):
138+
_log.warning('[舰队OCR] 识别到小于4的费用, 建议检查配队是否有误')
137139

138140
# 3. 恢复原版行为:仅对可购买项识别舰名
139141
selections: dict[str, FleetSelection] = {}

autowsgr/ui/decisive/map_controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ def enter_formation(self) -> None:
560560
CLICK_FORMATION,
561561
BattlePreparationPage.is_current_page,
562562
config=config,
563+
source='决战地图',
564+
target='出征准备',
563565
)
564566

565567
def click_sortie(self) -> None:

autowsgr/ui/decisive/overlay.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class DecisiveOverlay(enum.Enum):
132132
CLICK_SORTIE: tuple[float, float] = (900 / 960, 500 / 540)
133133
"""右下角「出征」按钮 — 进入出征准备页。"""
134134

135-
CLICK_FLEET_EDIT: tuple[float, float] = (700 / 960, 500 / 540)
135+
CLICK_FORMATION: tuple[float, float] = (700 / 960, 500 / 540)
136136
"""右下角「编队」按钮 — 进入编队页面。"""
137137

138138
CLICK_BUY_EXP: tuple[float, float] = (75 / 960, 500 / 540)
@@ -141,7 +141,6 @@ class DecisiveOverlay(enum.Enum):
141141
CLICK_SKILL: tuple[float, float] = (0.2143, 0.894)
142142
"""副官技能按钮。"""
143143

144-
CLICK_FORMATION: tuple[float, float] = (0.75, 0.925)
145144

146145
# ── 战备舰队获取 overlay ──
147146

0 commit comments

Comments
 (0)