{"record":{"id":"2698f9734078f646","repo":"babalae/better-genshin-impact","slug":"error-2698f9","errorCode":null,"errorMessage":"未能读取当前合成个数。","messagePattern":"未能读取当前合成个数。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":410,"sourceCode":"            throw new InvalidOperationException($\"材料不足以合成指定个数，目标 {targetQuantity}，当前最多可合成 {maxQuantity}。\");\n        }\n\n        if (maxQuantity == 1)\n        {\n            return 1;\n        }\n\n        await DragSliderToRatio(0);\n        await Delay(250, _ct);\n\n        var ratio = Math.Clamp((targetQuantity - 1d) / (maxQuantity - 1d), 0d, 1d);\n        await DragSliderToRatio(ratio);\n        await Delay(350, _ct);\n\n        var actualQuantity = ReadCurrentCraftQuantity();\n        if (actualQuantity <= 0)\n        {\n            throw new InvalidOperationException(\"未能读取当前合成个数。\");\n        }\n\n        if (Math.Abs(actualQuantity - targetQuantity) > 30)\n        {\n            await DragSliderToRatio(ratio);\n            await Delay(350, _ct);\n            actualQuantity = ReadCurrentCraftQuantity();\n            if (actualQuantity <= 0 || Math.Abs(actualQuantity - targetQuantity) > 30)\n            {\n                throw new InvalidOperationException($\"滑块调整合成个数后校验失败，目标 {targetQuantity}，当前 {actualQuantity}。\");\n            }\n        }\n\n        while (actualQuantity < targetQuantity)\n        {\n            GameCaptureRegion.GameRegion1080PPosClick(addButton.X, addButton.Y);\n            await Delay(60, _ct);\n            actualQuantity++;","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L392-L428","documentation":"Thrown after the craft-quantity slider is dragged to the target ratio when ReadCurrentCraftQuantity() returns a non-positive value. ReadCurrentCraftQuantity OCRs the current-quantity text at Rect1080(1248,615,221,34) and parses the first positive integer. A zero return means the OCR region produced no parseable digits.","triggerScenarios":"DragSliderToRatio(ratio) completes but the number at the quantity field is not recognized — text region misaligned, the field is obscured, the slider did not actually move, or OCR (Paddle) returned garbage/full-width characters that StringUtils.ConvertFullWidthNumToHalfWidth + ReadFirstPositiveInt cannot parse.","commonSituations":"Game resolution or capture scale changed so the 1080p-derived Rect no longer sits on the number; the slider drag was dropped early and the field still shows a placeholder; a localization/font change makes digits unrecognizable; transient capture where the field is mid-animation.","solutions":["Confirm the capture rect Rect1080(1248,615,221,34) aligns with the current-quantity field in the running game.","Verify DragSliderToRatio actually moved the handle (check the mouse-down/up path and the 12-step interpolation).","Add one extra re-read with a delay before failing, since OCR misses are often transient.","Log the raw OCR text (via ReadOcrText) when the parse returns 0 to diagnose which character is unreadable."],"exampleFix":"// before\nvar actualQuantity = ReadCurrentCraftQuantity();\nif (actualQuantity <= 0)\n{\n    throw new InvalidOperationException(\"未能读取当前合成个数。\");\n}\n\n// after: re-read once and log raw text on failure\nvar actualQuantity = ReadCurrentCraftQuantity();\nif (actualQuantity <= 0)\n{\n    await Delay(300, _ct);\n    actualQuantity = ReadCurrentCraftQuantity();\n}\nif (actualQuantity <= 0)\n{\n    Logger.LogWarning(\"当前合成个数 OCR 原文：{Raw}\", ReadOcrText(Rect1080(1248, 615, 221, 34)));\n    throw new InvalidOperationException(\"未能读取当前合成个数。\");\n}","handlingStrategy":"retry","validationCode":"// Pre-validate the OCR region is on a populated field\nvar raw = ReadOcrText(Rect1080(1248, 615, 221, 34));\nif (string.IsNullOrWhiteSpace(StringUtils.RemoveAllSpace(raw)))\n    Logger.LogWarning(\"合成个数区域为空，可能未对齐\");","typeGuard":"null","tryCatchPattern":"try { await SetCraftQuantity(target); }\ncatch (InvalidOperationException e) when (e.Message.Contains(\"未能读取当前合成个数\"))\n{ /* re-orient / re-drag, then retry once */ }","preventionTips":["Re-read OCR after a short delay before treating <= 0 as fatal.","Log the raw OCR text whenever a parse returns 0 to catch region drift early.","Keep the 1080p capture rect constants in one place so a game layout change is a single edit."],"tags":["ocr","crafting","slider","genshin-ui"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}