{"record":{"id":"cdbd686272ba4104","repo":"babalae/better-genshin-impact","slug":"currentrole-name","errorCode":null,"errorMessage":"切换角色：未找到目标角色 {_currentRole.Name}","messagePattern":"切换角色：未找到目标角色 (.+?)","errorType":"exception","errorClass":"PartySetupFailedException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs","lineNumber":858,"sourceCode":"                    avatarFound = true;\n                    break;\n                }\n\n                _logger.LogDebug(\n                    \"切换角色：好感排序第 {Attempt}/{AttemptCount} 次未找到 {Name}\",\n                    attempt,\n                    FriendshipSortSearchAttemptCount,\n                    _currentRole.Name);\n            }\n        }\n        else\n        {\n            avatarFound = await FindAndClickAvatar(_currentRole, Recognizer, _ct);\n        }\n\n        if (!avatarFound)\n        {\n            throw new PartySetupFailedException($\"切换角色：未找到目标角色 {_currentRole.Name}\");\n        }\n\n        if (!TryClickAnyText(page, [\"更换\", \"加入\"], Rect1080(382, 994, 87, 51)))\n        {\n            _logger.LogWarning(\"切换角色：未识别到“更换”或“加入”按钮\");\n            return StateHandlerResult.Retry;\n        }\n\n        if (_isAppendingRole)\n        {\n            _currentTeamSlots.Add(new TeamSlotSnapshot(_currentRole.Slot, _currentRole.PrimaryCandidateName));\n            _currentTeamSlots = _currentTeamSlots.OrderBy(slot => slot.Slot).ToList();\n            _expectedTeamCount++;\n        }\n        else\n        {\n            _currentTeamSlots = _currentTeamSlots\n                .Select(slot => slot.Slot == _currentRole.Slot","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs#L840-L876","documentation":"HandleFindAndClickAvatar could not locate the target character's avatar in the (filtered) character grid after all search attempts — direct recognition failed, and the friendship-sort loop (up to FriendshipSortSearchAttemptCount=3 toggling sort direction) also failed. The role is therefore unavailable on this account or unrecognizable, so the switch is aborted.","triggerScenarios":"FindAndClickAvatar(role, Recognizer, ct) returned false for every attempt; either UseFriendshipSort was true and all 3 sort-direction iterations missed, or it was false and the single direct scan missed.","commonSituations":"The character does not exist on the account (typo in config, not yet owned); element/weapon filter excluded it so it never appears in the grid; AvatarGridIconRecognizer model does not contain the character's icon (new/unreleased character, costume variant); grid card detection (DetectCharacterCards) rejected the card; game rendering at a different scale dropped the match below MatchThreshold=0.7.","solutions":["Verify the character is actually owned and not excluded by the active element/weapon filter (check _pendingFilterElementType/_pendingFilterWeaponType for this role).","Confirm the character's avatar is present in the recognizer's trained set; add/retrain if missing.","Lower/raise assetScale or MatchThreshold only after confirming capture resolution; re-run on a known 1080p capture.","Check the role's CandidateNames includes all in-game display variants (costume/alias) so Matches/FindAndClickAvatar can hit."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before starting, confirm the character is plausibly available\nvar owned = await CheckOwnedCharacters(ct); // user-supplied\nforeach (var name in requestedNames)\n    if (!owned.Contains(name))\n        throw new ArgumentException($\"账号未拥有角色 {name}\");","typeGuard":null,"tryCatchPattern":"try { await switchTask.Start(...); }\ncatch (PartySetupFailedException ex) when (ex.Message.Contains(\"未找到目标角色\"))\n{ _logger.LogError(ex, \"目标角色在筛选网格中未找到：检查账号拥有情况、筛选条件与识别器模型\"); }","preventionTips":["Verify the character is owned and not excluded by the element/weapon filter.","Keep AvatarGridIconRecognizer models current with new characters/costumes.","Provide all display-name aliases in CandidateNames."],"tags":["party-setup","character-recognition","opencv","avatar-grid","switch-character"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}