Exemplo n.º 1
0
        public void LoadProfilePath(String path)
        {
            try
            {
                _profileText = File.ReadAllText(path);
                var profileText = _profileText;
                //Parse and update values.
                var nameClassRegex = new Regex("([^=]+)=\"?([^\r\n\"]+)\"?");
                var specRegex      = new Regex("spec=(\\w+)");
                var ilvlRegex      = new Regex("gear_ilvl=(\\d+.?\\d*)");
                var tierRegex      = new Regex("set_bonus=tier(\\d+)_(\\d)pc=1");
                var potionRegex    = new Regex("potion=(\\w+)");
                var flaskRegex     = new Regex("flask=(\\w+)");
                var foodRegex      = new Regex("food=(\\w+)");
                var augmentRegex   = new Regex("augmentation=(\\w+)");

                var nameClassMatch = nameClassRegex.Match(profileText);
                Name  = nameClassMatch.Groups[2].Value;
                Class = nameClassMatch.Groups[1].Value.UppercaseWords().Replace("Deathk", "Death K").Replace("Demonh", "Demon H").UppercaseWords();
                Spec  = specRegex.Match(profileText).Groups[1].Value.UppercaseWords().Replace("Beastm", "Beast M");
                var fixedCulture = CultureInfo.CreateSpecificCulture("en-US");
                ILvl = float.Parse(ilvlRegex.Match(profileText).Groups[1].Value, fixedCulture); // Easy fix to convert EU to US style decimal notation.
                // Ring 1
                Ring1.Add("None");
                Ring1.Add("");
                Ring1.Add("- " + Class + " -");
                Ring1.Add("    - " + Spec + " -");
                AzeriteMapping[Class.ToLower().Replace(" ", "_")][Spec.ToLower().Replace(" ", "_")].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("- PVE -");
                Ring1.Add("    - Magni -");
                AzeriteMapping["pve"]["magni"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("    - Uldir -");
                AzeriteMapping["pve"]["uldir"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("    - World -");
                AzeriteMapping["pve"]["location"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("    - Dungeons -");
                AzeriteMapping["pve"]["dungeon"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("- PVP -");
                Ring1.Add("    - Horde -");
                AzeriteMapping["pvp"]["horde"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("    - Alliance -");
                AzeriteMapping["pvp"]["alliance"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                Ring1.Add("");
                Ring1.Add("- Professions -");
                Ring1.Add("    - Engineering -");
                AzeriteMapping["profession"]["engineering"].ForEach(x => { Ring1.Add(x.Name); Ring1Mapping.Add(x); });
                // Ring 2
                Ring2.Add("None");
                Ring2.Add("");
                Ring2.Add("- Role -");
                if (new List <String> {
                    "Demon Hunter", "Death Knight", "Monk", "Paladin", "Druid", "Warrior"
                }.Contains(Class))
                {
                    Ring2.Add("    - Tank -");
                    AzeriteMapping["role"]["tank"].ForEach(x => { Ring2.Add(x.Name); Ring2Mapping.Add(x); });
                    Ring2.Add("");
                }
                if (new List <String> {
                    "Paladin", "Priest", "Shaman", "Monk", "Druid"
                }.Contains(Class))
                {
                    Ring2.Add("    - Healer -");
                    AzeriteMapping["role"]["healer"].ForEach(x => { Ring2.Add(x.Name); Ring2Mapping.Add(x); });
                    Ring2.Add("");
                }
                Ring2.Add("    - DPS -");
                AzeriteMapping["role"]["dps"].ForEach(x => { Ring2.Add(x.Name); Ring2Mapping.Add(x); });
                Ring2.Add("");
                Ring2.Add("    - Any -");
                AzeriteMapping["role"]["any"].ForEach(x => { Ring2.Add(x.Name); Ring2Mapping.Add(x); });
                // Ring 4
                Ring4.Add("None");
                AzeriteMapping["generic"]["center"].ForEach(x => { Ring4.Add(x.Name); Ring4Mapping.Add(x); });

                HeadRing1      = "None";
                HeadRing2      = "None";
                HeadRing4      = "None";
                ChestRing1     = "None";
                ChestRing2     = "None";
                ChestRing4     = "None";
                ShouldersRing1 = "None";
                ShouldersRing2 = "None";
                ShouldersRing4 = "None";

                var potionName = potionRegex.Match(profileText).Groups[1].Value;
                var flaskName  = flaskRegex.Match(profileText).Groups[1].Value;
                var foodName   = foodRegex.Match(profileText).Groups[1].Value;
                var runeName   = augmentRegex.Match(profileText).Groups[1].Value;
                if (PotionNameMapping.Exists(x => x.simc_names.Contains(potionName)))
                {
                    Potion = PotionNameMapping.First(x => x.simc_names.Contains(potionName)).name;
                }
                if (FlaskNameMapping.Exists(x => x.simc_names.Contains(flaskName)))
                {
                    Flask = FlaskNameMapping.First(x => x.simc_names.Contains(flaskName)).name;
                }
                if (FoodNameMapping.Exists(x => x.simc_names.Contains(foodName)))
                {
                    Food = FoodNameMapping.First(x => x.simc_names.Contains(foodName)).name;
                }
                if (AugmentNameMapping.Exists(x => x.simc_names.Contains(runeName)))
                {
                    Rune = AugmentNameMapping.First(x => x.simc_names.Contains(runeName)).name;
                }
                if (PotionNameMapping.Exists(x => x.simc_names.Contains(potionName)))
                {
                    Potion = PotionNameMapping.First(x => x.simc_names.Contains(potionName)).name;
                }
                LoadAzerite(profileText);

                var tierMatches = tierRegex.Matches(profileText);
                for (int i = 0; i < tierMatches.Count; i++)
                {
                    var match = tierMatches[i];
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Ran into an issue loading your profile: " + e.Message, "Error", MessageBoxButton.OK);
            }
        }