{"record":{"id":"518b1db30d4816d0","repo":"babalae/better-genshin-impact","slug":"expectedteamcount-l","errorCode":null,"errorMessage":"切换角色：角色列表队伍识别不完整，期望 {expectedTeamCount} 个，末次检测到 {lastDetectedCardCount} 张卡片，成功识别 {characterNames.Count(name => name != null)} 个头像","messagePattern":"切换角色：角色列表队伍识别不完整，期望 (.+?) 个，末次检测到 (.+?) 张卡片，成功识别 (.+?) 个头像","errorType":"exception","errorClass":"PartySetupFailedException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs","lineNumber":1444,"sourceCode":"        }\n        finally\n        {\n            Simulation.SendInput.Keyboard.KeyPress(Vanara.PInvoke.User32.VK.VK_ESCAPE);\n        }\n\n        var returned = await NewRetry.WaitForAction(() =>\n        {\n            using var capture = CaptureToRectArea();\n            return IsPartyConfigPage(capture);\n        }, ct, 10, 300);\n        if (!returned)\n        {\n            throw new PartySetupFailedException(\"切换角色：角色列表关闭后未返回队伍配置页\");\n        }\n\n        if (characterNames.Count != expectedTeamCount || characterNames.Any(string.IsNullOrEmpty))\n        {\n            throw new PartySetupFailedException(\n                $\"切换角色：角色列表队伍识别不完整，期望 {expectedTeamCount} 个，\" +\n                $\"末次检测到 {lastDetectedCardCount} 张卡片，成功识别 {characterNames.Count(name => name != null)} 个头像\");\n        }\n\n        var result = characterNames\n            .Select((name, index) => new TeamSlotSnapshot(index + 1, name))\n            .ToList();\n        _logger.LogDebug(\n            \"切换角色：当前账号可控角色 {ControlCount} 个，生成 {SnapshotCount} 项队伍快照，映射 {SlotMapping}\",\n            _maxControlAvatarCount,\n            result.Count,\n            string.Join(\",\", _logicalToPhysicalSlot\n                .OrderBy(pair => pair.Key)\n                .Select(pair => $\"逻辑{pair.Key}->物理{pair.Value}\")));\n\n        return result;\n    }\n","sourceCodeStart":1426,"sourceCodeEnd":1462,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs#L1426-L1462","documentation":"After the list returns to party config, RecognizeTeamSlotsFromCharacterList validates the collected names: count must equal expectedTeamCount and none may be null/empty. A mismatch means avatar recognition was incomplete (some slots scored below MatchThreshold=0.7 or fewer cards were taken), so the snapshot would be misleading and is rejected.","triggerScenarios":"characterNames.Count != expectedTeamCount, OR characterNames.Any(string.IsNullOrEmpty) — i.e. recognizer.Recognize returned Score<0.7 for at least one card (stored as null), or fewer than expectedTeamCount cards were processed.","commonSituations":"One or more avatars scored below 0.7 (lighting, costume, scale); the grid had fewer visible cards than expectedTeamCount so fewer names were collected; recognizer model gaps for a character; partial card occlusion.","solutions":["Read the message's diagnostics: '末次检测到 N 张卡片' vs '成功识别 M 个头像' — if N is right but M is low, it's a recognition-quality problem; if N is low, it's a card-detection problem (see 392).","Improve capture/resolution so all avatars clear 0.7, or extend the recognizer with the missing icons.","If partial recognition is acceptable downstream, relax the strict count/null check — but note BuildDesiredTeamRoles (385) will still reject null names.","Re-run the recognition pass on a fresh capture before failing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (characterNames.Count != expectedTeamCount || characterNames.Any(string.IsNullOrEmpty))\n{\n    _teamSnapshotDirty = true; // re-recognize on next pass\n    return RecognizeTeamSlotsFromCharacterList(recognizer, expectedTeamCount, ct);\n}","typeGuard":"static bool IsCompleteSnapshot(IReadOnlyList<string?> names, int expected)\n    => names.Count == expected && names.All(n => !string.IsNullOrEmpty(n));","tryCatchPattern":"try { await switchTask.Start(...); }\ncatch (PartySetupFailedException ex) when (ex.Message.Contains(\"队伍识别不完整\"))\n{ _logger.LogWarning(ex, \"队伍头像识别不完整，建议改善截图质量后重试\"); }","preventionTips":["Use the message diagnostics to separate card-detection vs recognition-quality causes.","Re-run the recognition pass on a fresh capture before failing.","Maintain recognizer model coverage and capture quality."],"tags":["party-setup","character-recognition","opencv","validation","switch-character"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}