public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            void PopulateGlickoConstants(string sourceDictKey, Dictionary <VersusRule, GlickoConstants> constantsDict)
            {
                // Get the source dictionary
                Dictionary <string, object> sourceDict = (Dictionary <string, object>)dictionary[sourceDictKey];

                // Get the raw constants dictionary for every mode
                foreach (KeyValuePair <string, object> pair in sourceDict)
                {
                    // Create a new GlickoConstants instance and populate it
                    GlickoConstants glickoConstants = new GlickoConstants();
                    glickoConstants.DeserializeByaml((Dictionary <string, object>)pair.Value);

                    // Get the VersusRule enum
                    VersusRule VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), pair.Key);

                    // Add this to the target dictionary
                    constantsDict.Add(VersusRule, glickoConstants);
                }
            }

            // Create the dictionaries
            PairGlickoConstants = new Dictionary <VersusRule, GlickoConstants>();
            TeamGlickoConstants = new Dictionary <VersusRule, GlickoConstants>();

            // Populate them
            PopulateGlickoConstants("Pair", PairGlickoConstants);
            PopulateGlickoConstants("Team", TeamGlickoConstants);
        }
Example #2
0
        public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            // Deserialize the time
            UnlockTime = BlitzBcatDeserializationUtil.DeserializeDateTime(dictionary["DateTime"]);

            // Get the enum value for the VersusRule
            VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), (string)dictionary["Rule"]);
        }
Example #3
0
        public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            StartDateTime = BlitzBcatDeserializationUtil.DeserializeDateTime(dictionary["DateTime"]);

            void PopulateStagesSeedDict(string sourceDictKey, Dictionary <VersusRule, RandomizerSeed> targetDict)
            {
                // Get the source dictionary
                Dictionary <string, object> sourceDict = (Dictionary <string, object>)dictionary[sourceDictKey];

                // Get the raw seed dictionary for every mode
                foreach (KeyValuePair <string, object> pair in sourceDict)
                {
                    // Get the VersusRule enum
                    VersusRule VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), pair.Key);

                    // Create a new RandomizerSeed instance and deserialize
                    RandomizerSeed randomizerSeed = new RandomizerSeed();
                    randomizerSeed.DeserializeByaml((Dictionary <string, object>)pair.Value);

                    // Add this to the target dictionary
                    targetDict.Add(VersusRule, randomizerSeed);
                }
            }

            // Create the seed dictionaries
            GachiStagesSeed  = new Dictionary <VersusRule, RandomizerSeed>();
            LeagueStagesSeed = new Dictionary <VersusRule, RandomizerSeed>();

            // Populate them
            PopulateStagesSeedDict("GachiRuleStage", GachiStagesSeed);
            PopulateStagesSeedDict("LeagueRuleStage", LeagueStagesSeed);

            void PopulateRuleWeightDict(string sourceDictKey, Dictionary <VersusRule, int> targetDict)
            {
                // Get the source dictionary
                Dictionary <string, object> sourceDict = (Dictionary <string, object>)dictionary[sourceDictKey];

                // Get the raw seed dictionary for every mode
                foreach (KeyValuePair <string, object> pair in sourceDict)
                {
                    // Get the VersusRule enum
                    VersusRule VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), pair.Key);

                    // Add this to the target dictionary
                    targetDict.Add(VersusRule, (int)pair.Value);
                }
            }

            // Create the weighting dictionaries
            GachiRuleWeight  = new Dictionary <VersusRule, int>();
            LeagueRuleWeight = new Dictionary <VersusRule, int>();

            // Populate them
            PopulateRuleWeightDict("GachiRuleWeight", GachiRuleWeight);
            PopulateRuleWeightDict("LeagueRuleWeight", LeagueRuleWeight);
        }
Example #4
0
        public static Dictionary <Language, string> LocalizeRuleToAllLanguages(VersusRule rule)
        {
            // Create a new Dictionary
            Dictionary <Language, string> valueDict = new Dictionary <Language, string>();

            // Populate the Dictionary
            foreach (Language language in BlitzUtil.SupportedLanguages)
            {
                // Localize the key to this Language
                valueDict.Add(language, LocalizeRule(rule, language));
            }

            // Return the Dictionary
            return(valueDict);
        }
        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()]);
        }
Example #6
0
        public void DeserializeByaml(IDictionary <string, object> dictionary)
        {
            void PopulateTargetRates(string sourceDictKey, Dictionary <VersusRule, List <int> > rateRanges)
            {
                // Get the source dictionary
                Dictionary <string, object> sourceDict = (Dictionary <string, object>)dictionary[sourceDictKey];

                // Get the raw constants dictionary for every mode
                foreach (KeyValuePair <string, object> pair in sourceDict)
                {
                    // Get the VersusRule enum
                    VersusRule VersusRule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), pair.Key);

                    // Get the list of rates
                    List <object> rates = (List <object>)pair.Value;

                    // Add this to the target dictionary
                    rateRanges.Add(VersusRule, rates.Cast <int>().ToList());
                }
            }

            // Create the target rates  dictionaries
            TargetRates          = new Dictionary <VersusRule, List <int> >();
            OverSplusTargetRates = new Dictionary <VersusRule, List <int> >();

            // Populate them
            PopulateTargetRates("TargetRates", TargetRates);
            PopulateTargetRates("OverSplusTargetRates", OverSplusTargetRates);

            // Create the point retention dictionary
            PointRetentionRates = new Dictionary <string, UdemaePointRetention>();

            // Get the source dictionary
            Dictionary <string, object> retentionRatesSource = (Dictionary <string, object>)dictionary["PointRetationRates"];

            // Loop over every rank
            foreach (KeyValuePair <string, object> pair in retentionRatesSource)
            {
                // Create a new UdemaePointRetention instance and deserialize it
                UdemaePointRetention retention = new UdemaePointRetention();
                retention.DeserializeByaml((Dictionary <string, object>)pair.Value);

                // Add this to the target dictionary
                PointRetentionRates.Add(pair.Key, retention);
            }
        }
Example #7
0
 public static string LocalizeRule(VersusRule rule, Language language)
 {
     // Load the localized string
     return(MsbtHolders[language].Localize("VSRuleName", rule.ToString()));
 }
Example #8
0
 public void DeserializeByaml(IDictionary <string, object> dictionary)
 {
     Rule = (VersusRule)EnumUtil.GetEnumValueFromString(typeof(VersusRule), (string)dictionary["Rule"]);
 }