{"record":{"id":"f53e45857f376aeb","repo":"babalae/better-genshin-impact","slug":"error-f53e45","errorCode":null,"errorMessage":"未能获取到我方角色卡位置","messagePattern":"未能获取到我方角色卡位置","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs","lineNumber":930,"sourceCode":"    /// <summary>\n    /// 出战角色是否被打倒\n    /// </summary>\n    /// <returns></returns>\n    public bool IsActiveCharacterTakenOut()\n    {\n        using var ra = CaptureGameRectArea();\n        return !ra.Find(GetRecognitionObject(\"CharacterTakenOut\", ra)).IsEmpty();\n    }\n\n    /// <summary>\n    /// 哪些出战角色被打倒了\n    /// </summary>\n    /// <returns>true 是已经被打倒</returns>\n    public bool[] WhatCharacterDefeated(List<Rect> rects)\n    {\n        if (rects == null || rects.Count != 3)\n        {\n            throw new System.Exception(\"未能获取到我方角色卡位置\");\n        }\n\n        using var greyMat = CaptureGameGreyMat();\n        var pList = MatchTemplateHelper.MatchTemplateMulti(greyMat, _assets.CharacterDefeatedMat, 0.8);\n\n        var res = new bool[3];\n        foreach (var p in pList)\n        {\n            for (var i = 0; i < rects.Count; i++)\n            {\n                if (IsOverlap(rects[i],\n                        new Rect(p.X, p.Y, _assets.CharacterDefeatedMat.Width, _assets.CharacterDefeatedMat.Height)))\n                {\n                    res[i] = true;\n                }\n            }\n        }\n","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs#L912-L948","documentation":"Thrown by GeniusInvokationControl.WhatCharacterDefeated when the input rects list is null or does not contain exactly 3 elements. The method expects 3 character card rectangles (one per character in the TCG duel) to perform template matching for defeated-character detection. An invalid rects collection means upstream character card position detection failed.","triggerScenarios":"Called from DoWhenCharacterDefeated with duel.CharacterCardRects that is null or has != 3 entries. The character card positions are detected earlier in the duel setup; if that detection failed or returned partial results, this guard fires when a character is defeated and the system tries to determine which one.","commonSituations":"Game resolution or UI layout changes causing character card position detection to fail during duel initialization. The failure cascades: position detection fails silently, then when a character is defeated, WhatCharacterDefeated cannot proceed. Could also occur if the duel started with fewer than 3 characters due to upstream logic errors.","solutions":["Ensure the game runs at a supported resolution (1920x1080) so character card positions are detected correctly during duel setup.","Check logs for earlier warnings about character card position detection during the duel initialization phase.","Verify no overlay or window is obscuring the character card area.","If the issue persists, the character card detection templates may need updating after a game UI patch."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before calling WhatCharacterDefeated, verify character card rects were detected\nif (duel.CharacterCardRects == null || duel.CharacterCardRects.Count != 3)\n{\n    _logger.LogWarning(\"角色卡位置未正确检测，跳过阵亡检测\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var defeated = control.WhatCharacterDefeated(duel.CharacterCardRects);\n}\ncatch (Exception e) when (e.Message.Contains(\"未能获取到我方角色卡位置\"))\n{\n    _logger.LogError(\"角色卡位置检测失败，可能分辨率不正确: {Msg}\", e.Message);\n    // This indicates upstream position detection failed; check resolution and logs\n}","preventionTips":["Ensure 1920x1080 resolution so character card positions are detected during duel setup.","Check for earlier warnings during duel initialization about character card detection.","Keep the game window unobstructed and in focus.","After UI patches, card position templates may need updating."],"tags":["tcg","auto-genius-invokation","character-detection","precondition","ocr"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}