Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }