Esempio n. 1
0
 private async Task RelistItem(IMarketplaceItem marketplaceItem, NetworkAuctionInfo.ItemModel item)
 {
     var relistPrice = General.AmendBidBasedOnSelectedSellBin(marketplaceItem.SearchPrice);
     await FifaTasks.SellItemUsingItemDataIdAndBuyNowPriceAsync(item.ItemData.Id, relistPrice);
 }
Esempio n. 2
0
        private async Task HandleResults(IMarketplaceItem marketplaceItem, IEnumerable <NetworkAuctionInfo.ItemModel> searchResults)
        {
            var filterIndex = ViewModel.MarketplaceItems.IndexOf(marketplaceItem);

            if (searchResults == null)
            {
                return;
            }

            if (marketplaceItem.SearchPrice == 0 && searchResults.Count() == 0)
            {
                General.AddToLog($"No results found for { marketplaceItem.FriendlyName}");
                return;
            }

            if (marketplaceItem.SearchPrice == 0)
            {
                ViewModel.MarketplaceItems.ElementAt(filterIndex).SearchPrice = CalculateSearchPriceUsingTradePileData(searchResults);
                General.AddToLog($"Searching for {marketplaceItem.FriendlyName} at {marketplaceItem.SearchPrice}");
                return;
            }

            if (searchResults.Count() == 0)
            {
                if (!IsSearchPriceEqualToMaxPrice(marketplaceItem.SearchPrice, marketplaceItem.MaxPrice))
                {
                    //Raise search price
                    var nextSearchPrice = General.CalculateNextBid(marketplaceItem.SearchPrice);
                    ViewModel.MarketplaceItems.ElementAt(filterIndex).SearchPrice = nextSearchPrice;
                    General.AddToLog($"Increasing price for {marketplaceItem.FriendlyName} to {marketplaceItem.SearchPrice}");
                }
                return;
            }

            if (searchResults.Count() > 5)
            {
                if (!IsSearchPriceEqualToMinPrice(marketplaceItem.SearchPrice, marketplaceItem.MinPrice))
                {
                    //Reduce search price
                    var nextSearchPrice = General.CalculatePreviousBid(marketplaceItem.SearchPrice);
                    ViewModel.MarketplaceItems.ElementAt(filterIndex).SearchPrice = nextSearchPrice;
                    General.AddToLog($"Decreasing price for {marketplaceItem.FriendlyName} to {marketplaceItem.SearchPrice}");
                }
                return;
            }

            var broughtItems = new List <long>();
            var maxPrice     = General.CalculateMaxBuyNowPriceUsingSearchPrice(marketplaceItem.SearchPrice) - ViewModel.SelectedMinProfitMargin;

            foreach (var item in searchResults.Where(p => p.BuyNowPrice < maxPrice))
            {
                if (await FifaTasks.BuyItemUsingTradeIdAndBuyNowPriceAsync(item.TradeId, item.BuyNowPrice))
                {
                    General.AddToLog($"{marketplaceItem.FriendlyName} brought for {item.BuyNowPrice}");
                    var relistPrice = General.AmendBidBasedOnSelectedSellBin(marketplaceItem.SearchPrice);
                    ViewModel.Profit += General.CalculateProfitUsingSellPriceAndBroughtPrice(relistPrice, item.BuyNowPrice);
                    broughtItems.Add(item.ItemData.Id);
                }
            }

            // Moves brought items from unassigned to tradepile ready for re-sale
            foreach (var item in broughtItems)
            {
                await FifaTasks.MoveUnassignedItemToTradepileUsingPlayerInternalId(item);
            }
        }