{"record":{"id":"7b143b5793915393","repo":"babalae/better-genshin-impact","slug":"error-7b143b","errorCode":null,"errorMessage":"战斗脚本格式错误，指令括号不完整","messagePattern":"战斗脚本格式错误，指令括号不完整","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoFight/Script/CombatScriptParser.cs","lineNumber":261,"sourceCode":"                    if (command.Count(\"(\".Contains) > 1)\n                    {\n                        Logger.LogError(\"战斗脚本格式错误，指令 {Cmd} 括号无法配对\", command);\n                        throw new Exception(\"战斗脚本格式错误，指令括号无法配对\");\n                    }\n\n                    if (command.Contains(')'))\n                    {\n                        i = j;\n                        break;\n                    }\n\n                    j++;\n                }\n\n                if (!(command.Contains('(') && command.Contains(')')))\n                {\n                    Logger.LogError(\"战斗脚本格式错误，指令 {Cmd} 括号不完整\", command);\n                    throw new Exception(\"战斗脚本格式错误，指令括号不完整\");\n                }\n            }\n\n            var combatCommand = new CombatCommand(avatarName, command);\n            oneLineCombatCommands.Add(combatCommand);\n        }\n\n        return oneLineCombatCommands;\n    }\n}","sourceCodeStart":243,"sourceCodeEnd":271,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoFight/Script/CombatScriptParser.cs#L243-L271","documentation":"Thrown by CombatScriptParser.ParseLinePart after the comma-merge loop exhausts all remaining fragments without ever finding a ')' to close the opening '('. The command started with '(' but no ')' was found in any subsequent comma-separated fragment, so the parser cannot form a complete command and aborts.","triggerScenarios":"A TXT combat script line where a command token starts with '(' but the line ends (or the '|' separator is hit after splitting) before a ')' appears. For example: `香菱 skill(1,e(2)` — the last ')' is missing, or `香菱 walk(s, 0.2` where the closing ')' was accidentally deleted.","commonSituations":"User edits a combat script and accidentally deletes a ')', or a copy-paste truncates the line. Also possible when '|' separators are used mid-parenthesis, causing the split to isolate an unclosed fragment.","solutions":["Check the logged {Cmd} to see exactly which command is missing its ')'.","Add the missing ')' at the end of the command.","If using '|' to separate action groups, ensure each group is fully closed before the '|'.","Use the JSON strategy format which has structural validation and better error messages."],"exampleFix":"// before (missing closing paren)\n// 香菱 skill(1,e(2)\n\n// after\n// 香菱 skill(1),e(2)","handlingStrategy":"validation","validationCode":"// Check that every '(' has a matching ')' in each pipe-separated segment\nstatic bool AllSegmentsClosed(string line)\n{\n    foreach (var segment in line.Split('|', StringSplitOptions.RemoveEmptyEntries))\n    {\n        var open = segment.Count(c => c == '(');\n        var close = segment.Count(c => c == ')');\n        if (open != close) return false;\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var script = CombatScriptParser.ParseContext(text);\n}\ncatch (Exception e) when (e.Message.Contains(\"括号不完整\"))\n{\n    Logger.LogWarning(\"战斗脚本括号不完整，缺少右括号：{Msg}\", e.Message);\n}","preventionTips":["After editing a script, do a quick parenthesis count — every '(' must have a ')'.","Pay special attention to the last command on each line — that is where ')' is most commonly forgotten.","Use the JSON strategy format for better structural validation and error messages."],"tags":["combat-script","parser","txt-script","parentheses"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}