Beispiel #1
0
 public TradeOffer(OfferSession session, SteamID partnerSteamdId)
 {
     Items               = new TradeStatus();
     IsOurOffer          = true;
     OfferState          = TradeOfferState.TradeOfferStateUnknown;
     this.Session        = session;
     this.PartnerSteamId = partnerSteamdId;
 }
Beispiel #2
0
        public TradeOffer(OfferSession session, Offer offer)
        {
            var myAssets           = new List <TradeStatusUser.TradeAsset>();
            var myMissingAssets    = new List <TradeStatusUser.TradeAsset>();
            var theirAssets        = new List <TradeStatusUser.TradeAsset>();
            var theirMissingAssets = new List <TradeStatusUser.TradeAsset>();

            if (offer.ItemsToGive != null)
            {
                foreach (var asset in offer.ItemsToGive)
                {
                    var tradeAsset = new TradeStatusUser.TradeAsset();
                    //todo: for currency items we need to check descriptions for currency bool and use the appropriate method
                    tradeAsset.CreateItemAsset(Convert.ToInt64(asset.AppId), Convert.ToInt64(asset.ContextId),
                                               Convert.ToInt64(asset.AssetId), Convert.ToInt64(asset.Amount));
                    //todo: for missing assets we should store them somewhere else? if offer state is active we shouldn't be here though
                    if (!asset.IsMissing)
                    {
                        myAssets.Add(tradeAsset);
                    }
                    else
                    {
                        myMissingAssets.Add(tradeAsset);
                    }
                }
            }
            if (offer.ItemsToReceive != null)
            {
                foreach (var asset in offer.ItemsToReceive)
                {
                    var tradeAsset = new TradeStatusUser.TradeAsset();
                    tradeAsset.CreateItemAsset(Convert.ToInt64(asset.AppId), Convert.ToInt64(asset.ContextId),
                                               Convert.ToInt64(asset.AssetId), Convert.ToInt64(asset.Amount));
                    if (!asset.IsMissing)
                    {
                        theirAssets.Add(tradeAsset);
                    }
                    else
                    {
                        theirMissingAssets.Add(tradeAsset);
                    }
                }
            }
            this.Session = session;
            //assume public individual
            PartnerSteamId = new SteamID(Convert.ToUInt32(offer.AccountIdOther), EUniverse.Public, EAccountType.Individual);
            TradeOfferId   = offer.TradeOfferId;
            OfferState     = offer.TradeOfferState;
            IsOurOffer     = offer.IsOurOffer;
            ExpirationTime = offer.ExpirationTime;
            TimeCreated    = offer.TimeCreated;
            TimeUpdated    = offer.TimeUpdated;
            Message        = offer.Message;
            Items          = new TradeStatus(myAssets, theirAssets);
        }
 public TradeOfferManager(string apiKey, SteamWeb steamWeb, DateTime lastTimeCheckedOffers)
 {
     if (apiKey == null)
     {
         throw new ArgumentNullException(nameof(apiKey));
     }
     LastTimeCheckedOffers = lastTimeCheckedOffers;
     _webApi = new TradeOfferWebAPI(apiKey, steamWeb);
     Session = new OfferSession(_webApi, steamWeb);
     _unhandledTradeOfferUpdates = new ConcurrentQueue <Offer>();
 }