Exemplo n.º 1
0
        /// <summary>
        /// Returns the item information for the items with the given ID
        /// </summary>
        /// <param name="itemID">ID of the item</param>
        /// <returns>Item object containing all item information, or null if the itemName is invalid</returns>
        public GW2PAO.API.Data.Entities.Item GetItem(int itemID)
        {
            GW2PAO.API.Data.Entities.Item item = null;

            try
            {
                var itemService = GW2.V2.Items.ForCurrentUICulture();
                var itemDetails = itemService.Find(itemID);
                if (itemDetails != null)
                {
                    item                  = new Data.Entities.Item(itemID, itemDetails.Name);
                    item.Icon             = itemDetails.IconFileUrl;
                    item.Description      = itemDetails.Description;
                    item.Rarity           = (Data.Enums.ItemRarity)itemDetails.Rarity;
                    item.Flags            = (Data.Enums.ItemFlags)itemDetails.Flags;
                    item.GameTypes        = (Data.Enums.ItemGameTypes)itemDetails.GameTypes;
                    item.LevelRequirement = itemDetails.Level;
                    item.VenderValue      = itemDetails.VendorValue;
                    item.ChatCode         = itemDetails.GetItemChatLink().ToString();
                    item.Prices           = this.GetItemPrices(itemID);

                    // Since there is no need to use ALL details right now, we'll just get what we need...
                    // TODO: Finish this up, get all details, such as Type, SkinID
                }
            }
            catch (GW2NET.Common.ServiceException ex)
            {
                // Don't crash, just return null
                logger.Warn("Error finding item with id {0}: {1}", itemID, ex);
            }

            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the item information for the item with the given names
        /// </summary>
        /// <param name="itemName">Name of the item</param>
        /// <param name="rarity">Rarity of the item</param>
        /// <param name="level">Level of the item</param>
        /// <returns>Item object containing all item information, or null if the itemName is invalid</returns>
        public GW2PAO.API.Data.Entities.Item GetItem(string itemName, Data.Enums.ItemRarity rarity, int level)
        {
            GW2PAO.API.Data.Entities.Item item = null;

            KeyValuePair <int, ItemDBEntry> itemEntry;

            itemEntry = this.ItemsDB.FirstOrDefault(itm => itm.Value.Name == itemName &&
                                                    itm.Value.Rarity == rarity &&
                                                    itm.Value.Level == level);

            if (itemEntry.Key != 0 || itemEntry.Value != null)
            {
                item = this.GetItem(itemEntry.Key);
            }

            return(item);
        }