#!/usr/bin/env python3
"""
魔兽世界自动打怪主入口模块
使用图像识别技术定位怪物并模拟攻击操作
"""

import sys
import logging
from typing import Optional, Tuple
from combat_engine import CombatEngine
from config import GameConfig

def setup_logging() -> None:
    """配置日志记录"""
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        handlers=[
            logging.FileHandler('combat.log'),
            logging.StreamHandler()
        ]
    )

def main() -> int:
    """主入口函数"""
    try:
        setup_logging()
        logger = logging.getLogger(__name__)
        
        # 加载配置
        config = GameConfig.load_config()
        logger.info("游戏配置加载成功")
        
        # 初始化战斗引擎
        engine = CombatEngine(config)
        logger.info("战斗引擎初始化完成")
        
        # 启动自动战斗
        logger.info("启动自动打怪系统...")
        engine.run_combat_loop()
        
        return 0
    except KeyboardInterrupt:
        logger.info("用户中断程序执行")
        return 0
    except Exception as e:
        logger.critical(f"程序异常终止: {str(e)}", exc_info=True)
        return 1

if __name__ == "__main__":
    sys.exit(main())
