using System;
using System.Collections.Generic;
using System.IO;
using YamlDotNet;


namespace Celeste.Mod.Eevee_Skinmod {
    class EeveeReader {

        public static bool tryGet(string path) {
            return Directory.Exists(@path);
        }

        public static Dictionary<string,Palette> readContents(string path) {
            Dictionary<string, Palette> external = new Dictionary<string, Palette>();
            string[] files = Directory.GetFiles(path,"*.yaml");
            var deserializer = new YamlDotNet.Serialization.Deserializer();
            string[] holder = new string[2];
            
                foreach (string str in files) {
                using (var input = File.OpenText(str)) {
                    string filePath = str.Replace("\\", "/");
                    holder = (filePath.Substring(filePath.LastIndexOf("/") + 1)).Split('.');
                    external.Add(holder[0], deserializer.Deserialize<Palette>(input));
                }
                
            }

            return external;
        }
    }
}
