diff --git a/scripts/install_unattended.ps1 b/scripts/install_unattended.ps1 index 883923b..d99090c 100644 --- a/scripts/install_unattended.ps1 +++ b/scripts/install_unattended.ps1 @@ -5,7 +5,8 @@ # 用法: # powershell -ExecutionPolicy Bypass -File scripts\install_unattended.ps1 # 可选: -At 05:30 每日运行时间。游戏每日重置为 06:00 (KST), 即北京时间 05:00 -# -EveryHours 2 改成"每 N 小时重复一轮"以持续刷取; 0 = 只按 -At 每天一次 +# -EveryHours 2.5 改成"每 N 小时重复一轮"以持续刷取; 0 = 只按 -At 每天一次 +# 单轮上限 = 60 + 75*Mirror 分钟, 间隔要大于它, 否则会被跳过 # -Mirror 1 每轮镜牢局数, 0 = 不打镜牢 # -Target 34 把队内人格升到的等级 # -Python <路径> 默认 vendor\aalc\.venv\Scripts\pythonw.exe (无窗口, 不抢游戏焦点) @@ -16,7 +17,7 @@ # 先手动跑一轮确认无误再装: python scripts\auto_cycle.py --mirror 1 param( [string]$At = "05:30", - [int]$EveryHours = 0, + [double]$EveryHours = 0, [int]$Mirror = 1, [int]$Target = 34, [string]$Python = "", @@ -65,17 +66,18 @@ if (-not $NoWatchdog) { $cycle = Join-Path $PSScriptRoot "auto_cycle.py" $action = New-ScheduledTaskAction -Execute $Python -WorkingDirectory $Repo ` -Argument "-X utf8 `"$cycle`" --mirror $Mirror --target $Target" -# 一轮 daily 约 20 分钟, 每局镜牢约 40 分钟; 超过上限由计划任务强杀 +# 一轮 daily 约 22 分钟, 每局镜牢实测 39~>70 分钟; 超过上限由计划任务强杀 $limit = New-TimeSpan -Minutes (60 + 75 * [Math]::Max($Mirror, 0)) if ($EveryHours -gt 0) { # 持续刷取: 每 N 小时重复一轮。开始时间取"现在", 装完即进入节奏。 + # 注意 New-TimeSpan -Hours 的参数是 [int], 传 2.5 会被截断成 2 小时, 所以用 -Minutes。 $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(1) ` - -RepetitionInterval (New-TimeSpan -Hours $EveryHours) ` + -RepetitionInterval (New-TimeSpan -Minutes ($EveryHours * 60)) ` -RepetitionDuration (New-TimeSpan -Days 3650) $desc = "every $EveryHours h" # 重复周期必须大于单轮上限, 否则会在上一轮还没结束时又起一轮 - if ((New-TimeSpan -Hours $EveryHours) -lt $limit) { - Write-Warning "EveryHours=$EveryHours 短于单轮上限 $limit, 可能重叠; MultipleInstances=IgnoreNew 会跳过, 但建议调大" + if (($EveryHours * 60) -lt $limit.TotalMinutes) { + Write-Warning "EveryHours=$EveryHours ($($EveryHours * 60) 分钟) 短于单轮上限 $limit, 可能重叠; MultipleInstances=IgnoreNew 会跳过, 但建议调大" } } else { $trigger = New-ScheduledTaskTrigger -Daily -At $At