public TradeOffer(OfferSession session, Offer offer)
        {
            var myAssets    = new List <TradeAsset>();
            var theirAssets = new List <TradeAsset>();

            if (offer.ItemsToGive != null)
            {
                foreach (var asset in offer.ItemsToGive)
                {
                    var tradeAsset = new TradeAsset();

                    // todo: for currency items we need to check descriptions for currency bool and use the appropriate method
                    tradeAsset.CreateItemAsset(
                        Convert.ToInt64(asset.AppId),
                        asset.ContextId,
                        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);
                    }
                }
            }

            if (offer.ItemsToReceive != null)
            {
                foreach (var asset in offer.ItemsToReceive)
                {
                    var tradeAsset = new TradeAsset();
                    tradeAsset.CreateItemAsset(
                        Convert.ToInt64(asset.AppId),
                        asset.ContextId,
                        asset.AssetId,
                        Convert.ToInt64(asset.Amount));
                    if (!asset.IsMissing)
                    {
                        theirAssets.Add(tradeAsset);
                    }
                }
            }

            this.Session = session;

            // assume public individual
            this.PartnerSteamId = new SteamID(
                Convert.ToUInt32(offer.AccountIdOther),
                EUniverse.Public,
                EAccountType.Individual);
            this.TradeOfferId   = offer.TradeOfferId;
            this.OfferState     = offer.TradeOfferState;
            this.IsOurOffer     = offer.IsOurOffer;
            this.ExpirationTime = offer.ExpirationTime;
            this.TimeCreated    = offer.TimeCreated;
            this.TimeUpdated    = offer.TimeUpdated;
            this.Message        = offer.Message;
            this.Items          = new TradeStatus(myAssets, theirAssets);
        }
Exemple #2
0
 public TradeOffer(OfferSession session, SteamID partnerSteamdId)
 {
     Items          = new TradeStatus();
     IsOurOffer     = true;
     OfferState     = TradeOfferState.TradeOfferStateUnknown;
     Session        = session;
     PartnerSteamId = partnerSteamdId;
 }
 public TradeOffer(OfferSession session, SteamID partnerSteamdId)
 {
     this.Items          = new TradeStatus();
     this.IsOurOffer     = true;
     this.OfferState     = TradeOfferState.TradeOfferStateUnknown;
     this.Session        = session;
     this.PartnerSteamId = partnerSteamdId;
 }
        public TradeOfferManager(string apiKey, CookieContainer cookies, string sessionid)
        {
            if (apiKey == null)
            {
                throw new ArgumentNullException(nameof(apiKey));
            }

            this.LastTimeCheckedOffers = DateTime.MinValue;
            this._webApi  = new TradeOfferWebApi(apiKey);
            this._session = new OfferSession(this._webApi, cookies, sessionid);
            this._unhandledTradeOfferUpdates = new Queue <Offer>();
        }