babalae/better-genshin-impact · error · Exception

角色【{standardName}】暂无默认卡牌定义配置,请自行进行角色定义

Error message

角色【{standardName}】暂无默认卡牌定义配置,请自行进行角色定义

What it means

Thrown by ScriptParser.ParseCharacter when a character is defined without an explicit skill block (no '|' separator / no '{}' block) AND the character name cannot be found in DefaultTcgConfig.CharacterCardMap or resolved via DefaultAutoFightConfig.AvatarAliasToStandardName. The parser first tries an exact match in the TCG card map, then falls back to the fight-config alias resolver. If neither yields a standard name present in the TCG config, the character has no known card data (skills, talents, element) and cannot be automated.

Source

Thrown at BetterGenshinImpact/GameTask/AutoGeniusInvokation/ScriptParser.cs:178

            character.Skills = [.. skills];
        }
        else
        {
            // 没有配置直接使用默认配置
            character.Name = parts[1];
            var standardName = DefaultTcgConfig.CharacterCardMap.Keys.FirstOrDefault(x => x.Equals(character.Name));
            if (string.IsNullOrEmpty(standardName))
            {
                standardName = DefaultAutoFightConfig.AvatarAliasToStandardName(character.Name);
            }

            if (DefaultTcgConfig.CharacterCardMap.TryGetValue(standardName, out var characterCard))
            {
                CharacterCard.CopyCardProperty(character, characterCard);
            }
            else
            {
                throw new System.Exception($"角色【{standardName}】暂无默认卡牌定义配置,请自行进行角色定义");
            }
        }

        return character;
    }

    /// <summary>
    /// 技能3消耗=1雷骰子+2任意
    /// 技能2消耗=3雷骰子
    /// 技能1消耗=4雷骰子
    /// </summary>
    /// <param name="oneSkillStr"></param>
    /// <returns></returns>
    public static Skill ParseSkill(string oneSkillStr)
    {
        var skill = new Skill();
        var parts = oneSkillStr.Split('=');
        skill.Index = short.Parse(RegexHelper.ExcludeNumberRegex().Replace(parts[0], ""));

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Define the character with an explicit skill block: '角色1=角色名|元素{技能1消耗=3雷骰子,技能2消耗=...}'.
  2. Check DefaultTcgConfig.CharacterCardMap keys for the exact supported character name and use that spelling.
  3. If the character is genuinely unsupported, wait for a tool update that adds the card data, or contribute a config entry.
  4. Verify the character name has no trailing whitespace or full-width characters.

Example fix

// before — relies on default config that does not contain the character
角色1=流浪者

// after — explicit skill definition
角色1=流浪者|风{技能1消耗=3风骰子,技能2消耗=3风骰子,技能3消耗=1风骰子+2任意}
Defensive patterns

Strategy: validation

Validate before calling

// Before parsing, check if the character name exists in default config
if (!DefaultTcgConfig.CharacterCardMap.ContainsKey(characterName)
    && string.IsNullOrEmpty(DefaultAutoFightConfig.AvatarAliasToStandardName(characterName)))
{
    Logger.LogWarning("角色 {Name} 未在默认配置中,请手动定义技能", characterName);
}

Type guard

public static bool IsCharacterSupported(string name)
{
    var standardName = DefaultTcgConfig.CharacterCardMap.Keys
        .FirstOrDefault(x => x.Equals(name));
    if (string.IsNullOrEmpty(standardName))
    {
        standardName = DefaultAutoFightConfig.AvatarAliasToStandardName(name);
    }
    return !string.IsNullOrEmpty(standardName)
        && DefaultTcgConfig.CharacterCardMap.ContainsKey(standardName);
}

Try / catch

catch (System.Exception ex) when (ex.Message.Contains("暂无默认卡牌定义配置"))
{
    MyLogger.LogError($"角色不支持自动配置,请手动编写技能定义。错误: {ex.Message}");
    ThemedMessageBox.Error($"请在脚本中为该角色手动定义技能。{ex.Message}", "角色配置缺失");
    return default!;
}

Prevention

When it happens

Trigger: A strategy script line like '角色1=新角色名' (without a {...} skill definition) where '新角色名' is not in DefaultTcgConfig.CharacterCardMap and has no alias in DefaultAutoFightConfig. This happens when a new Genshin character has been added to the game but not yet added to the bundled default TCG configuration.

Common situations: Game updated with a new TCG character card that the tool does not yet support; user typed a character name with a typo or non-standard alias; user mixed character names from different localizations (e.g. English name in a Chinese config).

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/c76892640787ce75. Report an issue: GitHub.