{"record":{"id":"ce776e9e7407a7d3","repo":"babalae/better-genshin-impact","slug":"currenttarget-name-ce776e","errorCode":null,"errorMessage":"未找到目标角色 {CurrentTarget.Name}。","messagePattern":"未找到目标角色 (.+?)。","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs","lineNumber":683,"sourceCode":"        }\n\n        await Delay(500, _ct);\n        _workflowState = CharacterDevelopmentState.FindAndClickAvatar;\n        return StateHandlerResult.Success;\n    }\n\n    [StateHandler(CharacterDevelopmentState.FindAndClickAvatar, RetryTimeout = 30000, RetryInterval = 300, TransitionTimeout = 5000)]\n    private async Task<StateHandlerResult> HandleFindAndClickAvatar(BvPage page)\n    {\n        var candidate = await CharacterSelectionHelper.FindAndClickAvatar(\n            CurrentTarget,\n            Recognizer,\n            _assetScale,\n            _logger,\n            _ct);\n        if (candidate == null)\n        {\n            throw new InvalidOperationException($\"未找到目标角色 {CurrentTarget.Name}。\");\n        }\n\n        CurrentResult.ElementType = candidate.ElementType;\n\n        _workflowState = CharacterDevelopmentState.SelectedCharacter;\n        return StateHandlerResult.Success;\n    }\n\n    [StateHandler(CharacterDevelopmentState.SelectedCharacter, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 5000)]\n    private Task<StateHandlerResult> HandleSelectedCharacter(BvPage page)\n    {\n        Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);\n        _workflowState = CharacterDevelopmentState.SwitchCategory;\n        return Task.FromResult(StateHandlerResult.Success);\n    }\n\n    [StateHandler(CharacterDevelopmentState.SwitchCategory, RetryTimeout = 12000, RetryInterval = 300, TransitionTimeout = 5000)]\n    private Task<StateHandlerResult> HandleSwitchCategory(BvPage page)","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs#L665-L701","documentation":"`FindAndClickAvatar` scrolls through the entire character grid and returns null when no card's recognized name matches the target above the similarity threshold (`MatchThreshold = 0.7`). The `FindAndClickAvatar` handler treats null as a hard failure because the target character could not be located at all.","triggerScenarios":"The character is not owned/unequipped; the avatar model misidentifies every card (low scores); the filter excluded the character (wrong element/weapon filter applied); the grid ROI or card detector produced no valid cards on any page.","commonSituations":"Asking for a character the account does not own; a filter mismatch hiding the character; model accuracy drop after a UI/art change; card detector thresholds too strict for the current resolution.","solutions":["Confirm the account owns the character and that the correct element/weapon filter is applied.","Retrain or update the avatar recognition model/assets if scores are consistently low.","Lower `MatchThreshold` only after verifying false positives are acceptable, or widen the grid ROI.","Retry the whole task once (transient capture/OCR noise) before declaring the character missing."],"exampleFix":"// before\nvar candidate = await FindAndClickAvatar(target, recognizer, scale, logger, ct);\nif (candidate == null) throw new InvalidOperationException(...);\n\n// after: retry once, then surface a clearer error\nvar candidate = await FindAndClickAvatar(target, recognizer, scale, logger, ct);\nif (candidate == null)\n    throw new InvalidOperationException($\"未找到目标角色 {target.Name}，请确认已拥有该角色且筛选条件正确。\");","handlingStrategy":"retry","validationCode":"// Before starting, sanity-check ownership is out of scope at runtime;\n// instead validate filter types so the character isn't hidden:\nvar (el, wp) = GetFilterTypes(target, recognizer);\nif (string.IsNullOrWhiteSpace(wp)) return; // skip rather than search doomed","typeGuard":null,"tryCatchPattern":"try { await task.Start(ct); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"未找到目标角色\"))\n{ /* confirm ownership + correct filter; retry once */ }","preventionTips":["Confirm the account owns the character before running.","Ensure element/weapon filters are correct so the character is visible in the grid.","Keep the avatar model/assets current to maintain recognition accuracy."],"tags":["state-machine","avatar-recognition","character-not-found","filter","character-development"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}