babalae/better-genshin-impact · error · Exception

战斗策略文件不存在

Error message

战斗策略文件不存在

What it means

Thrown by AutoFightHandler.GetFightStrategy when config.StrategyName is set (not empty and not '根据队伍自动选择'), AutoFightParam.ResolveStrategyPath resolves a file path, but File.Exists(path) is false. The combat strategy file referenced by the pathing/auto-fight config is missing.

Source

Thrown at BetterGenshinImpact/GameTask/AutoPathing/Handler/AutoFightHandler.cs:93

    }

    private AutoFightParam GetFightAutoFightParam(AutoFightConfig? config)
    {
        AutoFightParam autoFightParam = new AutoFightParam(GetFightStrategy(config), config);
        return autoFightParam;
    }

    private string GetFightStrategy(AutoFightConfig config)
    {
        if ("根据队伍自动选择".Equals(config.StrategyName) || string.IsNullOrEmpty(config.StrategyName))
        {
            return Global.Absolute(@"User\AutoFight\");
        }

        var (path, _) = AutoFightParam.ResolveStrategyPath(config.StrategyName);
        if (!File.Exists(path))
        {
            throw new Exception("战斗策略文件不存在");
        }

        return path;
    }

    private string GetFightStrategy()
    {
        return GetFightStrategy(TaskContext.Instance().Config.AutoFightConfig);
    }
}

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Verify the resolved path exists (log ResolveStrategyPath's output).
  2. Restore the strategy file under User\AutoFight.
  3. Set StrategyName to '根据队伍自动选择' or empty to use directory-based auto selection.
  4. Create the missing strategy file or pick an existing one.
Defensive patterns

Strategy: validation

Validate before calling

var (path, _) = AutoFightParam.ResolveStrategyPath(config.StrategyName);
if (!File.Exists(path))
{
    throw new FileNotFoundException($"战斗策略文件不存在: {path}", path);
}

Type guard

bool FightStrategyFileExists(string strategyName)
{
    if (string.IsNullOrEmpty(strategyName) || strategyName == "根据队伍自动选择") return true;
    var (p, _) = AutoFightParam.ResolveStrategyPath(strategyName);
    return File.Exists(p);
}

Prevention

When it happens

Trigger: GetFightStrategy(config) with a concrete StrategyName; ResolveStrategyPath returns a path; File.Exists is false → throw. (Note: unlike the ley-line variant 267, this only checks File.Exists, not Directory.Exists.)

Common situations: Strategy file deleted/renamed; fresh install missing User\AutoFight strategy files; StrategyName in the party/auto-fight config points to a nonexistent file.

Related errors


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