Jump to content

Min value from list AuctionItem


Pudge
 Share

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
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;
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...