Jump to content

Recommended Posts

 

Hi, I need help, I tried to get the minimum value from Auction Page

List<AuctionHelpers.AuctionItem> auklist = new List<AuctionHelpers.AuctionItem>();
                      foreach (var item in AuctionHelpers.GetBrowsePageItems())
                    {
                        if(item.IsValid())
                        auklist.Add(item);                       
                    }
  var ChepestItemauklist = auklist.Where(x => x.Name == "Frostweave Bag").OrderBy(x => x.BuyoutPricePerUnit).Min();//error code

but I get an error if I try to use such code

image.png.fbdfd22edd10eee1aa74cffd311889f0.png

 

I need to know the minimum price on the page to use it for comparison.

 

Does anyone know which method to use to get the minimum buyout price from the AuctionItem array?

 

I know what you can extract into a separate BuyoutPrice list<int> and then everything seems to work as it should, but I would like to know if you can get the minimum value from multidimensional arrays of the wrobot?

5 Jun 2020 05H15.log.html

Link to comment
https://wrobot.eu/forums/topic/12227-min-value-from-list-auctionitem/
Share on other sites

Hi. Try this. Returns a dictionary where key is itemname and value is lowest price.

    private static Dictionary<string, int> GetLowestItemPrice()
    {
        Dictionary<string, int> CheapestItems = new Dictionary<string, int>();        
        List<AuctionHelpers.AuctionItem> ItemsList = new List<AuctionHelpers.AuctionItem>();
        List<string> ItemsToCheck = /*your list of items*/
        int LowestPrice = 0;

        if (AuctionHelpers.AuctionHouseIsShown()) 
            foreach (string item in ItemsToCheck)
            {                
                AuctionHelpers.BrowseNameSetText(item);
                Thread.Sleep(2000);
                AuctionHelpers.IsUsableCheckButtonSetChecked(false);
                if (AuctionHelpers.BrowseSearchButtonIsEnabled())
                {                
                    AuctionHelpers.BrowseSearchButtonClick();
                    Thread.Sleep(2000);
                    while (AuctionHelpers.BrowseNextPageButtonIsEnabled())
                    {
                        if (AuctionHelpers.GetBrowsePageItems().Any())
                        {
                            ItemsList.AddRange(AuctionHelpers.GetBrowsePageItems());                            
                            AuctionHelpers.BrowseNextPageButtonClick();
                            Thread.Sleep(1000);
                        }
                    }
                    if (AuctionHelpers.GetBrowsePageItems().Any())
                        ItemsList.AddRange(AuctionHelpers.GetBrowsePageItems());
                    ItemsList.RemoveAll(i => (i.Name != item) || (i.BuyoutPricePerUnit == 0));
                    LowestPrice = ItemsList.Min(price => price.BuyoutPricePerUnit);
                    CheapestItems.Add(item, LowestPrice);
                }                               
            }       
        
        foreach (KeyValuePair<string, int> kvp in CheapestItems)
        {            
            Logging.Write("Itemname = " + kvp.Key + "Itemprice " + kvp.Value);
        }
        AuctionHelpers.CloseAuctionHouse();
        return CheapestItems;
    }

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...