Skip to content

Commit 568d7a4

Browse files
committed
fix: resolve strict timing type diagnostics
1 parent 7c2f83d commit 568d7a4

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

aao/core/timing/battle_state.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
BATTLE_BEGIN_TITLE_WHITE_PERMYRIAD_MIN = 150
6161
BATTLE_BEGIN_TEXT_SCORE_PERMYRIAD_MIN = 650
6262

63+
type _DiagnosticValue = bool | int | float | str | None | dict[str, "_DiagnosticValue"]
64+
type _DiagnosticObject = dict[str, _DiagnosticValue]
65+
6366

6467
class BattleState(Enum):
6568
"""战斗状态(对应 Rust BattleState)。"""
@@ -445,7 +448,9 @@ def detect_battle_state(frame: np.ndarray) -> BattleState:
445448
}
446449

447450

448-
def _diagnose_battle_begin_bands(frame: np.ndarray, width: int, height: int, scale: float) -> dict:
451+
def _diagnose_battle_begin_bands(
452+
frame: np.ndarray, width: int, height: int, scale: float
453+
) -> _DiagnosticObject:
449454
"""诊断 7 band sampling 各 band 的值。"""
450455
step = max(4, round(scale * BATTLE_BEGIN_SAMPLE_STEP_SCALE))
451456
top_y_step = max(step, round(height * 0.10))

aao/core/timing/time_source.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from aao import config
2525
from aao.core.timing import tick
2626
from aao.core.timing.battle_state import BattleState, detect_battle_state
27-
from aao.core.timing.calibration import FullCalibrationData
27+
from aao.core.timing.calibration import CalibrationProfile, FullCalibrationData
2828
from aao.utils.logger import logger
2929

3030
_WRAP_MARGIN = 3 # 帧下降超过此值 → 判定周期 wrap(过滤抖动)
@@ -70,7 +70,7 @@ class TimeSource:
7070

7171
def __init__(self, calibration: FullCalibrationData):
7272
self.calibration = calibration
73-
self.profiles = calibration.profiles
73+
self.profiles: list[CalibrationProfile] = calibration.profiles
7474

7575
self.cycle_counter = 0
7676
self.cycle_base_frames = 0
@@ -91,7 +91,7 @@ def __init__(self, calibration: FullCalibrationData):
9191
self._num_hidden = [p.total_frames - len(p.pixel_map) for p in calibration.profiles]
9292

9393
# PLL 外推状态
94-
self._prev_measured = -1 # 上次测量帧(用于 wrap 检测)
94+
self._prev_measured: int = -1 # 上次测量帧(用于 wrap 检测)
9595
self._prev_cost_is_negative = False # 上次负费状态(排除负费切换的遮挡 hold)
9696
self._stuck_lf: int | None = None # 卡住时的测量帧
9797
self._stuck_since = 0.0 # 卡住开始时间
@@ -115,7 +115,7 @@ def num_profiles(self) -> int:
115115
return len(self.profiles)
116116

117117
@property
118-
def active_profile(self):
118+
def active_profile(self) -> CalibrationProfile:
119119
return self.profiles[self.cycle_counter % self.num_profiles]
120120

121121
def update(self, frame: np.ndarray) -> int | None:
@@ -221,6 +221,8 @@ def update(self, frame: np.ndarray) -> int | None:
221221
)
222222
return self.previous_frame if self.previous_frame >= 0 else None
223223

224+
lf_measured = int(lf_measured)
225+
224226
# 费用条可见 → 重置消失计数
225227
self._no_cost_bar_frames = 0
226228

0 commit comments

Comments
 (0)