Exemplo n.º 1
0
        public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            // Create new dictionaries
            Name      = new Dictionary <Language, string>();
            ShortName = new Dictionary <Language, string>();

            void PopulateDictionary(string sourceDictKey, Dictionary <Language, string> targetDict)
            {
                // Check if the source dictionary even exists
                if (dictionary.TryGetValue(sourceDictKey, out object value))
                {
                    // Get the dictionary
                    Dictionary <string, object> sourceDict = (Dictionary <string, object>)value;

                    // Loop over every short name
                    foreach (KeyValuePair <string, object> pair in sourceDict)
                    {
                        targetDict.Add(LanguageExtensions.FromSeadCode(pair.Key), (string)pair.Value);
                    }
                }
            }

            PopulateDictionary("Name", Name);
            PopulateDictionary("ShortName", ShortName);
        }
Exemplo n.º 2
0
        public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            // Deserialize the VersusRule
            VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), (string)dictionary["Rule"]);

            // Create the News dictionary
            News = new Dictionary <string, Dictionary <Language, List <ScriptCommand> > >();

            // Get the news list
            List <object> newsList = (List <object>)dictionary["News"];

            // Loop over every news
            foreach (object obj in newsList)
            {
                // Create a new inner dictionary
                Dictionary <Language, List <ScriptCommand> > innerDict = new Dictionary <Language, List <ScriptCommand> >();

                // Get the news dictionary
                Dictionary <string, object> news = (Dictionary <string, object>)obj;

                // Loop over every language key
                foreach (string code in news.Keys)
                {
                    // Skip NewsType
                    if (code == "NewsType")
                    {
                        continue;
                    }

                    // Create the script list
                    List <ScriptCommand> commandList = ScriptParser.ParseCommandList((List <object>)news[code]);

                    // Get the language code
                    Language language = LanguageExtensions.FromSeadCode(code);

                    // Add this to the inner dictionary
                    innerDict.Add(language, commandList);
                }

                // Add the inner dictionary
                News.Add((string)news["NewsType"], innerDict);
            }

            // Load the Glicko constants
            GlickoConstants = new GlickoConstants();
            GlickoConstants.DeserializeByaml((Dictionary <string, object>)dictionary[VersusRule.ToString()]);
        }