using System.Text.Json.Serialization;

namespace Theriapolis.Core.Data;

/// <summary>
/// Immutable subclass definition loaded from subclasses.json. Phase 5
/// stores these but does not apply mechanics — subclass selection is the
/// level-3 flow that ships with Phase 5.5 / 6 leveling. Loaded so
/// <c>ContentValidate</c> can verify referential integrity from
/// <see cref="ClassDef.SubclassIds"/>.
/// </summary>
public sealed record SubclassDef
{
    [JsonPropertyName("id")]
    public string Id { get; init; } = "";

    [JsonPropertyName("class_id")]
    public string ClassId { get; init; } = "";

    [JsonPropertyName("name")]
    public string Name { get; init; } = "";

    [JsonPropertyName("flavor")]
    public string Flavor { get; init; } = "";

    /// <summary>Level → feature ids unlocked. Same shape as the class table.</summary>
    [JsonPropertyName("level_features")]
    public SubclassLevelEntry[] LevelFeatures { get; init; } = Array.Empty<SubclassLevelEntry>();

    /// <summary>Subclass-specific feature descriptions, keyed by feature id.</summary>
    [JsonPropertyName("feature_definitions")]
    public Dictionary<string, ClassFeatureDef> FeatureDefinitions { get; init; } = new();
}

public sealed record SubclassLevelEntry
{
    [JsonPropertyName("level")]
    public int Level { get; init; } = 3;

    [JsonPropertyName("features")]
    public string[] Features { get; init; } = Array.Empty<string>();
}
