babalae/better-genshin-impact · warning · Exception

指定讨伐次数必须大于 0

Error message

指定讨伐次数必须大于 0

What it means

当 SpecifyRunCount=true(指定讨伐次数模式)时,RunCount 必须 ≥ 1,否则抛 Exception。确保指定次数模式有有效执行次数。

Source

Thrown at BetterGenshinImpact/GameTask/AutoBoss/AutoBossTask.cs:1005

    {
        if (string.IsNullOrWhiteSpace(_taskParam.BossName))
        {
            throw new Exception("请选择需要讨伐的首领");
        }

        if (!AutoBossData.IsSupportedBoss(_taskParam.BossName))
        {
            throw new Exception($"暂不支持首领:{_taskParam.BossName}");
        }

        if (_taskParam.ReviveRetryCount < 0)
        {
            throw new Exception("角色死亡后重试次数不能小于 0");
        }

        if (_taskParam.SpecifyRunCount && _taskParam.RunCount < 1)
        {
            throw new Exception("指定讨伐次数必须大于 0");
        }

        if (!_taskParam.SpecifyRunCount && (_taskParam.UseTransientResin || _taskParam.UseFragileResin))
        {
            throw new Exception("只有指定讨伐次数模式才能开启须臾树脂或脆弱树脂补充");
        }

        if (string.IsNullOrWhiteSpace(_taskParam.CombatStrategyPath))
        {
            _taskParam.SetCombatStrategyPath(_taskParam.StrategyName);
        }

        if (!File.Exists(_taskParam.CombatStrategyPath) && !Directory.Exists(_taskParam.CombatStrategyPath))
        {
            throw new Exception("当前选择的自动战斗策略文件不存在");
        }

        foreach (var route in GetRequiredRouteFiles(_taskParam.BossName))

View on GitHub (pinned to a7cb36712d)

Solutions

  1. 将 RunCount 设为 ≥ 1 的整数。
  2. 在 UI 用数值控件限定最小值 1。
  3. 开启 SpecifyRunCount 时自动将 RunCount 默认为 1。
Defensive patterns

Strategy: validation

Validate before calling

if (_taskParam.SpecifyRunCount && _taskParam.RunCount < 1)
{
    _taskParam.RunCount = 1; // 或 UI Minimum=1
}

Prevention

When it happens

Trigger: 用户开启指定次数但未填或填 0/负数;UI 默认值未设置;配置迁移产生 0。

Common situations: 手动改配置;UI 控件初始值为 0 未校验;切换 SpecifyRunCount 后未同步 RunCount。

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/3a67295420b42ec5. Report an issue: GitHub.