/// <summary>
        /// Sets the active offer.
        /// </summary>
        /// <param name="offer">The offer.</param>
        private void SetActiveOffer(OfferViewModel offer)
        {
            var currentActiveOffer = this.ActiveOffer;

            if (currentActiveOffer == null)
            {
                this.AddActiveOffer(offer);
                return;
            }

            if (currentActiveOffer == offer)
            {
                return;
            }

            currentActiveOffer.Active = false;

            var index = this._activeOffers.IndexOf(offer);

            if (index != -1)
            {
                this._activeOffers.RemoveAt(index);
            }

            this._activeOffers.Insert(0, offer);
            this.ActiveOffer.Active = true;

            this.SendToLifeBulb(offer.Event);
        }
Beispiel #2
0
        /// <summary>
        /// Removes the offer.
        /// </summary>
        /// <param name="offer">The offer.</param>
        private void RemoveOffer(OfferViewModel offer)
        {
            if (offer != null)
            {
                Execute.OnUIThread(() =>
                {
                    if (offer.Active)
                    {
                        this._removeActive?.Invoke();
                    }

                    this.TradeOffers.Remove(offer);
                    this._activeOffers.Remove(offer);
                    var activeOffer = this.ActiveOffer;
                    if (activeOffer != null)
                    {
                        activeOffer.Active = true;
                        this.SendToLifeBulb(activeOffer.Event);
                    }
                    else
                    {
                        this._removeActive?.Invoke();
                    }

                    offer.Dispose();
                });
            }
        }
Beispiel #3
0
        /// <summary>
        /// Executes the trade.
        /// </summary>
        /// <param name="offer">The offer.</param>
        /// <returns>The task.</returns>
        private async Task ExecuteTradeAccepted(OfferViewModel offer)
        {
            this.InsertEvent(offer.Event);
            if (!string.IsNullOrEmpty(this.SettingsService.ThankYouMessage))
            {
                await offer.ThankYou();
            }

            if (this.SettingsService.AutoKickEnabled)
            {
                await this._keyboardHelper.Kick(offer.PlayerName);
            }

            var itemClass = offer.Event.ItemClass;

            if (itemClass != ItemClass.Map && itemClass != ItemClass.Currency && itemClass != ItemClass.DivinationCard)
            {
                var alreadySold = this.CheckIfOfferIsAlreadySold(offer.Event);
                if (!alreadySold)
                {
                    this.AddToSoldOffer(offer);
                }
            }

            this.RemoveOffer(offer);
        }
        /// <summary>
        /// Adds the active offer.
        /// </summary>
        /// <param name="offer">The offer.</param>
        private void AddActiveOffer(OfferViewModel offer)
        {
            this._activeOffers.Add(offer);
            this.ActiveOffer.Active = true;


            this.SendToLifeBulb(this.ActiveOffer.Event);
        }
Beispiel #5
0
 /// <summary>
 /// Adds to sold offer.
 /// </summary>
 /// <param name="offer">The offer.</param>
 private void AddToSoldOffer(OfferViewModel offer)
 {
     this._soldOffers.Add(offer.Event);
     if (this._soldOffers.Count >= 5)
     {
         this._soldOffers.RemoveAt(0);
     }
 }
Beispiel #6
0
        /// <summary>
        /// Adds the active offer.
        /// </summary>
        /// <param name="offer">The offer.</param>
        private void AddActiveOffer(OfferViewModel offer)
        {
            if (!this._activeOffers.Contains(offer))
            {
                this._activeOffers.Add(offer);
            }

            this.ActiveOffer.Active = true;

            if (offer.Equals(this.ActiveOffer))
            {
                this.SendToLifeBulb(this.ActiveOffer.Event);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Removes the offer.
        /// </summary>
        /// <param name="offer">The offer.</param>
        private void RemoveOffer(OfferViewModel offer)
        {
            if (offer != null)
            {
                Execute.OnUIThread(() =>
                {
                    this.TradeOffers.Remove(offer);
                    this._activeOffers.Remove(offer);
                    this.ItemName = string.Empty;

                    var activeOffer = this.ActiveOffer;
                    if (this.ActiveOffer != null)
                    {
                        this.ItemName           = this.ActiveOffer.ItemName;
                        this.ActiveOffer.Active = true;
                    }
                });
            }
        }
Beispiel #8
0
 /// <summary>
 /// Adds the active offer.
 /// </summary>
 /// <param name="offer">The offer.</param>
 private void AddActiveOffer(OfferViewModel offer)
 {
     this._activeOffers.Add(offer);
     this.ItemName           = this.ActiveOffer.ItemName;
     this.ActiveOffer.Active = true;
 }