{"record":{"id":"d22d7b05542de626","repo":"babalae/better-genshin-impact","slug":"pathingtask-successfight-fightco","errorCode":null,"errorMessage":"实际战斗次数({pathingTask.SuccessFight})<预期战斗次数（{fightCount}），判定失败，触发异常！","messagePattern":"实际战斗次数\\((.+?)\\)<预期战斗次数（(.+?)），判定失败，触发异常！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs","lineNumber":277,"sourceCode":"            if (task.FarmingInfo.AllowFarmingCount)\n            {\n                var successFight = pathingTask.SuccessEnd;\n                var fightCount = 0;\n               \n                //未走完完整路径下，才校验打架次数\n                if (!successFight)\n                {\n                    fightCount = task.Positions.Count(pos => pos.Action == ActionEnum.Fight.Code);\n                    successFight = pathingTask.SuccessFight >= fightCount;\n                    //判断为锄地脚本\n                    if (task.FarmingInfo.PrimaryTarget!=\"disable\")\n                    {\n\n                        if (autoRestart.Enabled\n                            &&autoRestart.IsFightFailureExceptional\n                            &&!successFight)\n                        {\n                            throw new Exception($\"实际战斗次数({pathingTask.SuccessFight})<预期战斗次数（{fightCount}），判定失败，触发异常！\");\n                        }\n                    }\n                }\n\n                if (successFight)\n                {\n                    //每日锄地记录\n                    FarmingStatsRecorder.RecordFarmingSession(task.FarmingInfo, new FarmingRouteInfo\n                    {\n                        GroupName = GroupInfo?.Name ?? \"\",\n                        FolderName = FolderName,\n                        ProjectName = Name\n                    });\n                }\n                else\n                {\n                    TaskControl.Logger.LogWarning($\"实际战斗次数({pathingTask.SuccessFight})<预期战斗次数（{fightCount}），判定失败，此次不纳入成功锄地规划的统计上限！\");\n                }","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/Group/ScriptGroupProject.cs#L259-L295","documentation":"Thrown when the actual fight count (pathingTask.SuccessFight) is less than the expected fight count derived from the pathing JSON's Fight-type positions, but only for farming scripts (PrimaryTarget != 'disable') when AutoRestart is enabled and IsFightFailureExceptional is true. This validates that all expected combats were engaged during a farming route.","triggerScenarios":"Executing a Pathing task where task.FarmingInfo.AllowFarmingCount is true, the route didn't fully complete (SuccessEnd=false), pathingTask.SuccessFight < number of positions with Action == Fight, and FarmingInfo.PrimaryTarget is not 'disable', with autoRestart.Enabled and autoRestart.IsFightFailureExceptional both true.","commonSituations":"Enemies were not detected or engaged during farming. The pathing script skipped combat positions due to navigation issues. Enemy detection threshold too high or combat interrupted by game events. This is a quality-assurance check for farming route completion.","solutions":["If you don't want auto-restart on fight failures, disable IsFightFailureExceptional in AutoRestartConfig.","Review the pathing JSON — reduce expected Fight positions or improve combat waypoints.","Check combat detection settings and enemy recognition thresholds.","Verify the game is in the correct state (not in dialogue, menus, etc.) during farming."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    await project.Run();\n}\ncatch (Exception ex) when (ex.Message.Contains(\"实际战斗次数\"))\n{\n    TaskControl.Logger.LogWarning(\"Fight count mismatch: {Message}\", ex.Message);\n    // Log detailed farming stats, retry or skip\n}","preventionTips":["Disable IsFightFailureExceptional if fight count strictness is too aggressive.","Tune enemy detection and combat engagement settings.","Review pathing JSON Fight positions to ensure they match actual enemy locations."],"tags":["pathing","farming","auto-restart","script-execution","game-automation"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}