Beispiel #1
0
        public static List <ItemStat> GenerateGearStats(IEnumerable <DatabaseItemInfo> _Items, WowVersionEnum _WowVersion)
        {
            List <ItemStat> totalStats = new List <ItemStat>();

            foreach (var item in _Items)
            {
                try
                {
                    var itemInfo = DatabaseAccess.GetItemInfo(item.ItemID, _WowVersion);
                    var stats    = ItemStats.ParseAjaxTooltip(itemInfo.GetAjaxTooltip(_WowVersion, item.ItemID, item.SuffixID, item.EnchantID, item.UniqueID, item.GemIDs));

                    foreach (var stat in stats)
                    {
                        ItemStat[] addStats     = null;
                        int        normalValue  = 0;
                        int        enchantValue = 0;
                        int        gemValue     = 0;
                        if (stat.Enchant == true)
                        {
                            enchantValue = stat.Value;
                        }
                        else if (stat.Gem == true)
                        {
                            gemValue = stat.Value;
                        }
                        else
                        {
                            normalValue = stat.Value;
                        }
                        if (stat.Type == ItemStatType.Spell_Damage_and_Healing)
                        {
                            addStats = new ItemStat[] { new ItemStat(ItemStatType.Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Spell_Healing, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Frost_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Nature_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Arcane_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Shadow_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Fire_Spell_Damage, normalValue, enchantValue, gemValue) };
                        }
                        else if (stat.Type == ItemStatType.Spell_Damage)
                        {
                            addStats = new ItemStat[] { new ItemStat(ItemStatType.Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Frost_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Nature_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Arcane_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Shadow_Spell_Damage, normalValue, enchantValue, gemValue)
                                                        , new ItemStat(ItemStatType.Fire_Spell_Damage, normalValue, enchantValue, gemValue) };
                        }
                        else if (stat.Type == ItemStatType.All_Resistances)
                        {
                            addStats = new ItemStat[] {
                                new ItemStat(ItemStatType.Shadow_Resistance, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Fire_Resistance, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Nature_Resistance, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Frost_Resistance, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Arcane_Resistance, normalValue, enchantValue, gemValue)
                            };
                        }
                        else if (stat.Type == ItemStatType.Attack_Power)
                        {
                            addStats = new ItemStat[] {
                                new ItemStat(ItemStatType.Attack_Power, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Ranged_Attack_Power, normalValue, enchantValue, gemValue)
                            };
                        }
                        else if (stat.Type == ItemStatType.HMp5)
                        {
                            addStats = new ItemStat[] {
                                new ItemStat(ItemStatType.Hp5, normalValue, enchantValue, gemValue)
                                , new ItemStat(ItemStatType.Mp5, normalValue, enchantValue, gemValue)
                            };
                        }
                        else
                        {
                            addStats = new ItemStat[] { new ItemStat(stat.Type, normalValue, enchantValue, gemValue) };
                        }
                        foreach (var addStat in addStats)
                        {
                            if (addStat.StatType == ItemStatType.Unknown)
                            {
                                continue;
                            }
                            int statIndex = totalStats.FindIndex((ItemStat _Stat) => { return(addStat.StatType == _Stat.StatType); });
                            if (statIndex != -1)
                            {
                                var currStat = totalStats[statIndex];
                                currStat.NormalValue  += addStat.NormalValue;
                                currStat.EnchantValue += addStat.EnchantValue;
                                currStat.GemValue     += addStat.GemValue;
                                totalStats[statIndex]  = currStat;
                            }
                            else
                            {
                                totalStats.Add(addStat);
                            }
                        }
                    }
                }
                catch (Exception)
                {}
            }
            List <ItemStatType> removeStats = new List <ItemStatType>();
            int spellDmg = GetStat(totalStats, ItemStatType.Spell_Damage);

            if (spellDmg == GetStat(totalStats, ItemStatType.Frost_Spell_Damage))
            {
                removeStats.Add(ItemStatType.Frost_Spell_Damage);
            }
            if (spellDmg == GetStat(totalStats, ItemStatType.Fire_Spell_Damage))
            {
                removeStats.Add(ItemStatType.Fire_Spell_Damage);
            }
            if (spellDmg == GetStat(totalStats, ItemStatType.Arcane_Spell_Damage))
            {
                removeStats.Add(ItemStatType.Arcane_Spell_Damage);
            }
            if (spellDmg == GetStat(totalStats, ItemStatType.Nature_Spell_Damage))
            {
                removeStats.Add(ItemStatType.Nature_Spell_Damage);
            }
            if (spellDmg == GetStat(totalStats, ItemStatType.Shadow_Spell_Damage))
            {
                removeStats.Add(ItemStatType.Shadow_Spell_Damage);
            }

            int spellResistance = 0;

            if (spellResistance == GetStat(totalStats, ItemStatType.Frost_Resistance))
            {
                removeStats.Add(ItemStatType.Frost_Resistance);
            }
            if (spellResistance == GetStat(totalStats, ItemStatType.Fire_Resistance))
            {
                removeStats.Add(ItemStatType.Fire_Resistance);
            }
            if (spellResistance == GetStat(totalStats, ItemStatType.Arcane_Resistance))
            {
                removeStats.Add(ItemStatType.Arcane_Resistance);
            }
            if (spellResistance == GetStat(totalStats, ItemStatType.Nature_Resistance))
            {
                removeStats.Add(ItemStatType.Nature_Resistance);
            }
            if (spellResistance == GetStat(totalStats, ItemStatType.Shadow_Resistance))
            {
                removeStats.Add(ItemStatType.Shadow_Resistance);
            }

            if (GetStat(totalStats, ItemStatType.Attack_Power) == GetStat(totalStats, ItemStatType.Ranged_Attack_Power))
            {
                removeStats.Add(ItemStatType.Ranged_Attack_Power);
            }

            foreach (var removeStat in removeStats)
            {
                int removeIndex = totalStats.FindIndex((_Value) => _Value.StatType == removeStat);
                if (removeIndex != -1)
                {
                    totalStats.RemoveAt(removeIndex);
                }
            }

            return(totalStats);
        }
