{"record":{"id":"769a6b91c2e4c9af","repo":"babalae/better-genshin-impact","slug":"error-769a6b","errorCode":null,"errorMessage":"未能识别最大可合成个数。","messagePattern":"未能识别最大可合成个数。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":387,"sourceCode":"    {\n        return ContainsText(Rect1080(1139, 112, 401, 39), _materialName);\n    }\n\n    /// <summary>\n    /// 设置本次合成个数并校验最终数量。\n    /// </summary>\n    /// <param name=\"targetQuantity\">目标合成个数。</param>\n    /// <returns>最终校验到的合成个数。</returns>\n    /// <exception cref=\"InvalidOperationException\">最大可合成个数、当前合成个数读取失败，材料不足或最终数量不匹配时抛出。</exception>\n    private async Task<int> SetCraftQuantity(int targetQuantity)\n    {\n        var addButton = (X: 1614, Y: 672);\n        var reduceButton = (X: 1074, Y: 672);\n\n        var maxQuantity = ReadMaxCraftQuantity();\n        if (maxQuantity <= 0)\n        {\n            throw new InvalidOperationException(\"未能识别最大可合成个数。\");\n        }\n\n        if (targetQuantity > maxQuantity)\n        {\n            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);","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L369-L405","documentation":"Thrown as InvalidOperationException by CraftMaterialTask.SetCraftQuantity when ReadMaxCraftQuantity() returns a value <= 0. The method first tries OCR on the max-quantity region (1522,653), then falls back to parsing material fraction text (owned/required). If both approaches yield zero, the task cannot determine how many can be crafted and aborts before slider manipulation.","triggerScenarios":"The selected material detail panel does not show a readable max-quantity number or material fraction text. OCR failed on both the numeric region and the fraction region. The screenshot is blurry, wrong resolution, or the UI element was occluded.","commonSituations":"The crafting UI did not fully load the detail panel after material selection. Non-1080p resolution causes Rect1080 to crop the wrong area. OCR engine misread full-width digits or the text was rendered with unusual fonts. A game update changed the UI layout/positions.","solutions":["Add a delay after selecting the material to let the detail panel render fully before reading quantity.","Verify the game resolution is 1080p or that the scale ratio is correct.","If UI positions changed in a game update, update the Rect1080 coordinates for max-quantity and fraction text regions."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"for (int attempt = 0; attempt < 3; attempt++)\n{\n    try { await task.Start(ct); break; }\n    catch (InvalidOperationException ex) when (ex.Message.Contains(\"最大可合成个数\")) { /* wait for UI, retry */ } }","preventionTips":["Add a delay after material selection to let the detail panel render.","Ensure the game runs at 1080p or correct scale for OCR region accuracy."],"tags":["crafting","ocr","ui-layout","resolution"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}