Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autowsgr/ops/decisive/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ def _handle_prepare_combat(self) -> None:

if self._state.node == 'U':
# 初次进入都要进行节点识别
self._state.node = self._map.recognize_node()
recognized_node = self._map.recognize_node()
if recognized_node == 'CHOOSE_FLEET':
_log.info('[决战] 检测到战备舰队获取页面')
self._state.phase = DecisivePhase.CHOOSE_FLEET
return
self._state.node = recognized_node
_log.info(
'[决战] 出征准备 (小关 {} 节点 {})',
self._state.stage,
Expand Down
3 changes: 2 additions & 1 deletion autowsgr/ops/decisive/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def choose_ships(
score -= sel.cost
result.append(target)

if first_node and result:
# 第一节点没选上Lv1,也购买Lv2舰船
if first_node:
for target in set(self._level2_full) - self._level1_set:
if target in selections:
sel = selections[target]
Expand Down
12 changes: 10 additions & 2 deletions autowsgr/ui/decisive/map_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import numpy as np

import autowsgr.ui.decisive.fleet_ocr as _fleet_ocr
from autowsgr.combat import recognize_ship_drop
from autowsgr.infra.logger import get_logger
from autowsgr.types import DecisivePhase, FleetSelection, ShipDamageState
from autowsgr.ui.battle.preparation import BattlePreparationPage, RepairStrategy
Expand Down Expand Up @@ -233,6 +234,10 @@ def dll_recognize_map(self, dll, screen, center) -> str:

def get_ship_icon_pos(self) -> float | None:
detect_screen = self._ctrl.screenshot()
# 针对Ex5特调,A节点不选择分支,直接进入战备舰队获取
screen_is_fleet_acquisition = is_fleet_acquisition(detect_screen)
if screen_is_fleet_acquisition:
return -1
# _locate_ship_icon 需要 BGR;screenshot() 返回 RGB
bgr = cv2.cvtColor(detect_screen, cv2.COLOR_RGB2BGR)
icon_rel_x = self._locate_ship_icon(bgr)
Expand Down Expand Up @@ -270,6 +275,8 @@ def recognize_node(
for retry_icon in range(_MAX_RETRY + 1):
time.sleep(0.5)
icon_rel_x_now = self.get_ship_icon_pos_with_retry()
if icon_rel_x_now == -1:
return 'CHOOSE_FLEET'
if icon_rel_x_now == icon_rel_x:
_log.debug('[地图控制器] 舰船指示器位置: X={:.5f}', icon_rel_x)
break
Expand Down Expand Up @@ -637,8 +644,9 @@ def confirm_stage_clear(self) -> list[str]:
if detail is None:
break

_log.info("[地图控制器] 检测到掉落: '{}'", detail.template_name)
collected.append(detail.template_name)
ship_drop = recognize_ship_drop(screen, ocr=self._ocr)
_log.info(f'[地图控制器] 检测到掉落: {ship_drop.ship_name}({ship_drop.ship_type})')
collected.append(ship_drop.ship_name)
self._ctrl.click(0.953, 0.954)
time.sleep(0.5)
confirm_operation(self._ctrl, timeout=1.0)
Expand Down