Beispiel #2
0
        //public int GenerateStat(int _ItemID, int _SuffixID, int _EnchantID)
        //{
        //    if (_ItemID == int.Parse(ItemID))
        //    {
        //        var specifiedAjaxTooltip = GetAjaxTooltip(_ItemID, _SuffixID, _EnchantID, "");
        //    }
        //    return 0;
        //}

        private static ItemStat[] _Parse_Plus_Attribute(string _Data)
        {
            string[]   datas  = null;
            ItemStat[] result = null;
            if (_Data.Contains(" and "))
            {
                int afterAndIndex = _Data.IndexOf(" and ") + " and ".Length;
                if ((_Data[afterAndIndex] >= 'A' && _Data[afterAndIndex] <= 'Z') ||
                    (_Data[afterAndIndex] >= 'a' && _Data[afterAndIndex] <= 'z'))
                {
                    //Special case for "+5 Health and Mana every 5 sec"
                    datas = new string[] { _Data };
                }
                else
                {
                    datas = _Data.SplitVF(" and ");
                    for (int i = 0; i < datas.Length; ++i)
                    {
                        if (datas[i].Count((c) => c == '+') >= 2)
                        {
                            //Special case for "+11 Healing +4 Spell Damage and 2 mana per 5 sec"
                            string[] extraData = datas[i].SplitVF(" +");
                            string[] newDatas  = new string[datas.Length + extraData.Length - 1];
                            for (int u = 0; u < i; ++u)
                            {
                                newDatas[u] = datas[u];
                            }
                            for (int u = 0; u < extraData.Length; ++u)
                            {
                                newDatas[i + u] = extraData[u];
                            }
                            for (int u = i + 1; u < datas.Length; ++u)
                            {
                                newDatas[extraData.Length + u - 1] = datas[u];
                            }
                            datas = newDatas;
                        }
                    }
                }
            }
            else if (_Data.Contains(" & "))
            {
                datas = _Data.SplitVF(" & ");
            }
            else if (_Data.Contains(", "))
            {
                datas = _Data.SplitVF(", ");
            }
            else if (_Data.Contains(" +") == true)
            {
                datas = _Data.SplitVF(" +", StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                datas = new string[] { _Data };
            }
            result = new ItemStat[datas.Length];
            for (int i = 0; i < datas.Length; ++i)
            {
                string[] value_And_StatType = datas[i].Split(new char[] { ' ' }, 2);
                if (value_And_StatType[0].StartsWith("+"))
                {
                    value_And_StatType[0] = value_And_StatType[0].Substring(1);
                }
                string       valueStr    = value_And_StatType[0].Replace("%", "");
                string       statTypeStr = value_And_StatType[1].Replace(' ', '_').Replace(".", "");
                ItemStatType valueType   = ItemStatType.Unknown;
                statTypeStr = statTypeStr.ToLower();
                if (statTypeStr == "hit")
                {
                    valueType = ItemStatType.Hit_Chance;
                }
                else if (statTypeStr == "mana_every_5_seconds" || statTypeStr.ToLower() == "mana_per_5_sec" || statTypeStr == "mana_regen" || statTypeStr == "mana_every_5_sec")
                {
                    valueType = ItemStatType.Mp5;
                }
                else if (statTypeStr == "healing" || statTypeStr == "healing_spells")
                {
                    valueType = ItemStatType.Spell_Healing;
                }
                else if (statTypeStr == "health_and_mana_every_5_sec")
                {
                    valueType = ItemStatType.HMp5;
                }
                else
                {
                    try
                    {
                        valueType = (ItemStatType)Enum.Parse(typeof(ItemStatType), statTypeStr, true);
                    }
                    catch (Exception)
                    {
                        //to be added something in the future?
                    }
                }
                if (valueType != ItemStatType.Unknown)
                {
                    result[i] = new ItemStat(valueType, int.Parse(valueStr));
                }
            }
            return(result);
        }