using System.Collections.Generic;
using System.IO;
using Data;
using Utils;

namespace Managers
{
    public class DefineManager : Singleton<DefineManager>
    {
        private const string coreNamespace = "Data";
        private static readonly string[] dataSetFilePath = { "Data", "Mod" };

        public Dictionary<string, Dictionary<string, Define>> defines = new();
        public Dictionary<string, DefinePack> packs = new();

        public void Init()
        {
            var packFolder = Configs.ConfigProcessor.GetSubFolders(new(dataSetFilePath));
            foreach (var folder in packFolder)
            {
                var pack = new DefinePack();
                if (pack.LoadPack(folder)) packs.Add(pack.packID, pack);
            }
        }

        public override string ToString()
        {
            if (packs == null || packs.Count == 0)
            {
                return "No packs available"; // 如果集合为空或为 null，返回默认信息
            }
            
            var result = new System.Text.StringBuilder();

            foreach (var definePack in packs)
            {
                result.AppendLine(definePack.ToString()); // 每个元素占一行
            }

            return result.ToString(); 
        }
    }
}