namespace Theriapolis.Core.Rules.Reputation;

/// <summary>
/// Phase 6 M2 — coarse-grain banding of an integer disposition score.
/// Per <c>reputation.md §I-2</c> the bands gate dialogue tone, prices,
/// service refusal, and combat-on-sight behaviour.
/// </summary>
public enum DispositionLabel : byte
{
    Nemesis      = 0,   // -100..-76  kill on sight
    Hostile      = 1,   //  -75..-51  attacked if recognised
    Antagonistic = 2,   //  -50..-26  refused service
    Unfriendly   = 3,   //  -25.. -1  cold reception
    Neutral      = 4,   //   0
    Favorable    = 5,   //   +1..+25
    Friendly     = 6,   //  +26..+50
    Allied       = 7,   //  +51..+75
    Champion     = 8,   //  +76..+100
}

/// <summary>
/// Phase 6 M2 — trust ladder accumulated through repeated personal
/// interaction. Distinct from <see cref="DispositionLabel"/> — trust is
/// earned, disposition is felt.
/// </summary>
public enum TrustLevel : byte
{
    Stranger     = 0,
    Acquaintance = 1,
    Familiar     = 2,
    Trusted      = 3,
    Bonded       = 4,
}

public static class DispositionLabels
{
    /// <summary>Map an integer disposition score (clamped to ±100) to its label.</summary>
    public static DispositionLabel For(int score)
    {
        if (score >= C.REP_CHAMPION_THRESHOLD)     return DispositionLabel.Champion;
        if (score >= C.REP_ALLIED_THRESHOLD)       return DispositionLabel.Allied;
        if (score >= C.REP_FRIENDLY_THRESHOLD)     return DispositionLabel.Friendly;
        if (score >= C.REP_FAVORABLE_THRESHOLD)    return DispositionLabel.Favorable;
        if (score == 0)                            return DispositionLabel.Neutral;
        if (score >= C.REP_UNFRIENDLY_THRESHOLD)   return DispositionLabel.Unfriendly;
        if (score >= C.REP_ANTAGONISTIC_THRESHOLD) return DispositionLabel.Antagonistic;
        if (score >= C.REP_HOSTILE_THRESHOLD)      return DispositionLabel.Hostile;
        return DispositionLabel.Nemesis;
    }

    /// <summary>Display string ("Nemesis", "Friendly", etc.) for the reputation screen + tooltip.</summary>
    public static string DisplayName(DispositionLabel l) => l switch
    {
        DispositionLabel.Nemesis      => "Nemesis",
        DispositionLabel.Hostile      => "Hostile",
        DispositionLabel.Antagonistic => "Antagonistic",
        DispositionLabel.Unfriendly   => "Unfriendly",
        DispositionLabel.Neutral      => "Neutral",
        DispositionLabel.Favorable    => "Favorable",
        DispositionLabel.Friendly     => "Friendly",
        DispositionLabel.Allied       => "Allied",
        DispositionLabel.Champion     => "Champion",
        _                              => "Unknown",
    };
}
