Files
lc-mcp/lc_mcp/preflight.py
ywsandClaude Opus 5.5 2190f57abe 无人值守自动化: 配置预检、选队精确匹配、窗口守护、卡死重跑、计划任务, AALC 升级到 b0f4393
- lc_mcp/preflight.py: 启动前拦截 sinner_order 全 0、会花狂气、窗口放不进桌面 (退出码 3)
- lc_mcp/aalc_patches.py: 队伍名按编号精确匹配 (TEAMS #1 不再命中 #10); 后台守护客户区 16:9
- auto_cycle.py: AALC 卡死后停掉重跑; --mirror 打镜牢; 每轮写 cycle_*.log/.json 报告
- install_unattended.ps1: 注册会话看门狗 (每 5 分钟) 与每日一轮计划任务
- lc_ui.py: pythonw 启动时子进程改用 python 且不弹窗
- vendor/aalc: 7452fad -> b0f4393 (镜牢楼层识别、困牢奖励、排队启动修复)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 03:12:19 +00:00

73 lines
3.2 KiB
Python

# -*- coding: utf-8 -*-
"""任务启动前的配置检查。
10-04/05 的几次长时间空转都源于配置: AALC 不报错, 只是一直原地打转。
这里把已知的坑在启动前拦下来, 返回人能看懂的原因。
check() 只吃普通 dict, 不依赖 AALC, 便于单测; collect() 负责从 AALC cfg 取值。
"""
import os
# 窗口边框 + 标题栏(100% 缩放下实测 16x39, 留一点余量)
FRAME_W, FRAME_H = 16, 40
ALLOW_LUNACY_ENV = 'LCP_ALLOW_LUNACY'
def collect(cfg):
teams = {}
for key, team in (cfg.get_value('teams') or {}).items():
data = team.model_dump() if hasattr(team, 'model_dump') else dict(team)
teams[str(key)] = data
return {
'simulator': bool(cfg.get_value('simulator')),
'mirror': bool(cfg.get_value('mirror')),
'set_win_size': int(cfg.get_value('set_win_size')),
'set_lunacy_to_enkephalin': int(cfg.get_value('set_lunacy_to_enkephalin') or 0),
'teams_active_queue': list(cfg.get_value('teams_active_queue') or []),
'teams': teams,
}
def desktop_size():
"""主显示器分辨率(进程已由 bootstrap 设为 DPI aware, 取到的是物理像素)。"""
from ctypes import windll
return windll.user32.GetSystemMetrics(0), windll.user32.GetSystemMetrics(1)
def check(values, task, desktop=None, env=None):
"""返回问题列表; 空列表表示可以启动。"""
env = os.environ if env is None else env
problems = []
lunacy = values.get('set_lunacy_to_enkephalin', 0)
if lunacy and task != 'enkephalin' and env.get(ALLOW_LUNACY_ENV) != '1':
problems.append(
'set_lunacy_to_enkephalin=%s: 体力不足时会花狂气换体力。狂气只用于抽卡, 请在 AALC 里改成 0'
'(确需使用时设环境变量 %s=1)' % (lunacy, ALLOW_LUNACY_ENV))
# all 只在 AALC 里勾选了镜牢时才会编队
if task == 'mirror' or (task == 'all' and values.get('mirror')):
teams = values.get('teams', {})
for num in values.get('teams_active_queue', []):
team = teams.get(str(num))
if team is None:
problems.append('teams_active_queue 里的队伍 %s 没有配置' % num)
continue
order = list(team.get('sinner_order') or [])
# team_formation 从 1 开始按顺序找罪人, 缺 1 就一个都不选, 然后无限重试编队
if 1 not in order:
problems.append(
'队伍 %s 的 sinner_order 没有罪人(全是 0): 镜牢编队会选空队伍并无限重试。'
'在 AALC 队伍设置里勾选罪人并排序' % num)
if not values.get('simulator') and desktop:
size = values.get('set_win_size', 0)
need_w = int(size * 16 / 9) + FRAME_W
need_h = size + FRAME_H
if need_w > desktop[0] or need_h > desktop[1]:
problems.append(
'set_win_size=%s 需要 %sx%s 的窗口(含标题栏), 桌面只有 %sx%s: 窗口会被压扁成非 16:9,'
' 模板匹配全部失效。改小 set_win_size(如 720)或调大桌面分辨率'
% (size, need_w, need_h, desktop[0], desktop[1]))
return problems