namespace Theriapolis.Core.Rules.Character;

/// <summary>
/// Whose side an actor is on at the moment. Drives encounter-trigger logic:
/// hostile → auto-trigger combat on LOS; friendly/neutral → "[F] Talk to ..."
/// prompt. Phase 5 sets this from <see cref="Data.NpcTemplateDef.DefaultAllegiance"/>;
/// faction logic in Phase 6 may mutate it at runtime.
/// </summary>
public enum Allegiance : byte
{
    Player   = 0,
    Allied   = 1,
    Neutral  = 2,
    Friendly = 3,
    Hostile  = 4,
}

public static class AllegianceExtensions
{
    public static Allegiance FromJson(string raw) => raw.ToLowerInvariant() switch
    {
        "player"   => Allegiance.Player,
        "allied"   => Allegiance.Allied,
        "neutral"  => Allegiance.Neutral,
        "friendly" => Allegiance.Friendly,
        "hostile"  => Allegiance.Hostile,
        _ => throw new ArgumentException($"Unknown allegiance: '{raw}'"),
    };
}
