namespace Theriapolis.Core.Rules.Stats;

/// <summary>
/// Damage classifications. Resistance and immunity are checked against
/// these. Theriapolis adds no exotic types beyond standard d20 — the
/// scent/pheromone abilities use <see cref="Condition"/> not damage.
/// </summary>
public enum DamageType : byte
{
    Bludgeoning = 0,
    Piercing    = 1,
    Slashing    = 2,
    Fire        = 3,
    Cold        = 4,
    Lightning   = 5,
    Poison      = 6,
    Psychic     = 7,
    Thunder     = 8,
    Acid        = 9,
    Necrotic    = 10,
    Radiant     = 11,
    Force       = 12,
}

public static class DamageTypeExtensions
{
    public static DamageType FromJson(string raw) => raw.ToLowerInvariant() switch
    {
        "bludgeoning"   => DamageType.Bludgeoning,
        "piercing"      => DamageType.Piercing,
        "slashing"      => DamageType.Slashing,
        "fire"          => DamageType.Fire,
        "cold"          => DamageType.Cold,
        "lightning"     => DamageType.Lightning,
        "poison"        => DamageType.Poison,
        "psychic"       => DamageType.Psychic,
        "thunder"       => DamageType.Thunder,
        "acid"          => DamageType.Acid,
        "necrotic"      => DamageType.Necrotic,
        "radiant"       => DamageType.Radiant,
        "force"         => DamageType.Force,
        _ => throw new ArgumentException($"Unknown damage type: '{raw}'"),
    };
}
