first commit
This commit is contained in:
40
config.py
Normal file
40
config.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
游戏配置模块
|
||||
"""
|
||||
from dataclasses import dataclass
|
||||
import cv2
|
||||
import numpy as np
|
||||
from typing import Tuple
|
||||
|
||||
@dataclass
|
||||
class GameConfig:
|
||||
# 图像识别参数
|
||||
monster_template_path: str = 'monster_template.png'
|
||||
recognition_threshold: float = 0.55
|
||||
scan_interval: float = 1.0
|
||||
|
||||
# 操作参数
|
||||
attack_button: str = 'left'
|
||||
action_delay: float = 0.1
|
||||
|
||||
# 移动参数
|
||||
move_tolerance: float = 0.5 # 到达巡逻点的判定半径(坐标单位)
|
||||
|
||||
# 系统参数
|
||||
auto_recovery: bool = True
|
||||
error_recovery_delay: float = 3.0
|
||||
|
||||
# 计算属性
|
||||
@property
|
||||
def monster_template(self) -> np.ndarray:
|
||||
"""加载怪物模板图像"""
|
||||
img = cv2.imread(self.monster_template_path, cv2.IMREAD_COLOR)
|
||||
if img is None:
|
||||
raise FileNotFoundError(f"模板图像未找到: {self.monster_template_path}")
|
||||
return img
|
||||
|
||||
@classmethod
|
||||
def load_config(cls) -> 'GameConfig':
|
||||
"""加载配置文件"""
|
||||
# 实际项目中可以从配置文件读取
|
||||
return cls()
|
||||
Reference in New Issue
Block a user