{"record":{"id":"04d631c0a23f8d62","repo":"babalae/better-genshin-impact","slug":"error-04d631","errorCode":null,"errorMessage":"骰子数量与预期不符，重试次数过多，可能出现了未知错误！","messagePattern":"骰子数量与预期不符，重试次数过多，可能出现了未知错误！","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs","lineNumber":773,"sourceCode":"    /// </summary>\n    /// <param name=\"skillIndex\">技能编号,从右往左数,从1开始</param>\n    /// <param name=\"diceCost\">技能消耗骰子数</param>\n    /// <param name=\"elementalType\">消耗骰子元素类型</param>\n    /// <param name=\"duel\">对局对象</param>\n    /// <returns>手牌或者元素骰子是否充足</returns>\n    public bool ActionPhaseAutoUseSkill(int skillIndex, int diceCost, ElementalType elementalType, Duel duel)\n    {\n        var dice9RetryCount = 0;\n        var retryCount = 0;\n        var diceStatus = ActionPhaseDice();\n        while (true)\n        {\n            int dCount = diceStatus.Sum(x => x.Value);\n            if (dCount != duel.CurrentDiceCount)\n            {\n                if (retryCount > 20)\n                {\n                    throw new System.Exception(\"骰子数量与预期不符，重试次数过多，可能出现了未知错误！\");\n                }\n\n                if (dCount == 9 && duel.CurrentDiceCount == 8 && diceStatus[ElementalType.Omni.ToLowerString()] > 0)\n                {\n                    dice9RetryCount++;\n                    if (dice9RetryCount > 5)\n                    {\n                        // 支援区存在 鲸井小弟 情况下骰子数量增加导致识别出错的问题 #1\n                        // 5次重试后仍然是9个骰子并且至少有一个万能骰子，出现多识别的情况是很稀少的，此时可以基本认为 支援区存在 鲸井小弟\n                        // TODO : 但是这个方法并不是100%准确，后续需要添加支援区判断\n                        _logger.LogInformation(\"期望的骰子数量8，应为开局期望，重试多次后累计实际识别9个骰子的情况为5次\");\n                        duel.CurrentDiceCount = 9; // 修正当前骰子数量\n                        break;\n                    }\n                }\n\n                _logger.LogInformation(\"当前骰子数量{Count}与期望的骰子数量{Expect}不相等，重试\", dCount, duel.CurrentDiceCount);\n                diceStatus = ActionPhaseDice();","sourceCodeStart":755,"sourceCodeEnd":791,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs#L755-L791","documentation":"Thrown by GeniusInvokationControl.ActionPhaseAutoUseSkill when the recognized dice count (dCount) does not match the expected count (duel.CurrentDiceCount) after more than 20 retries (each ~1s sleep). A special case handles 9-vs-8 dice with a Omni dice present (鲸井小弟 support card) by allowing up to 5 additional retries before correcting to 9, but all other mismatches abort after 20 retries.","triggerScenarios":"During the action phase, ActionPhaseDice OCR returns a dice count that consistently differs from what the duel state expects. This could be recognition errors (miscount), game state desync (dice actually changed due to card effects the tracker didn't account for), or visual interference. The 9-vs-8 special case handles one known card effect; all others are treated as errors.","commonSituations":"Unsupported resolution or visual interference causing dice miscount. Game patches introducing new card effects that alter dice count in ways the tracker doesn't model. Visual artifacts from animations not fully settled. The known 鲸井小弟 workaround suggests other unmodeled card effects could cause the same failure.","solutions":["Ensure correct game resolution (1920x1080) and unobstructed capture.","Check if a new TCG card/support effect is altering dice counts that the tracker doesn't model — report it.","Wait for game animations to settle — the retry loop has 1s sleeps but complex animations may need longer.","If the issue is reproducible with specific card combinations, it indicates a missing game-mechanic model, not a transient error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    control.ActionPhaseAutoUseSkill(skillIndex, diceCost, elementalType, duel);\n}\ncatch (Exception e) when (e.Message.Contains(\"骰子数量与预期不符\"))\n{\n    _logger.LogError(\"骰子识别持续不一致，停止打牌: {Msg}\", e.Message);\n    // This often indicates a game state desync or unmodeled card effect\n}","preventionTips":["Ensure correct resolution (1920x1080) and unobstructed capture for reliable dice OCR.","Be aware that certain support cards (like 鲸井小弟) can alter dice counts — the tracker handles one known case but not all.","After game patches introducing new TCG cards, dice-count effects may need modeling.","If reproducible with specific card combos, report it as a missing game-mechanic model."],"tags":["tcg","auto-genius-invokation","ocr","dice","timeout","retry-exhausted","state-desync"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}