{"record":{"id":"746fc53e852e77b5","repo":"babalae/better-genshin-impact","slug":"targetquantity-actualquanti","errorCode":null,"errorMessage":"滑块调整合成个数后校验失败，目标 {targetQuantity}，当前 {actualQuantity}。","messagePattern":"滑块调整合成个数后校验失败，目标 (.+?)，当前 (.+?)。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":420,"sourceCode":"\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++;\n        }\n\n        while (actualQuantity > targetQuantity)\n        {\n            GameCaptureRegion.GameRegion1080PPosClick(reduceButton.X, reduceButton.Y);\n            await Delay(60, _ct);\n            actualQuantity--;\n        }\n\n        await Delay(200, _ct);","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L402-L438","documentation":"Thrown when, after dragging the slider and one retry drag, the recognized current quantity is still more than 30 away from the target. It indicates the slider-to-quantity mapping is imprecise at this target ratio and the fine-adjustment buttons have not yet been engaged.","triggerScenarios":"targetQuantity is mid-range, DragSliderToRatio lands the handle off by many units (slider geometry non-linear), and a second identical drag does not converge. Concretely Math.Abs(actualQuantity - targetQuantity) > 30 holds on both the first and the retry read.","commonSituations":"The game slider's pixel-to-quantity curve is non-linear so the linear ratio interpolation overshoots; DPI/scale mismatch makes the dragged distance wrong; the slider handle was not grabbed (click landed beside it) so the ratio never changed.","solutions":["Improve the ratio->quantity model: drag, read, then compute a corrected ratio from the error instead of repeating the identical drag.","Verify the slider grab point (sliderStartX 1173, Y 672) actually contacts the handle at the current scale.","Widen the tolerance band before switching to fine add/reduce clicks, since the subsequent while-loops correct small offsets deterministically.","Log ratio, targetQuantity, and actualQuantity each attempt to calibrate the non-linear curve."],"exampleFix":"// before\nawait DragSliderToRatio(ratio);\nawait Delay(350, _ct);\nactualQuantity = ReadCurrentCraftQuantity();\nif (actualQuantity <= 0 || Math.Abs(actualQuantity - targetQuantity) > 30)\n{\n    throw new InvalidOperationException($\"滑块调整合成个数后校验失败，目标 {targetQuantity}，当前 {actualQuantity}。\");\n}\n\n// after: correct ratio from observed error before giving up\nif (Math.Abs(actualQuantity - targetQuantity) > 30 && maxQuantity > 1)\n{\n    var corrected = Math.Clamp(ratio + (targetQuantity - actualQuantity) / (double)(maxQuantity - 1), 0d, 1d);\n    await DragSliderToRatio(corrected);\n    await Delay(350, _ct);\n    actualQuantity = ReadCurrentCraftQuantity();\n}\nif (actualQuantity <= 0 || Math.Abs(actualQuantity - targetQuantity) > 30)\n{\n    throw new InvalidOperationException($\"滑块调整合成个数后校验失败，目标 {targetQuantity}，当前 {actualQuantity}。\");\n}","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { await SetCraftQuantity(target); }\ncatch (InvalidOperationException e) when (e.Message.Contains(\"滑块调整合成个数后校验失败\"))\n{ /* fall back to pure fine-tune clicks from min/max instead of slider ratio */ }","preventionTips":["Calibrate the slider ratio->quantity curve offline so the linear interpolation is accurate.","After the first drag, correct the ratio using the observed error rather than repeating the same drag.","Keep the post-drag delay long enough for the field to settle before reading."],"tags":["ocr","crafting","slider","calibration"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}