private void EquipItem()
        {
            // Get rid of set/gem information
            CompareItem.Gems = null;
            CompareItem.Set = null;

            for (int i = 0; i < _inputs.Count; i++)
            {
                if (String.IsNullOrEmpty(_inputs[i].Text))
                    continue;

                double value = 0;

                if (double.TryParse(_inputs[i].Text, out value))
                {
                    if (_attributeStrings[i] == "Damage_Delta#Physical")
                    {
                        value -= AttributesRaw["Damage_Min#Physical"].Min;
                    }

                    if (_attributeStrings[i] == "Hitpoints_Max_Percent_Bonus_Item" ||
                        _attributeStrings[i] == "Crit_Damage_Percent" ||
                        _attributeStrings[i] == "Crit_Percent_Bonus_Capped" ||
                        _attributeStrings[i] == "Attacks_Per_Second_Percent")
                    {
                        value = value / 100;
                    }

                    AttributesRaw[_attributeStrings[i]] = new MinMax() { Min = value, Max = value };
                }
                else
                {
                    CompareItem = PreviousItem.DeepCopyForCompare();
                    return;
                }
            }

            CompareItem.AttributesRaw = AttributesRaw;

            CompareItem.IsDirty = true;

            EquipButtonTapped(this, EventArgs.Empty);
        }
Exemple #2
0
        public static Dictionary<string, MinMax> ParseAttributesRawFromAttributes(List<string> attributes)
        {
            Match match;
            Dictionary<string, MinMax> attributesRaw = new Dictionary<string, MinMax>();
            string name = "";
            double val = 0;

            foreach (string attribute in attributes)
            {
                if ((match = Regex.Match(attribute, @"^\+(\d+) (Dexterity|Intelligence|Strength|Vitality)$", RegexOptions.IgnoreCase)).Success)
                {
                    name = match.Groups[2].Value + "_Item";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Int32.Parse(match.Groups[1].Value);
                }
                else if ((match = Regex.Match(attribute, @"^\+(\d+) Resistance to All Elements$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Resistance_All";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Int32.Parse(match.Groups[1].Value);
                }
                else if ((match = Regex.Match(attribute, @"^Critical Hit Chance Increased by (\d+\.\d+)%$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Crit_Percent_Bonus_Capped";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Attack Speed Increased by (\d+)%$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Attacks_Per_Second_Item_Percent";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^\+(\d+)% Life$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Hitpoints_Max_Percent_Bonus_Item";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Critical Hit Damage Increased by (\d+)%$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Crit_Damage_Percent";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Reduces damage from melee attacks by (\d+)%\.?$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Damage_Percent_Reduction_From_Melee";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Reduces damage from ranged attacks by (\d+)%\.?$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Damage_Percent_Reduction_From_Ranged";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Increases Damage Against Elites by (\d+)%$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Damage_Percent_Bonus_Vs_Elites";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^\+(\d+)% Damage to Demons$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Damage_Percent_Bonus_Vs_Monster_Type#Demon";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Reduces damage from elites by (\d+)%\.?$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Damage_Percent_Reduction_From_Elites";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^Regenerates (\d+) Life per Second$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Hitpoints_Regen_Per_Second";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }
                else if ((match = Regex.Match(attribute, @"^(\d+\.\d+)% of Damage Dealt Is Converted to Life$", RegexOptions.IgnoreCase)).Success)
                {
                    name = "Steal_Health_Percent";
                    val = attributesRaw.ContainsKey(name) ? attributesRaw[name].Min : 0;
                    val += Double.Parse(match.Groups[1].Value) / 100;
                }

                if (!name.Equals(""))
                    attributesRaw[name] = new MinMax { Max = val, Min = val };
            }

            return attributesRaw;
        }