- 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>
75 lines
3.9 KiB
PowerShell
75 lines
3.9 KiB
PowerShell
# 注册无人值守用的两个计划任务 (在跑游戏的那个账号下, 普通 PowerShell 即可):
|
|
# LcMCPKeepDisplay 每 5 分钟跑 keep_display.ps1: 会话掉到 Disc 时重挂 console, 防止截图全黑
|
|
# LcMCPDailyCycle 每天定时跑 auto_cycle.py: 刷材料 -> 镜牢 -> 升级/同步, 报告写到 ~\lc_mcp\cycles
|
|
#
|
|
# 用法:
|
|
# powershell -ExecutionPolicy Bypass -File scripts\install_unattended.ps1
|
|
# 可选: -At 05:30 每日运行时间。游戏每日重置为 06:00 (KST), 即北京时间 05:00
|
|
# -Mirror 1 每轮镜牢局数, 0 = 不打镜牢
|
|
# -Target 34 把队内人格升到的等级
|
|
# -Python <路径> 默认 vendor\aalc\.venv\Scripts\pythonw.exe (无窗口, 不抢游戏焦点)
|
|
# -NoWatchdog 只装每日任务
|
|
# -Uninstall
|
|
#
|
|
# 前提: LcMCPServer 已用 install_logon_task.ps1 装好并在运行。
|
|
# 先手动跑一轮确认无误再装: python scripts\auto_cycle.py --mirror 1
|
|
param(
|
|
[string]$At = "05:30",
|
|
[int]$Mirror = 1,
|
|
[int]$Target = 34,
|
|
[string]$Python = "",
|
|
[switch]$NoWatchdog,
|
|
[switch]$Uninstall
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$Repo = Split-Path -Parent $PSScriptRoot
|
|
$Watchdog = "LcMCPKeepDisplay"
|
|
$Daily = "LcMCPDailyCycle"
|
|
|
|
if ($Uninstall) {
|
|
foreach ($name in @($Watchdog, $Daily)) {
|
|
Unregister-ScheduledTask -TaskName $name -Confirm:$false -ErrorAction SilentlyContinue
|
|
Write-Output "removed $name"
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
if (-not $Python) { $Python = Join-Path $Repo "vendor\aalc\.venv\Scripts\pythonw.exe" }
|
|
if (-not (Test-Path $Python)) {
|
|
throw "找不到 Python: $Python`n先在 vendor\aalc 里执行 uv sync, 或用 -Python 指定"
|
|
}
|
|
if (-not (Get-ScheduledTask -TaskName "LcMCPServer" -ErrorAction SilentlyContinue)) {
|
|
Write-Warning "没有找到 LcMCPServer 计划任务, 每日任务需要它: 先运行 scripts\install_logon_task.ps1"
|
|
}
|
|
|
|
$user = "$env:USERDOMAIN\$env:USERNAME"
|
|
# Limited: keep_display.ps1 自己用 RunAs 静默提权跑 tscon (需要 ConsentPromptBehaviorAdmin=0)
|
|
$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited
|
|
|
|
if (-not $NoWatchdog) {
|
|
$ps = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe"
|
|
$script = Join-Path $PSScriptRoot "keep_display.ps1"
|
|
$action = New-ScheduledTaskAction -Execute $ps -WorkingDirectory $Repo `
|
|
-Argument "-NoProfile -NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$script`""
|
|
$trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) `
|
|
-RepetitionInterval (New-TimeSpan -Minutes 5) -RepetitionDuration (New-TimeSpan -Days 3650)
|
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
|
|
-ExecutionTimeLimit (New-TimeSpan -Minutes 3) -MultipleInstances IgnoreNew
|
|
Register-ScheduledTask -TaskName $Watchdog -Action $action -Trigger $trigger -Principal $principal `
|
|
-Settings $settings -Force | Out-Null
|
|
Write-Output "registered $Watchdog (every 5 min) -> $script"
|
|
}
|
|
|
|
$cycle = Join-Path $PSScriptRoot "auto_cycle.py"
|
|
$action = New-ScheduledTaskAction -Execute $Python -WorkingDirectory $Repo `
|
|
-Argument "-X utf8 `"$cycle`" --mirror $Mirror --target $Target"
|
|
$trigger = New-ScheduledTaskTrigger -Daily -At $At
|
|
# 一轮 daily 约 20 分钟, 每局镜牢约 40 分钟; 超过上限由计划任务强杀
|
|
$limit = New-TimeSpan -Minutes (60 + 75 * [Math]::Max($Mirror, 0))
|
|
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
|
|
-StartWhenAvailable -ExecutionTimeLimit $limit -MultipleInstances IgnoreNew
|
|
Register-ScheduledTask -TaskName $Daily -Action $action -Trigger $trigger -Principal $principal `
|
|
-Settings $settings -Force | Out-Null
|
|
Write-Output "registered $Daily (daily at $At, mirror=$Mirror, target=Lv.$Target, limit=$limit)"
|
|
Write-Output "reports -> $env:USERPROFILE\lc_mcp\cycles\cycle_*.json"
|