namespace Theriapolis.Core.Dungeons;

/// <summary>
/// Phase 7 M1 — runtime state for a single room inside a generated dungeon.
///
/// A Room records its template id, its dungeon-local axis-aligned bounding
/// box (top-left corner + dimensions, in tactical tiles), the clade that
/// built it (drives clade-responsive movement cost per Phase 7 plan §5.4),
/// and the role it occupies in the dungeon's layout. Mutable runtime state
/// (cleared / looted flags) lives on the <see cref="DungeonState"/>
/// snapshot, not here, so this record stays a deterministic baseline view.
/// </summary>
public sealed class Room
{
    /// <summary>Stable id within a dungeon (0..Dungeon.Rooms.Length-1).</summary>
    public int    Id          { get; init; }

    /// <summary>Reference back to the source <see cref="Theriapolis.Core.Data.RoomTemplateDef.Id"/>.</summary>
    public string TemplateId  { get; init; } = "";

    /// <summary>Dungeon-local AABB top-left X (tile units). Inclusive.</summary>
    public int    AabbX       { get; init; }
    /// <summary>Dungeon-local AABB top-left Y (tile units). Inclusive.</summary>
    public int    AabbY       { get; init; }
    /// <summary>AABB width in tactical tiles (matches the source template's <c>footprint_w_tiles</c>).</summary>
    public int    AabbW       { get; init; }
    /// <summary>AABB height in tactical tiles (matches the source template's <c>footprint_h_tiles</c>).</summary>
    public int    AabbH       { get; init; }

    /// <summary>
    /// Builder clade — drives the clade-responsive movement multiplier
    /// (<c>ClademorphicMovement.GetCostMultiplier</c>) the player pays
    /// while moving through this room. Empty / "none" means no penalty.
    /// </summary>
    public string BuiltBy     { get; init; } = "none";

    /// <summary>Role assigned at layout-build time.</summary>
    public RoomRole Role      { get; init; }

    /// <summary>
    /// Optional environmental-storytelling prose surfaced by the
    /// InteractionScreen scent-overlay panel (Phase 6.5 M1) and the
    /// dungeon-clear coda. Null when the source template doesn't carry one.
    /// </summary>
    public string? NarrativeText { get; init; }

    public override string ToString()
        => $"Room[id={Id} role={Role} aabb=({AabbX},{AabbY},{AabbW}x{AabbH}) tpl={TemplateId}]";
}
