private void AddIfGreaterThan <T>(ItemStat <T> stat, T value) where T : System.IComparable <T> { if (stat != null && stat.Value.CompareTo(value) > value.CompareTo(stat.Value)) { ItemStats.Add(stat); } }
private void AddIfTrue(ItemStat <bool> stat) { if (stat != null && stat.Value) { ItemStats.Add(stat); } }
private void AddIfNotNull(ItemField field) { if (field != null) { ItemStats.Add(field); } }
public void RecordStatsWotLK() { if (ItemType != "Armor" && ItemType != "Weapon") { return; } string stats = Lua.LuaDoString <string>($@" local itemstats=GetItemStats(""{ItemLink.Replace("\"", "\\\"")}"") local stats = """" for stat, value in pairs(itemstats) do stats = stats.._G[stat]..""§""..value..""$"" end return stats"); //Logger.Log("stats -> " + stats); if (stats.Length < 1) { return; } List <string> statsPairs = stats.Split('$').ToList(); foreach (string pair in statsPairs) { if (pair.Length > 0) { string[] statsPair = pair.Split('§'); string statName = statsPair[0]; float statValue = float.Parse(statsPair[1], CultureInfo.InvariantCulture); if (!ItemStats.ContainsKey(statName)) { ItemStats.Add(statName, statValue); } } } RecordWeightScore(); }
public void RecordToolTipTBC() { if (ItemType != "Armor" && ItemType != "Weapon") { return; } // Record the info present in the tooltip string lines = Lua.LuaDoString <string>($@" WEquipTooltip:ClearLines() WEquipTooltip:SetHyperlink(""{ItemLink}"") return EnumerateTooltipLines(WEquipTooltip: GetRegions())"); string[] allLines = lines.Split('|'); foreach (string l in allLines) { bool lineRecorded = false; if (l.Length > 0 && l != "r" && !l.Contains("Socket") && !l.Contains("Requires") && !l.Contains(Name) && !l.Contains("Binds") && !l.Contains("Unique")) { // Look for item stats foreach (KeyValuePair <string, CharStat> statEnum in StatEnums) { if (l.ToLower().Contains(statEnum.Key.ToLower())) { if (ObjectManager.Me.WowClass != WoWClass.Druid && l.Contains("Cat, Bear")) { continue; } string line = l.Replace(".", ",").Replace("(", "").Replace(")", ""); if (line.Contains("and damage done")) { Match prefix = Regex.Match(line, @"^.*?(?=and damage done)"); line = line.Replace(prefix.Value, ""); } string[] words = line.Split(' '); string value = string.Empty; bool statNumberFound = false; foreach (string word in words) { for (int i = 0; i < word.Length; i++) { if (char.IsDigit(word[i]) || word[i] == ',') { value += word[i]; statNumberFound = true; } } if (statNumberFound) { break; } } if (value.Length > 0 && !ItemStats.ContainsKey(statEnum.Key)) { ItemStats.Add(statEnum.Key, float.Parse(value)); lineRecorded = true; } else { Logger.LogError($"No value found for {statEnum.Value}"); } break; } } if (lineRecorded) { continue; } // record specifics if (ItemType == "Weapon" && l.Contains("Speed ")) { WeaponSpeed = float.Parse(l.Replace("Speed ", "").Replace(".", ",")); } /*if (!lineRecorded) * Logger.LogError($"Ignored : {l}");*/ } } RecordWeightScore(); }