示例#1
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()]);
        }
示例#2
0
 public static string LocalizeRule(VersusRule rule, Language language)
 {
     // Load the localized string
     return(MsbtHolders[language].Localize("VSRuleName", rule.ToString()));
 }