using System.Collections.ObjectModel;

namespace NeonSprawl.Server.Game.Mastery;

/// <summary>In-memory mastery catalog loaded at startup (NEO-46). Prefer <see cref="IMasteryCatalogRegistry"/> for lookups.</summary>
public sealed class MasteryCatalog
{
    public MasteryCatalog(
        string masteryDirectory,
        IReadOnlyDictionary<string, MasteryTrackRow> tracksBySkillId,
        IReadOnlyDictionary<string, PerkDefRow> perksById,
        int catalogJsonFileCount)
    {
        MasteryDirectory = masteryDirectory;
        TracksBySkillId = new ReadOnlyDictionary<string, MasteryTrackRow>(
            new Dictionary<string, MasteryTrackRow>(tracksBySkillId, StringComparer.Ordinal));
        PerksById = new ReadOnlyDictionary<string, PerkDefRow>(
            new Dictionary<string, PerkDefRow>(perksById, StringComparer.Ordinal));
        CatalogJsonFileCount = catalogJsonFileCount;
    }

    /// <summary>Absolute path to the directory enumerated for <c>*_mastery.json</c> catalogs.</summary>
    public string MasteryDirectory { get; }

    public IReadOnlyDictionary<string, MasteryTrackRow> TracksBySkillId { get; }

    public IReadOnlyDictionary<string, PerkDefRow> PerksById { get; }

    public int TrackCount => TracksBySkillId.Count;

    public int PerkCount => PerksById.Count;

    /// <summary>Number of <c>*_mastery.json</c> files under <see cref="MasteryDirectory"/>.</summary>
    public int CatalogJsonFileCount { get; }
}
