Пример #1
0
        private void LoadAzerite(String profileText)
        {
            var azeriteHeadRegex     = new Regex("head=.*azerite_powers=([^\r\n,]+).*");
            var azeriteShoulderRegex = new Regex("shoulders?=.*azerite_powers=([^\r\n,]+).*");
            var azeriteChestRegex    = new Regex("chest=.*azerite_powers=([^\r\n,]+).*");
            var azeriteHelm          = azeriteHeadRegex.Match(profileText);

            if (azeriteHelm.Success)
            {
                var value = azeriteHelm.Groups[1].Value;
                if (!azeriteHelm.Groups[1].Value.Contains("/"))
                {
                    if (Ring1Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        HeadRing1 = Ring1Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring2Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        HeadRing2 = Ring2Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring4Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        HeadRing4 = Ring4Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    // Ring3 gets skipped
                }
                else
                {
                    var traits = azeriteHelm.Groups[1].Value.Split('/');
                    foreach (var trait in traits)
                    {
                        if (Ring1Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            HeadRing1 = Ring1Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring2Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            HeadRing2 = Ring2Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring4Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            HeadRing4 = Ring4Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        // Ring3 gets skipped
                    }
                }
            }
            var azeriteShoulder = azeriteShoulderRegex.Match(profileText);

            if (azeriteShoulder.Success)
            {
                var value = azeriteShoulder.Groups[1].Value;
                if (!azeriteShoulder.Groups[1].Value.Contains("/"))
                {
                    if (Ring1Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ShouldersRing1 = Ring1Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring2Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ShouldersRing2 = Ring2Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring4Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ShouldersRing4 = Ring4Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    // Ring3 gets skipped
                }
                else
                {
                    var traits = azeriteShoulder.Groups[1].Value.Split('/');
                    foreach (var trait in traits)
                    {
                        if (Ring1Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ShouldersRing1 = Ring1Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring2Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ShouldersRing2 = Ring2Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring4Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ShouldersRing4 = Ring4Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        // Ring3 gets skipped
                    }
                }
            }
            var azeriteChest = azeriteChestRegex.Match(profileText);

            if (azeriteChest.Success)
            {
                var value = azeriteChest.Groups[1].Value;
                if (!azeriteChest.Groups[1].Value.Contains("/"))
                {
                    if (Ring1Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ChestRing1 = Ring1Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring2Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ChestRing2 = Ring2Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    else if (Ring4Mapping.Exists(x => x.Id.Equals(value)))
                    {
                        ChestRing4 = Ring4Mapping.Find(x => x.Id.Equals(value)).Name;
                    }
                    // Ring3 gets skipped
                }
                else
                {
                    var traits = azeriteChest.Groups[1].Value.Split('/');
                    foreach (var trait in traits)
                    {
                        if (Ring1Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ChestRing1 = Ring1Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring2Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ChestRing2 = Ring2Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        else if (Ring4Mapping.Exists(x => x.Id.Equals(trait)))
                        {
                            ChestRing4 = Ring4Mapping.Find(x => x.Id.Equals(trait)).Name;
                        }
                        // Ring3 gets skipped
                    }
                }
            }
        }
Пример #2
0
        private String UnloadAzerite(String profileText)
        {
            var _profileText = profileText;

            string headPowers           = "";
            string shoulderPowers       = "";
            string chestPowers          = "";
            var    azeriteHeadRegex     = new Regex("head=(.*)azerite_powers=[^\r\n,]+(.*)");
            var    azeriteShoulderRegex = new Regex("shoulders?=(.*)azerite_powers=[^\r\n,]+(.*)");
            var    azeriteChestRegex    = new Regex("chest=(.*)azerite_powers=[^\r\n,]+(.*)");

            if (Ring1Mapping.Exists(x => x.Name.Equals(HeadRing1)))
            {
                headPowers += Ring1Mapping.Find(x => x.Name.Equals(HeadRing1)).Id + "/";
            }
            if (Ring2Mapping.Exists(x => x.Name.Equals(HeadRing2)))
            {
                headPowers += Ring2Mapping.Find(x => x.Name.Equals(HeadRing2)).Id + "/";
            }
            if (Ring4Mapping.Exists(x => x.Name.Equals(HeadRing4)))
            {
                headPowers += Ring4Mapping.Find(x => x.Name.Equals(HeadRing4)).Id + "/";
            }

            if (Ring1Mapping.Exists(x => x.Name.Equals(ChestRing1)))
            {
                chestPowers += Ring1Mapping.Find(x => x.Name.Equals(ChestRing1)).Id + "/";
            }
            if (Ring2Mapping.Exists(x => x.Name.Equals(ChestRing2)))
            {
                chestPowers += Ring2Mapping.Find(x => x.Name.Equals(ChestRing2)).Id + "/";
            }
            if (Ring4Mapping.Exists(x => x.Name.Equals(ChestRing4)))
            {
                chestPowers += Ring4Mapping.Find(x => x.Name.Equals(ChestRing4)).Id + "/";
            }

            if (Ring1Mapping.Exists(x => x.Name.Equals(ShouldersRing1)))
            {
                shoulderPowers += Ring1Mapping.Find(x => x.Name.Equals(ShouldersRing1)).Id + "/";
            }
            if (Ring2Mapping.Exists(x => x.Name.Equals(ShouldersRing2)))
            {
                shoulderPowers += Ring2Mapping.Find(x => x.Name.Equals(ShouldersRing2)).Id + "/";
            }
            if (Ring4Mapping.Exists(x => x.Name.Equals(ShouldersRing4)))
            {
                shoulderPowers += Ring4Mapping.Find(x => x.Name.Equals(ShouldersRing4)).Id + "/";
            }
            shoulderPowers = shoulderPowers.ToString();

            if (headPowers.Length > 0)
            {
                if (azeriteHeadRegex.Match(profileText).Success)
                {
                    _profileText = _profileText.Replace(azeriteHeadRegex.Match(_profileText).Groups[0].Value, "head=" + azeriteHeadRegex.Match(_profileText).Groups[1] + "azerite_powers=" + headPowers.Substring(0, headPowers.Count() - 1) + azeriteHeadRegex.Match(_profileText).Groups[2]);
                }
                else
                {
                    _profileText = _profileText.Replace(new Regex("head=([^\r\n]*)").Match(_profileText).Groups[0].Value, new Regex("head=([^\r\n]*)").Match(_profileText).Groups[0].Value + ",azerite_powers=" + headPowers.Substring(0, headPowers.Count() - 1));
                }
            }


            if (shoulderPowers.Length > 0)
            {
                if (azeriteShoulderRegex.Match(profileText).Success)
                {
                    _profileText = _profileText.Replace(azeriteShoulderRegex.Match(_profileText).Groups[0].Value, "shoulders=" + azeriteShoulderRegex.Match(_profileText).Groups[1] + "azerite_powers=" + shoulderPowers.Substring(0, shoulderPowers.Count() - 1) + azeriteShoulderRegex.Match(_profileText).Groups[2]);
                }
                else
                {
                    _profileText = _profileText.Replace(new Regex("shoulders=([^\r\n]*)").Match(_profileText).Groups[0].Value, new Regex("shoulders=([^\r\n]*)").Match(_profileText).Groups[0].Value + ",azerite_powers=" + shoulderPowers.Substring(0, shoulderPowers.Count() - 1));
                }
            }

            if (chestPowers.Length > 0)
            {
                if (azeriteChestRegex.Match(profileText).Success)
                {
                    _profileText = _profileText.Replace(azeriteChestRegex.Match(_profileText).Groups[0].Value, "chest=" + azeriteChestRegex.Match(_profileText).Groups[1] + "azerite_powers=" + chestPowers.Substring(0, chestPowers.Count() - 1) + azeriteChestRegex.Match(_profileText).Groups[2]);
                }
                else
                {
                    _profileText = _profileText.Replace(new Regex("chest=([^\r\n]*)").Match(_profileText).Groups[0].Value, new Regex("chest=([^\r\n]*)").Match(_profileText).Groups[0].Value + ",azerite_powers=" + chestPowers.Substring(0, chestPowers.Count() - 1));
                }
            }

            return(_profileText);
        }