{"record":{"id":"5d5ab20d4a4ea905","repo":"babalae/better-genshin-impact","slug":"error-5d5ab2","errorCode":null,"errorMessage":"识别骰子数量不正确,重试超时,停止自动打牌！","messagePattern":"识别骰子数量不正确,重试超时,停止自动打牌！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs","lineNumber":552,"sourceCode":"\n        _logger.LogInformation(\"保留{Msg}骰子\", msg);\n        Sleep(5000);\n        var retryCount = 0;\n        // 保留 x、万能 骰子\n        while (!RollPhaseReRoll(holdElementalTypes))\n        {\n            retryCount++;\n\n            if (IsDuelEnd())\n            {\n                throw new NormalEndException(\"对战已结束,停止自动打牌！\");\n            }\n\n            //MyLogger.Debug(\"识别骰子数量不正确,第{}次重试中...\", retryCount);\n            Sleep(500);\n            if (retryCount > 35)\n            {\n                throw new System.Exception(\"识别骰子数量不正确,重试超时,停止自动打牌！\");\n            }\n        }\n\n        ClickConfirm();\n        _logger.LogInformation(\"选择需要重投的骰子后点击确认完毕\");\n\n        Sleep(1000);\n        // 鼠标移动到中心\n        ClickGameWindowCenter();\n\n        _logger.LogInformation(\"等待5s对方重投\");\n        Sleep(5000);\n    }\n\n    public Point MakeOffset(Point p)\n    {\n        var rect = TaskContext.Instance().SystemInfo.CaptureAreaRect;\n        return new Point(rect.X + p.X, rect.Y + p.Y);","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs#L534-L570","documentation":"Thrown by GeniusInvokationControl.ReRollDice when RollPhaseReRoll returns false for more than 35 consecutive retries (each with a 500ms sleep, totaling ~17.5s). RollPhaseReRoll performs OCR dice recognition during the reroll phase; if it consistently fails to recognize the correct dice layout, the abort guard fires.","triggerScenarios":"During the TCG dice reroll phase, the screen capture + OCR pipeline consistently returns an invalid dice count or layout. The duel is checked for IsDuelEnd between retries, but after 35 failures the method gives up. Root causes: resolution mismatch, UI遮挡 (overlay covering dice), game not fully rendered, or OCR template failure.","commonSituations":"Game running at unsupported resolution, dice area partially obscured by another window or overlay, game not in focus, capture region misconfigured, or game UI changed after an update breaking dice recognition templates. Slow GPU rendering can cause the dice animation to not have settled within the retry window.","solutions":["Ensure the game runs at a supported resolution (typically 1920x1080) in windowed or borderless mode.","Close overlays (RTSS, Discord overlay, etc.) that may cover the dice area.","Verify the capture region is correctly set to the game window.","Check that the game is fully in focus and the reroll phase UI is fully rendered before the script starts.","If the issue persists, it may indicate dice recognition templates need updating after a game patch."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Wrap the TCG task in a top-level try-catch to handle OCR failures gracefully\ntry\n{\n    control.ReRollDice(holdTypes);\n}\ncatch (Exception e) when (e.Message.Contains(\"识别骰子数量不正确\"))\n{\n    _logger.LogError(\"骰子识别失败，停止自动打牌: {Msg}\", e.Message);\n    // Notify user to check resolution, game focus, and overlays\n}","preventionTips":["Run the game at 1920x1080 (the supported resolution for OCR templates).","Close all overlays (RTSS, Discord, GeForce Experience) that may cover the dice area.","Ensure the game window is in focus and fully rendered before TCG automation starts.","Keep the capture region correctly set to the game window.","After game patches, dice recognition templates may need updates."],"tags":["tcg","auto-genius-invokation","ocr","dice","timeout","retry-exhausted"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}