namespace Theriapolis.Core.Dungeons;

/// <summary>
/// The slot a room occupies in a dungeon's role mix.
///
/// Each <see cref="Theriapolis.Core.Data.RoomTemplateDef"/> declares a list
/// of role-eligibility tags via <c>roles_eligible</c>. The layout assembler
/// pairs templates to roles when filling a dungeon's required + optional
/// role slots; the resulting <see cref="Room"/> records its assigned role
/// for content-distribution decisions (loot tier, encounter density, etc.).
/// </summary>
public enum RoomRole : byte
{
    /// <summary>The dungeon's surface entrance. Always one per dungeon.</summary>
    Entry,
    /// <summary>Generic in-between room — most rooms in a typical dungeon are transit.</summary>
    Transit,
    /// <summary>Carries environmental-storytelling prose; usually no encounter, often unique decor.</summary>
    Narrative,
    /// <summary>Optional reward room with a container slot (sometimes locked).</summary>
    Loot,
    /// <summary>The dungeon's set-piece final room. Always one in dungeons that declare it.</summary>
    Boss,
    /// <summary>A side room off the critical path — exists for exploration reward.</summary>
    DeadEnd,
}

internal static class RoomRoleExtensions
{
    public static RoomRole Parse(string raw) => raw switch
    {
        "entry"     => RoomRole.Entry,
        "transit"   => RoomRole.Transit,
        "narrative" => RoomRole.Narrative,
        "loot"      => RoomRole.Loot,
        "boss"      => RoomRole.Boss,
        "dead-end"  => RoomRole.DeadEnd,
        _           => throw new System.ArgumentException($"Unknown room role: '{raw}'"),
    };

    public static string ToTag(this RoomRole r) => r switch
    {
        RoomRole.Entry     => "entry",
        RoomRole.Transit   => "transit",
        RoomRole.Narrative => "narrative",
        RoomRole.Loot      => "loot",
        RoomRole.Boss      => "boss",
        RoomRole.DeadEnd   => "dead-end",
        _                  => "transit",
    };
}
