public static bool ClickOptionText(string text) { GInterfaceObject[] options = VisibleOptions(); if (options.Length < 1) { return(false); } PPather.Debug("ClickOptionText() options.Length={0}, text={1}", options.Length, text); foreach (GInterfaceObject button in options) { if (button != null && button.IsVisible && Functions.LogCleaner(button.LabelText).ToLower().Contains(text.ToLower())) { Functions.Click(button); return(true); } foreach (GInterfaceObject child in button.Children) { if (child != null && child.IsVisible && Functions.LogCleaner(child.LabelText).ToLower().Contains(text.ToLower())) { Functions.Click(button); return(true); } } } return(false); }
public static bool CompareGear(EasyItem E, string item) { eq_item_score = 0; new_item_score = 0; if (!initialized) { return(false); } if (E == null && E.Item == null) { return(false); } if (IsEquippable(E)) { if (IsWanted(E)) { if (!IsProtected(E)) { if (IsUsable(E)) { PPather.Debug("CompareGear: checking {0} (Type={1}, SubType={2}, Slot={3})", E.RealName, E.Item.Type, E.Item.SubType, E.Item.Slot); return(Compare(E, item)); } } } } return(false); }
public static void CheckForBetterGear() { List <EasyItem> containers = new List <EasyItem>(); PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Inventory: Reading Inventory Items"); Character.GetInventoryItems(); PPather.Debug("\n=====================================\n=== CHECK OF {0} BAG ITEMS START ===\n=====================================\n", Character.InventoryItems.Count); foreach (KeyValuePair <long, EasyItem> e in Character.InventoryItems) { //PPather.WriteLine("AutoEquipTask: Got " + e.Key + " from InventoryItems"); EasyItem E = e.Value; PPather.Debug("\n\n=== AUTOEQUIP FOR {0} START ===", E.RealName); if (E.Item.Type.Equals("Containers")) { PPather.Debug("AutoEquip: {0} saved for CompareAndEquipBags()", E.RealName); containers.Add(E); PPather.Debug("\n=== AUTOEQUIP FOR {0} END ===\n", E.RealName); continue; } if (ItemCompare.CompareGear(E, E.RealName)) { PPather.WriteLine(LOG_CATEGORY.DEBUG, "AutoEquip: Equipped better gear [{0}]", E.RealName); } PPather.Debug("\n=== AUTOEQUIP FOR {0} END ===\n", E.RealName); } if (containers.Count > 0) { EasyItem[] C = containers.ToArray(); Inventory.CompareAndEquipBags(C); containers.Clear(); } PPather.Debug("\n=====================================\n=== CHECK OF {0} BAG ITEMS END ===\n=====================================\n", Character.InventoryItems.Count); }
public static void GetEquippedItems() { GItemHelper GIH = new GItemHelper(); if (CharacterSlots == null) { CharacterSlots = GetCharacterSlots(); } CharacterFrame.ShowFrame(); foreach (string slot in CharacterSlots) { string tooltipName = "none"; PPather.Debug("\n\n == SLOT LOOKUP FOR {0} START ==", slot); List <string> tooltip = CharacterFrame.GetTooltip(slot); if (tooltip != null && tooltip.Count > 0) { //foreach (string tip in tooltip) // PPather.WriteLine("Character: Tooltip[{0}]\t=>\t{1}", slot, tip); tooltipName = tooltip[tooltip.Count - 1]; } PPather.Debug("Character: Name for {0} = {1}", slot, tooltipName); if (tooltip == null || IsEmptySlotName(tooltipName)) { AddNullSlot(slot); } else { Item i = ItemManager.get(tooltipName); if (i == null) { AddNullSlot(slot); } else { GItem Item = (GItem)GObjectList.FindObject(GIH.GetEquippedGUID(slot)); if (Item == null) { continue; } EasyItem E = new EasyItem(Item, i, Item.GUID, tooltipName); try { CurrentlyEquipped.Add(slot, E); PPather.WriteLine(LOG_CATEGORY.INFORMATION, "Character: Item [{0}] equipped in '{1}'", tooltipName, slot); PPather.Debug(String.Format("ToolTip[{0}]: {1}", i.Name, CleanToolTip(tooltip))); } catch (ArgumentException) { PPather.Debug("Character: " + tooltipName + " is already added to CurrentlyEquipped (skipping)"); } } } PPather.Debug("\n=== SLOT LOOKUP FOR {0} END ===\n", slot); } CharacterFrame.HideFrame(); }
public static void AddNullSlot(string slot) { try { CurrentlyEquipped.Add(slot, null); PPather.Debug("Character: No currently equipped item for slot '" + slot + "'"); } catch (ArgumentException) { //PPather.WriteLine("Character: Already added 'null' to slot '" + slot + "'"); } }
public static GInterfaceObject[] VisibleOptions() { List <GInterfaceObject> options = new List <GInterfaceObject>(); for (int i = 1; i <= 32; i++) { GInterfaceObject btn = GContext.Main.Interface.GetByName("GossipTitleButton" + i); if (btn != null && btn.IsVisible) { PPather.Debug("GossipTitleButton{0} => {1}", i, Functions.LogCleaner(btn.LabelText)); options.Add(btn); } } return(options.ToArray()); }
public static EasyItem GetCurrent(string s) { EasyItem E; CurrentlyEquipped.TryGetValue(s, out E); if (E != null) { PPather.Debug("Character: GetCurrent for {0} is {1}", s, E.RealName); } else { PPather.Debug("Character: GetCurrent for {0} is {1}", s, "null"); } return(E); }
public static void put(Item i, string item) { //if (!connected) init(); lock (CacheLock) { // add without check. overrides any old objects try { ItemCache.Add(Clean(i.Name), i); PPather.Debug("ItemManager: Added " + item + " to ItemCache"); } catch (ArgumentException) { PPather.Debug("ItemManager: " + item + " already added to ItemCache (skipping)"); } } }
/// <summary> /// Sends a request to WowHead for the selected data type. Returns parsed /// data in a string delimited by '|' for each property. /// </summary> /// <param name="name">The name of the object to be queried</param> /// <param name="type">The type of the object (item, npc etc.)</param> /// <returns>Returns the parsed data in a string delimited by '|'</returns> public Dictionary <string, string> GetWowHeadItem(string name) { string output = GetWebResponse(name); if (output == null) { return(null); } if (output.Equals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><wowhead><error>Item not found!</error></wowhead>")) { string base_name = GetBaseName(name); output = GetWebResponse(base_name); } if (output != null) { PPather.Debug("WowHeadFetcher: response = {0}", output); return(ProcessWHData(name, output)); } return(null); }
public List <string> GetEnchantLines(string item_id) { WebRequest req = HttpWebRequest.Create("http://www.wowhead.com/?item=" + item_id.ToString()); WebResponse res = req.GetResponse(); System.IO.StreamReader reader = new StreamReader(res.GetResponseStream()); List <string> lines = new List <string>(); string line = null; while ((line = reader.ReadLine()) != null) { if (line.StartsWith("<li><div><span class=\"q2")) { lines.Add(line); PPather.Debug("EnchantLine: {0}", line); } } return(lines); }
public static Item get(string item) { Item i = null; // 1. check in memory cache if (ItemCache.ContainsKey(Clean(item))) { i = ItemCache[Clean(item)]; PPather.Debug("ItemManager.get: {0} fetched from ItemCache", item); return(i); } // 2. check in db DataRow data = db.GetItem(Clean(item)); if (data != null) { i = DataRow2Item(item, data); PPather.Debug("ItemManager.get: {0} fetched from Database", item); put(i, item); return(i); } // 3. fetch from WowHead i = GetItemFromWowHead(item); if (i != null) { if (i.Name == "0" || i.Name == null || i.Name == "") { i.Name = item; } PPather.Debug("ItemManager.get: {0} fetched from WoWHead", item); db.PutItem(i, item); put(i, item); return(i); } return(null); }
private static Item WowHead2Item(Dictionary <string, string> data, string name) { //PPather.WriteLine("WowHead2Item: Creating item of " + name); Item i = new Item(); string type = null; string subtype = null; string slot = null; data.TryGetValue("type", out type); data.TryGetValue("subtype", out subtype); data.TryGetValue("slot", out slot); slot = Character.Slots.get(slot); PPather.Debug("WowHead2Item: TYPE='{0}' SUBTYPE='{1}' SLOT='{2}'", type, subtype, slot); //string type = db.QueryFetchCell(String.Format("SELECT type_name FROM item_types WHERE type_id = {0}", Convert.ToInt32(ty))); //string subtype = db.QueryFetchCell(String.Format("SELECT subtype_name FROM item_subtypes WHERE subtype_id = {0}", Convert.ToInt32(st))); //string slot = db.QueryFetchCell(String.Format("SELECT slot_name FROM item_slots WHERE slot_id = {0}", Convert.ToInt32(sl))); //PPather.WriteLine("WowHead2Item: DB replied with type={0}, subtype={1} and slot={2}", type, subtype, slot); string wowhead_id = "0"; string icon = "0"; // http link to item icon on wowhead string required = "0"; string classes = "0"; string armor = "0"; string block = "0"; string min_damage = "0"; string max_damage = "0"; string speed = "0"; string dps = "0"; string agility = "0"; string intellect = "0"; string stamina = "0"; string spirit = "0"; string strength = "0"; string health = "0"; string mana = "0"; string mana_regen = "0"; string hp_regen = "0"; // complex, they are nested within each other string attack_power = "0"; string ranged_attack_power = "0"; string ranged_crit = "0"; string ranged_attack_speed = "0"; string attack_power_feral = "0"; string expertise = "0"; string defense = "0"; string resilience = "0"; string armor_penetration = "0"; string shield_block = "0"; string crit = "0"; string hit = "0"; string dodge = "0"; string parry = "0"; // complex, they are nested within each other but in 2 different ways string spell_power = "0"; string spell_hit = "0"; string spell_crit = "0"; string spell_haste = "0"; string spell_penetration = "0"; // Resists omg so much string resist_arcane = "0"; string resist_fire = "0"; string resist_frost = "0"; string resist_holy = "0"; string resist_nature = "0"; string resist_shadow = "0"; // + Damage string damage_arcane = "0"; string damage_fire = "0"; string damage_frost = "0"; string damage_holy = "0"; string damage_nature = "0"; string damage_shadow = "0"; foreach (KeyValuePair <string, string> e in data) { //PPather.WriteLine("WowHead2Item: {0}\t=>\t{1}", e.Key, e.Value); switch (e.Key) { case "wowheadid": wowhead_id = e.Value; break; case "icon": icon = e.Value; break; case "classes": classes = e.Value; break; case "required": required = e.Value; break; case "armor": armor = e.Value; break; case "block": block = e.Value; break; case "mindamage": min_damage = e.Value; break; case "maxdamage": max_damage = e.Value; break; case "speed": speed = e.Value; break; case "dps": dps = e.Value; break; case "agility": agility = e.Value; break; case "intellect": intellect = e.Value; break; case "stamina": stamina = e.Value; break; case "spirit": spirit = e.Value; break; case "strength": strength = e.Value; break; case "health": health = e.Value; break; case "mana": mana = e.Value; break; case "manaregen": mana_regen = e.Value; break; case "hpregen": hp_regen = e.Value; break; case "attackpower": attack_power = e.Value; break; case "rangedattackpower": ranged_attack_power = e.Value; break; case "rangedcrit": ranged_crit = e.Value; break; case "rangedattackspeed": ranged_attack_speed = e.Value; break; case "attackpowerferal": attack_power_feral = e.Value; break; case "expertise": expertise = e.Value; break; case "defense": defense = e.Value; break; case "resilience": resilience = e.Value; break; case "armorpenetration": armor_penetration = e.Value; break; case "shieldblock": shield_block = e.Value; break; case "crit": crit = e.Value; break; case "hit": hit = e.Value; break; case "dodge": dodge = e.Value; break; case "parry": parry = e.Value; break; case "spellpower": spell_power = e.Value; break; case "spellhit": spell_hit = e.Value; break; case "spellcrit": spell_crit = e.Value; break; case "spellhaste": spell_haste = e.Value; break; case "spellpenetration": spell_penetration = e.Value; break; case "resistarcane": resist_arcane = e.Value; break; case "resistfire": resist_fire = e.Value; break; case "resistfrost": resist_frost = e.Value; break; case "resistholy": resist_holy = e.Value; break; case "resistnature": resist_nature = e.Value; break; case "resistshadow": resist_shadow = e.Value; break; case "damagearcane": damage_arcane = e.Value; break; case "damagefire": damage_fire = e.Value; break; case "damagefrost": damage_frost = e.Value; break; case "damageholy": damage_holy = e.Value; break; case "damagenature": damage_nature = e.Value; break; case "damageshadow": damage_shadow = e.Value; break; } } //PPather.WriteLine("WowHead2Item: About to get wowhead_id from RD"); // data.TryGetValue("wowheadid", out wowhead_id); // data.TryGetValue("icon", out icon); // http link to item icon on wowhead // PPather.WriteLine("WowHead2Item: Set icon={0]",icon); // PPather.WriteLine("WowHead2Item: Set dps={0]",dps); // PPather.WriteLine("WowHead2Item: Set hp_regen={0]", hp_regen); // // complex, out they are nested within each other // // complex, out they are nested within each other but in 2 different ways // PPather.WriteLine("WowHead2Item: Set spell_penetration={0]", spell_penetration); // // Resists omg so much // PPather.WriteLine("WowHead2Item: Set resist_shadow={0]", resist_shadow); // // + Damage // PPather.WriteLine("WowHead2Item: Set damage_shadwo={0]", damage_shadow); i.Name = name; i.Type = type; i.SubType = subtype; i.Slot = slot; i.Icon = icon; i.Classes = classes; try { i.WowHeadId = Convert.ToInt32(wowhead_id); } catch { } try { i.Required = Convert.ToInt32(required); } catch { } try { i.Armor = Convert.ToInt32(armor); } catch { } try { i.Block = Convert.ToInt32(block); } catch { } try { i.MinDamage = Convert.ToInt32(min_damage); } catch { } try { i.MaxDamage = Convert.ToInt32(max_damage); } catch { } try { i.Speed = Convert.ToDouble(speed); } catch { } try { i.DPS = Convert.ToDouble(dps); } catch { } try { i.Agility = Convert.ToInt32(agility); } catch { } try { i.Intellect = Convert.ToInt32(intellect); } catch { } try { i.Stamina = Convert.ToInt32(stamina); } catch { } try { i.Spirit = Convert.ToInt32(spirit); } catch { } try { i.Strength = Convert.ToInt32(strength); } catch { } try { i.Health = Convert.ToInt32(health); } catch { } try { i.Mana = Convert.ToInt32(mana); } catch { } try { i.HealthRegen = Convert.ToInt32(hp_regen); } catch { } try { i.ManaRegen = Convert.ToInt32(mana_regen); } catch { } try { i.ResistArcane = Convert.ToInt32(resist_arcane); } catch { } try { i.ResistFire = Convert.ToInt32(resist_fire); } catch { } try { i.ResistFrost = Convert.ToInt32(resist_frost); } catch { } try { i.ResistHoly = Convert.ToInt32(resist_holy); } catch { } try { i.ResistNature = Convert.ToInt32(resist_nature); } catch { } try { i.ResistShadow = Convert.ToInt32(resist_shadow); } catch { } try { i.AttackPower = Convert.ToInt32(attack_power); } catch { } try { i.RangedAttackPower = Convert.ToInt32(ranged_attack_power); } catch { } try { i.RangedCrit = Convert.ToInt32(ranged_crit); } catch { } try { i.RangedAttackSpeed = Convert.ToInt32(ranged_attack_speed); } catch { } try { i.AttackPowerFeral = Convert.ToInt32(attack_power_feral); } catch { } try { i.Expertise = Convert.ToInt32(expertise); } catch { } try { i.Defense = Convert.ToInt32(defense); } catch { } try { i.Resilience = Convert.ToInt32(resilience); } catch { } try { i.ArmorPenetration = Convert.ToInt32(armor_penetration); } catch { } try { i.ShieldBlock = Convert.ToInt32(shield_block); } catch { } try { i.CriticalStrike = Convert.ToInt32(crit); } catch { } try { i.Hit = Convert.ToInt32(hit); } catch { } try { i.Dodge = Convert.ToInt32(dodge); } catch { } try { i.Parry = Convert.ToInt32(parry); } catch { } try { i.SpellPower = Convert.ToInt32(spell_power); } catch { } try { i.SpellHit = Convert.ToInt32(spell_hit); } catch { } try { i.SpellCrit = Convert.ToInt32(spell_crit); } catch { } try { i.SpellHaste = Convert.ToInt32(spell_haste); } catch { } try { i.SpellPenetration = Convert.ToInt32(spell_penetration); } catch { } try { i.DamageArcane = Convert.ToInt32(damage_arcane); } catch { } try { i.DamageFire = Convert.ToInt32(damage_fire); } catch { } try { i.DamageFrost = Convert.ToInt32(damage_frost); } catch { } try { i.DamageHoly = Convert.ToInt32(damage_holy); } catch { } try { i.DamageNature = Convert.ToInt32(damage_nature); } catch { } try { i.DamageShadow = Convert.ToInt32(damage_shadow); } catch { } return(i); }
public static Item GetItemFromWowHead(string item) { Item return_item = new Item(); bool ReturnItemSet = false; int variation = 0; Dictionary <string, string> rd = wh.GetWowHeadItem(item); PPather.Debug("GetItemFromWowHead: Got " + item + " from WowHead"); if (rd == null) { return(null); } string random_enchant = ""; rd.TryGetValue("randomenchant", out random_enchant); //PPather.WriteLine("ItemManager: random_enchant = " + random_enchant); if (random_enchant.Equals("Random Enchant")) { PPather.WriteLine(LOG_CATEGORY.DEBUG, "Getting all random enchant variants..."); /* get bonuses for all variants of the item */ Dictionary <string, string> tmp = new Dictionary <string, string>(); string item_id = null; foreach (KeyValuePair <string, string> e in rd) { if (e.Key.Equals("wowheadid")) { item_id = e.Value; } } List <string> lines = wh.GetEnchantLines(item_id); Regex bonusMatchPattern = new Regex("(?<=^|>)[^><]+?(?=<|$)"); foreach (string line in lines) { tmp.Clear(); PPather.Debug("GetItemFromWowHead: line = {0}", line); foreach (KeyValuePair <string, string> e in rd) { tmp[e.Key] = new string(e.Value.ToCharArray()); } List <string> bonuses = new List <string>(); bonuses.Clear(); string[] bonus_parts = null; MatchCollection mc = bonusMatchPattern.Matches(line); string subname = mc[0].Value.Replace("...", ""); string space = mc[1].Value; string percent = mc[2].Value; string bonus_string = mc[3].Value; PPather.Debug("GetItemFromWowHead: subname={0}, space={1}, percent={2}, bonus_string={3}", subname, space, percent, bonus_string); bonus_parts = bonus_string.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string bp in bonus_parts) { string[] sub_parts = null; if (bp.Contains("and")) { sub_parts = bp.Split(new string[] { " and " }, StringSplitOptions.RemoveEmptyEntries); foreach (string sp in sub_parts) { bonuses.Add(sp.TrimStart(new char[] { ' ' })); } } else { bonuses.Add(bp.TrimStart(new char[] { ' ' })); } } foreach (string b in bonuses) { PPather.Debug("GetItemFromWowHead: bonus\t=>\t{0}", b); } string last_val = null; foreach (string bonus in bonuses) { string attribute = null; string value = null; if (bonus.Contains(')')) { string[] c = bonus.Split(new char[] { ')' }); string attr = c[1].Remove(0, 1); //Attribute value = c[0].Replace(" ", "").Split(new char[] { '-' })[1]; //bonus attribute = ConformAttribute(attr); } else { if (bonus.Contains("+")) { value = bonus.Replace("+", "").Split(new char[] { ' ' })[0]; last_val = value; } else { value = last_val; last_val = "0"; } string attr = bonus.Substring(bonus.IndexOf(" ") + 1, bonus.Length - bonus.IndexOf(" ") - 1); attribute = ConformAttribute(attr); } PPather.Debug("GetItemFromWowHead: {0}[{1}] = {2}", subname, attribute, value); tmp[attribute] = value; } string full_name = wh.GetBaseName(item) + " " + subname; PPather.Debug("GetItemFromWowHead: Full Name = " + full_name); Item i = WowHead2Item(tmp, full_name); //PPather.WriteLine(Pather.LOG_CATEGORY.DEBUG,i.ToString()); if (full_name.Equals(item)) { return_item = WowHead2Item(tmp, full_name); ReturnItemSet = true; } else { db.PutItem(i, full_name); put(i, full_name); } if (!ReturnItemSet && variation >= lines.Count) { return_item = WowHead2Item(tmp, full_name); ReturnItemSet = true; } variation++; } } else { PPather.Debug("ItemManager: Regular item, parsing it..."); return_item = WowHead2Item(rd, item); } //PPather.WriteLine(return_item.ToString()); return(return_item); }
public static string get(string slot) { slot = slot.ToLower(); slot = slot.Replace("-", ""); slot = slot.Replace(" ", ""); switch (slot) { case "head": return(Head); case "neck": return(Neck); case "shoulder": return(Shoulder); case "back": return(Back); case "chest": return(Chest); case "shirt": return(Shirt); case "tabard": return(Tabard); case "wrist": return(Wrist); case "hands": return(Hands); case "waist": return(Waist); case "legs": return(Legs); case "feet": return(Feet); case "finger": return(Finger); case "finger0": return(Finger0); case "finger1": return(Finger1); case "trinket": return(Trinket); case "trinket0": return(Trinket0); case "trinket1": return(Trinket1); case "main": return(MainHand); case "mainhand": return(MainHand); case "twohand": return(MainHand); case "heldinmainhand": return(MainHand); case "heldinonehand": return(OneHand); case "onehand": return(OneHand); case "offhand": return(SecondaryHand); case "heldinoffhand": return(SecondaryHand); case "secondaryhand": return(SecondaryHand); case "shield": return(SecondaryHand); case "ranged": return(Ranged); case "relic": return(Ranged); default: PPather.Debug("Slots: Uknown (not equippable?): {0}", slot); return(slot); } }
public static void GetInventoryItems() { InventoryItems.Clear(); bm.UpdateItemsSorted(); for (int j = 0; j < bm.Bags.Length; j++) { //PPather.Debug("Charcater: Bags.Length = {0}",bm.Bags.Length); BagManager.Bag b = bm.Bags[j]; if (b.count < 1) { continue; } //PPather.Debug("Characater: Bags[{0}] contains {1} items",j,b.I.Length); bm.OpenBag(b.bag); GItem[] Items = null; if (b.I != null) { Items = b.I; } if (Items == null || Items.Length < 1) { continue; } foreach (GItem Item in Items) { if (Item == null || Item.GUID == 0) { continue; } PPather.Debug("\n\n == ITEM LOOKUP FOR {0} START ==", Item.Name); List <string> tooltip = GetTooltipOnOpenBags(Item); if (tooltip == null || tooltip.Count < 1) { PPather.Debug("Character.GetInventoryItems: tooltip for {0} is emtpy", Item.Name); } else { string tooltipName = tooltip[tooltip.Count - 1]; PPather.Debug("Character.GetInventoryItems: tooltip[0] for {0} is {1}", Item.Name, tooltipName); Item i = ItemManager.get(tooltipName); if (i == null) { PPather.Debug("Character: ItemManager return null, {0} most likely not equippable", tooltipName); continue; } try { EasyItem E = new EasyItem(Item, i, Item.GUID, tooltipName); InventoryItems.Add(Item.GUID, E); PPather.WriteLine(Pather.LOG_CATEGORY.INFORMATION, "Character: {0} added to InventoryItems", tooltipName); //PPather.WriteLine(String.Format("DEBUG: Item.Type = {0} , Item.Quality = {1}",E.GItem.Type.ToString(), E.GItem.Definition.Quality.ToString())); //PPather.WriteLine(String.Format("Charcter: Item [{0}] found in bags", i.Name)); //PPather.WriteLine(String.Format("ToolTip[{0}]: {1}", i.Name, CleanToolTip(tooltip))); } catch (ArgumentException) { PPather.Debug("Character.GetInventoryItems: {0}({1}) is already added to InventoryItems (skipping)", tooltipName, Item.GUID); } } PPather.Debug("\n=== ITEM LOOKUP FOR {0} END ===\n", Item.Name); } } bm.CloseAllBags(); }
// Process the wowhead xml into a string to pass to storeitem private Dictionary <string, string> ProcessWHData(string itemName, string data) { string _icon_path = "http://static.wowhead.com/images/icons/large/"; string tooltip = ""; Dictionary <string, string> rd = new Dictionary <string, string>(); // return_data string wowhead_id = "0"; string type = "0"; string subtype = "0"; string slot = "0"; string icon = "0"; // http link to item icon on wowhead string required = "0"; string classes = "0"; string armor = "0"; string block = "0"; string min_damage = "0"; string max_damage = "0"; string speed = "0"; string dps = "0"; string agility = "0"; string intellect = "0"; string stamina = "0"; string spirit = "0"; string strength = "0"; string health = "0"; string mana = "0"; string mana_regen = "0"; string hp_regen = "0"; // complex, they are nested within each other string attack_power = "0"; string ranged_attack_power = "0"; string ranged_crit = "0"; string ranged_attack_speed = "0"; string attack_power_feral = "0"; string expertise = "0"; string defense = "0"; string resilience = "0"; string armor_penetration = "0"; string shield_block = "0"; string crit = "0"; string hit = "0"; string dodge = "0"; string parry = "0"; // complex, they are nested within each other but in 2 different ways string spell_power = "0"; string spell_hit = "0"; string spell_crit = "0"; string spell_haste = "0"; string spell_penetration = "0"; // Resists omg so much string resist_arcane = "0"; string resist_fire = "0"; string resist_frost = "0"; string resist_holy = "0"; string resist_nature = "0"; string resist_shadow = "0"; // + Damage string damage_arcane = "0"; string damage_fire = "0"; string damage_frost = "0"; string damage_holy = "0"; string damage_nature = "0"; string damage_shadow = "0"; string random_enchant = "0"; System.Xml.XmlDocument WHData; System.Xml.XmlNode WHRoot; data = data.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", ""); WHData = new System.Xml.XmlDocument(); WHData.LoadXml(@data); WHRoot = WHData.SelectSingleNode("wowhead"); foreach (XmlNode Node in WHRoot.ChildNodes) { if (Node.Name == "item") { foreach (XmlNode Attrib in Node.Attributes) { if (Attrib.Name == "id") { wowhead_id = Attrib.Value; } } foreach (XmlNode Node2 in Node.ChildNodes) { if (Node2.Name == "class") { type = Node2.InnerText; } if (Node2.Name == "subclass" && Node2.InnerText != "") { subtype = Node2.InnerText; } if (Node2.Name == "inventorySlot" && Node2.InnerText != "") { slot = Node2.InnerText; } if (Node2.Name == "icon" && Node2.InnerText != "") { icon = _icon_path + Node2.InnerText.ToLowerInvariant(); } if (Node2.Name == "htmlTooltip") { tooltip = Node2.InnerText; } } } } MatchCollection myMatchCollection = Regex.Matches(tooltip, @"Requires Level ([0-9]{1,2})"); foreach (Match myMatch in myMatchCollection) { required = myMatch.ToString().Replace("Requires Level ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Classes: ([^<]*)"); foreach (Match myMatch in myMatchCollection) { classes = myMatch.ToString().Replace("Classes: ", ""); } myMatchCollection = Regex.Matches(tooltip, @"([0-9]*)\sArmor"); foreach (Match myMatch in myMatchCollection) { armor = myMatch.ToString().Replace(" Armor", ""); } myMatchCollection = Regex.Matches(tooltip, @"([0-9]*)\sBlock"); foreach (Match myMatch in myMatchCollection) { block = myMatch.ToString().Replace(" Block", ""); } myMatchCollection = Regex.Matches(tooltip, @"([0-9]*)\s-\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { min_damage = myMatch.ToString().Replace(" ", ""); string[] result = min_damage.Split(new Char[] { '-' }); min_damage = result[0]; max_damage = result[1]; } myMatchCollection = Regex.Matches(tooltip, @"Speed\s([0-9\.]*)"); foreach (Match myMatch in myMatchCollection) { speed = myMatch.ToString().Replace("Speed ", ""); } myMatchCollection = Regex.Matches(tooltip, @"([0-9\.]*)\sdamage\sper\ssecond"); foreach (Match myMatch in myMatchCollection) { dps = myMatch.ToString().Replace(" damage per second", ""); } myMatchCollection = Regex.Matches(tooltip, @".*Random\senchantment.*"); foreach (Match myMatch in myMatchCollection) { random_enchant = "Random Enchant"; } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sAgility"); foreach (Match myMatch in myMatchCollection) { agility = myMatch.ToString().Replace("+", "").Replace(" Agility", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sIntellect"); foreach (Match myMatch in myMatchCollection) { intellect = myMatch.ToString().Replace("+", "").Replace(" Intellect", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sStamina"); foreach (Match myMatch in myMatchCollection) { stamina = myMatch.ToString().Replace("+", "").Replace(" Stamina", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sSpirit"); foreach (Match myMatch in myMatchCollection) { spirit = myMatch.ToString().Replace("+", "").Replace(" Spirit", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sStrength"); foreach (Match myMatch in myMatchCollection) { strength = myMatch.ToString().Replace("+", "").Replace(" Strength", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sHealth"); foreach (Match myMatch in myMatchCollection) { health = myMatch.ToString().Replace("+", "").Replace(" Health", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9]*)\sMana"); foreach (Match myMatch in myMatchCollection) { mana = myMatch.ToString().Replace("+", "").Replace(" Mana", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sRestores\s([0-9\.]*)\shealth\sper\s5\ssec"); foreach (Match myMatch in myMatchCollection) { hp_regen = myMatch.ToString().Replace("Equip: Restores ", "").Replace(" health per 5 sec", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sRestores\s([0-9\.]*)\smana\sper\s5\ssec"); foreach (Match myMatch in myMatchCollection) { mana_regen = myMatch.ToString().Replace("Equip: Restores ", "").Replace(" mana per 5 sec", ""); } // Catch all for the hybrid items with both melee and ranged merged together myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\smelee\sand\sranged\sattack\spower\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { attack_power = myMatch.ToString().Replace("Equip: Increases melee and ranged attack power by ", ""); ranged_attack_power = attack_power; } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sattack\spower\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { attack_power = myMatch.ToString().Replace("Equip: Increases attack power by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sranged\sattack\spower\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { ranged_attack_power = myMatch.ToString().Replace("Equip: Increases ranged attack power by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\syour\sranged\sweapon\scritical\sstrike\sdamage\sbonus\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { ranged_crit = myMatch.ToString().Replace("Equip: Increases your ranged weapon critical strike damage bonus by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sranged\sattack\sspeed\sby\s([0-9]*)%"); foreach (Match myMatch in myMatchCollection) { ranged_attack_speed = myMatch.ToString().Replace("Equip: Increases ranged attack speed by ", "").Replace("%", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sattack\spower\sby\s([0-9]*)\sin\sCat,\sBear,\sDire\sBear,\sand\sMoonkin\sforms\sonly"); foreach (Match myMatch in myMatchCollection) { attack_power_feral = myMatch.ToString().Replace("Equip: Increases attack power by ", "").Replace(" in Cat, Bear, Dire Bear, and Moonkin forms only", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\syour\sexpertise\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { expertise = myMatch.ToString().Replace("Equip: Increases your expertise rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdefense\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { defense = myMatch.ToString().Replace("Equip: Increases defense rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves\sresilience\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { resilience = myMatch.ToString().Replace("Equip: Increases resilience rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sYou\sattacks\signore\s([0-9]*)\sof\syour\sopponent"); foreach (Match myMatch in myMatchCollection) { armor_penetration = myMatch.ToString().Replace("Equip: Your attacks ignore ", "").Replace(" of your oppenent", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\syour\sshield\sblock\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { shield_block = myMatch.ToString().Replace("Equip: Increases your shield block rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves critical strike rating by\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { crit = myMatch.ToString().Replace("Equip: Improves critical strike rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves hit rating by\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { hit = myMatch.ToString().Replace("Equip: Improves hit rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases your dodge rating by\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { dodge = myMatch.ToString().Replace("Equip: Increases your dodge rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\syour\sparry\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { parry = myMatch.ToString().Replace("Equip: Increases your parry rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sspell\spower\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { spell_power = myMatch.ToString().Replace("Equip: Increases spell power by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves\sspell\shit\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { spell_hit = myMatch.ToString().Replace("Equip: Improves spell hit rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves\sspell\scritical\sstrike\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { spell_crit = myMatch.ToString().Replace("Equip: Improves spell critical strike rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sImproves\sspell\shaste\srating\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { spell_haste = myMatch.ToString().Replace("Equip: Improves spell haste rating by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\syour\sspell\spenetration\sby\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { spell_penetration = myMatch.ToString().Replace("Equip: Increases your spell penetration by ", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sArcane\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_arcane = myMatch.ToString().Replace("+", "").Replace(" Arcane Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sFire\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_fire = myMatch.ToString().Replace("+", "").Replace(" Fire Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sFrost\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_frost = myMatch.ToString().Replace("+", "").Replace(" Frost Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sHoly\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_holy = myMatch.ToString().Replace("+", "").Replace(" Holy Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sNature\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_nature = myMatch.ToString().Replace("+", "").Replace(" Nature Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"\+([0-9\.]*)\sShadow\sResistance"); foreach (Match myMatch in myMatchCollection) { resist_shadow = myMatch.ToString().Replace("+", "").Replace(" Shadow Resistance", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sArcane\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_arcane = myMatch.ToString().Replace("Equip: Increases damage done by Arcane spells and effects by up to ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sFire\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_fire = myMatch.ToString().Replace("Equip: Increases damage done by Fire spells and effects by up to ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sFrost\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_frost = myMatch.ToString().Replace("Equip: Increases damage done by Frost spells and effects by up to ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sHoly\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_holy = myMatch.ToString().Replace("Equip: Increases damage done by Holy spells and effects by up to ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sNature\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_nature = myMatch.ToString().Replace("Equip: Increases damage done by Nature spells and effects by up to ", ""); } myMatchCollection = Regex.Matches(tooltip, @"Equip:\sIncreases\sdamage\sdone\sby\sShadow\sspells\sand\seffects\sby\sup\sto\s([0-9]*)"); foreach (Match myMatch in myMatchCollection) { damage_shadow = myMatch.ToString().Replace("Equip: Increases damage done by Shadow spells and effects by up to ", ""); } //Context.Log(" Requires Level: " + required + " Classes: " + classes + " Armor: " + armor + " DPS: " + dps + " Agility: " + agility + " Intellect: " + intellect + " Stamina: " + stamina + " Spirit: " + spirit + " Strength: " + strength + " Health: " + health + " Mana: " + mana); string return_value = wowhead_id + "|" + type + "|" + subtype + "|" + slot + "|" + icon + "|" + required + "|" + classes + "|" + armor + "|" + block + "|" + min_damage + "|" + max_damage + "|" + speed + "|" + dps + "|" + agility + "|" + intellect + "|" + stamina + "|" + spirit + "|" + strength + "|" + health + "|" + mana + "|" + hp_regen + "|" + mana_regen + "|" + attack_power + "|" + ranged_attack_power + "|" + ranged_crit + "|" + ranged_attack_speed + "|" + attack_power_feral + "|" + expertise + "|" + defense + "|" + resilience + "|" + armor_penetration + "|" + shield_block + "|" + crit + "|" + hit + "|" + dodge + "|" + parry + "|" + spell_power + "|" + spell_hit + "|" + spell_crit + "|" + spell_haste + "|" + spell_penetration + "|" + resist_arcane + "|" + resist_fire + "|" + resist_frost + "|" + resist_holy + "|" + resist_nature + "|" + resist_shadow + "|" + damage_arcane + "|" + damage_fire + "|" + damage_frost + "|" + damage_holy + "|" + damage_nature + "|" + damage_shadow; PPather.Debug("WoWHead Return: {0}", return_value); rd.Add("wowheadid", wowhead_id); rd.Add("type", type); rd.Add("subtype", subtype); rd.Add("slot", slot); rd.Add("icon", icon); // http link to item icon on wowhead rd.Add("required", required); rd.Add("classes", classes); rd.Add("armor", armor); rd.Add("block", block); rd.Add("mindamage", min_damage); rd.Add("maxdamage", max_damage); rd.Add("speed", speed); rd.Add("dps", dps); rd.Add("agility", agility); rd.Add("intellect", intellect); rd.Add("stamina", stamina); rd.Add("spirit", spirit); rd.Add("strength", strength); rd.Add("health", health); rd.Add("mana", mana); rd.Add("manaregen", mana_regen); rd.Add("hpregen", hp_regen); // complex, they are nested within each other rd.Add("attackpower", attack_power); rd.Add("rangedattackpower", ranged_attack_power); rd.Add("rangedcrit", ranged_crit); rd.Add("rangedattackspeed", ranged_attack_speed); rd.Add("attackpowerferal", attack_power_feral); rd.Add("expertise", expertise); rd.Add("defense", "0"); rd.Add("resilience", resilience); rd.Add("armorpenetration", armor_penetration); rd.Add("shieldblock", shield_block); rd.Add("crit", crit); rd.Add("hit", hit); rd.Add("dodge", dodge); rd.Add("parry", parry); // complex, they are nested within each other but in 2 different ways rd.Add("spellpower", spell_power); rd.Add("spellhit", spell_hit); rd.Add("spellcrit", spell_crit); rd.Add("spellhaste", spell_haste); rd.Add("spellpenetration", spell_penetration); // Resists omg so much rd.Add("resistarcane", resist_arcane); rd.Add("resistfire", resist_fire); rd.Add("resistfrost", resist_frost); rd.Add("resistholy", resist_holy); rd.Add("resistnature", resist_nature); rd.Add("resistshadow", resist_shadow); // + Damage rd.Add("damagearcane", damage_arcane); rd.Add("damagefire", damage_fire); rd.Add("damagefrost", damage_frost); rd.Add("damageholy", damage_holy); rd.Add("damagenature", damage_nature); rd.Add("damageshadow", damage_shadow); // Random enchant rd.Add("randomenchant", random_enchant); return(rd); }