Esempio n. 1
0
 public static void Add(string itemId, ItemLocation itemLocation)
 {
     lock (_allLocations)
     {
         _allLocations[itemId] = new ItemLocation[] { itemLocation, null };
     }
 }
Esempio n. 2
0
        public static ItemLocation Create(XmlNode node, string itemId)
        {
            ItemLocation item = null;

            try
            {
                if (node != null && node.SelectSingleNode("page/itemTooltips/itemTooltip/itemSource") != null)
                {
                    string sourceType = node.SelectSingleNode("page/itemTooltips/itemTooltip/itemSource").Attributes["value"].Value;
                    if (_LocationFactory.ContainsKey(sourceType))
                    {
                        item = _LocationFactory[sourceType]();
                        item = item.Fill(node, itemId);
                    }
                    else
                    {
                        throw new Exception("Unrecognized item source " + sourceType);
                    }
                }
                else
                {
                    item = UnknownItem.Construct();
                }
            }
            catch (System.Exception e)
            {
                item = new ItemLocation("Failed - " + e.Message);
            }
            _allLocations[itemId] = item;

            return(item);
        }
Esempio n. 3
0
 public static void Add(string itemId, ItemLocation itemLocation)
 {
     if (_allLocations.ContainsKey(itemId))
     {
         _allLocations.Remove(itemId);
     }
     _allLocations.Add(itemId, new ItemLocation[] { itemLocation, null });
 }
Esempio n. 4
0
        public static ItemLocation[] Lookup(string id)
        {
            ItemLocation[] item = { null, null };
            if (_allLocations.TryGetValue(id, out item))
            {
                return(item);
            }
            item = new ItemLocation[] { new ItemLocation("Unknown Location, please refresh"), null };

            return(item);
        }
Esempio n. 5
0
        public static ItemLocation CreateItemLocsFromXDoc(XDocument xdoc, string itemId)
        {
            ItemLocation locs = null;

            try
            {
                if (xdoc != null && xdoc.SelectSingleNode("itemData/page/itemTooltips/itemTooltip/itemSource") != null)
                {
                    string sourceType = xdoc.SelectSingleNode("itemData/page/itemTooltips/itemTooltip/itemSource").Attribute("value").Value;
                    locs = LocationFactoryDictionary[sourceType]();
                    locs = locs.Fill(xdoc, itemId);
                }
                else
                {
                    locs = UnknownItem.Construct();
                }
            }
            catch (Exception ex)
            {
                locs = new ItemLocation("Failed - " + ex.Message);
            }
            return(locs);
        }
Esempio n. 6
0
        public static ItemLocation Create(XDocument xdoc, string itemId)
        {
            ItemLocation item = null;

            try {
                if (xdoc != null && xdoc.SelectSingleNode("itemData/page/itemTooltips/itemTooltip/itemSource") != null)
                {
                    string sourceType = xdoc.SelectSingleNode("itemData/page/itemTooltips/itemTooltip/itemSource").Attribute("value").Value;
                    if (_LocationFactory.ContainsKey(sourceType))
                    {
                        item = _LocationFactory[sourceType]();
                        item = item.Fill(xdoc, itemId);
                    }
                    else
                    {
                        throw new Exception("Unrecognized item source " + sourceType);
                    }
                }
                else
                {
                    item = UnknownItem.Construct();
                }
            }
            catch (System.Exception e)
            {
                item = new ItemLocation("Failed - " + e.Message);
            }
            ItemLocation[] prev = { null, null };
            _allLocations.TryGetValue(itemId, out prev);
            if (prev != null && prev[0] != null)
            {
                item.Note = prev[0].Note;
            }
            _allLocations[itemId] = new ItemLocation[] { item, null };

            return(item);
        }
Esempio n. 7
0
        public static ItemLocation Create(XmlNode node, string itemId)
        {
            ItemLocation item = null;

            try
            {
                if (node != null && node.SelectSingleNode("page/itemTooltips/itemTooltip/itemSource") != null)
                {
                    WebRequestWrapper wrw        = new WebRequestWrapper();
                    XmlDocument       doc        = wrw.DownloadItemInformation(int.Parse(itemId));
                    string            sourceType = node.SelectSingleNode("page/itemTooltips/itemTooltip/itemSource").Attributes["value"].Value;

                    // If the armory has an item source set to creatureDrop, check to see if it might also be a vendor sold item
                    // and if so, switch it's type to vendor
                    if (sourceType == "sourceType.creatureDrop")
                    {
                        if (doc != null)
                        {
                            XmlNode subNode = doc.SelectSingleNode("/page/itemInfo/item/cost/token");
                            if (subNode != null)
                            {
                                sourceType = "sourceType.vendor";
                            }
                        }
                    }
                    // If the armory has an item source set to vendor, check to see if it cost honor or arena point to purchase and if so,
                    // switch it's type to pvpItem
                    if (sourceType == "sourceType.vendor")
                    {
                        if (doc != null)
                        {
                            XmlNode subNodeH = doc.SelectSingleNode("/page/itemInfo/item/cost/@honor");
                            XmlNode subNodeA = doc.SelectSingleNode("/page/itemInfo/item/cost/@arena");

                            if (subNodeH != null || subNodeA != null)
                            {
                                sourceType = "sourceType.pvpReward";
                            }
                        }
                    }
                    if (_LocationFactory.ContainsKey(sourceType))
                    {
                        item = _LocationFactory[sourceType]();
                        item = item.Fill(doc, node, itemId);
                    }
                    else
                    {
                        throw new Exception("Unrecognized item source " + sourceType);
                    }
                }
                else
                {
                    item = UnknownItem.Construct();
                }
            }
            catch (System.Exception e)
            {
                item = new ItemLocation("Failed - " + e.Message);
            }
            ItemLocation[] prev = { null, null };
            _allLocations.TryGetValue(itemId, out prev);
            if (prev != null)
            {
                item.Note = prev[0].Note;
            }
            _allLocations[itemId] = new ItemLocation[] { item, null };

            return(item);
        }