Exemplo n.º 1
0
        /// <summary>
        /// Check every item inside the list we are going to give away or we are going to receive
        /// The description we got earlier got all the items inside the trade, look there which item is ours or theirs so we have more informations about the item
        ///
        /// Enumerate trough all values of the enum ItemType
        /// If we want to allow trading cards and foil trading cards to be added to our itemslist, therefore use the binary OR operator "ItemType.TRADING_CARD | ItemType.FOIL_TRADING_CARD"
        /// If it is set inside our parameter "_items" use it on the switch and add the item to the list
        /// </summary>
        /// <param name="_listToCheck"></param>
        /// <param name="_offersResponse"></param>
        /// <param name="_items"></param>
        private List <TradeOfferItemDescription> FillItemsList(List <TradeOfferItem> _listToCheck, GetOffersResponse _offersResponse, ItemType _items)
        {
            List <TradeOfferItemDescription> itemListToFill = new List <TradeOfferItemDescription>();

            foreach (TradeOfferItem item in _listToCheck)
            {
                if (item.AppID == "753")
                {
                    TradeOfferItemDescription itemWithDescription = _offersResponse.Descriptions.First(_itemDescription => _itemDescription.ClassID == item.ClassID && _itemDescription.InstanceID == item.InstanceID);

                    Array checkTypeValues = Enum.GetValues(typeof(ItemType));

                    foreach (ItemType itemType in checkTypeValues)
                    {
                        if ((_items & itemType) == itemType)
                        {
                            switch (itemType)
                            {
                            case ItemType.BOOSTER_PACK:
                                if (itemWithDescription.Type.ToLower().Contains("booster pack"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;

                            case ItemType.EMOTICON:
                                if (itemWithDescription.Type.ToLower().Contains("emoticon"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;

                            case ItemType.PROFILE_BACKGROUND:
                                if (itemWithDescription.Type.ToLower().Contains("profile background"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;

                            case ItemType.STEAM_GEMS:
                                if (itemWithDescription.Type.Equals("Steam Gems"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;

                            case ItemType.FOIL_TRADING_CARD:
                                if (itemWithDescription.Type.ToLower().Contains("foil"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;

                            case ItemType.TRADING_CARD:
                                if (itemWithDescription.Type.ToLower().Contains("trading card") && !itemWithDescription.Type.ToLower().Contains("foil"))
                                {
                                    itemListToFill.Add(itemWithDescription);
                                }
                                break;
                            }
                        }
                    }
                }
            }

            return(itemListToFill);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get the appID of the game from the marketHashName
 /// The appID is the number at the beginning before the '-' so we want to split it at the '-'
 /// Return the left (first) part of the string array we got as a integer
 /// </summary>
 /// <param name="_item"></param>
 /// <returns></returns>
 private int GetAppIDFromItem(TradeOfferItemDescription _item)
 {
     return(Convert.ToInt32(_item.MarketHashName.Split('-')[0]));
 }