//indexs are {0}=ItemsCounter,NumOfItemToBuy, {1}=ItemID, {2}=maxBuyout, {3}=BidOnItem ? 1 : 0 private bool BuyFromAH(BuyItemEntry bie) { bool done = false; if (!_queueTimer.IsRunning) { string lua = string.Format("QueryAuctionItems(\"{0}\" ,nil,nil,nil,nil,nil,{1}) return 1", bie.Name.ToFormatedUTF8(), _page); Lua.GetReturnVal <int>(lua, 0); ProfessionbuddyBot.Debug("Searching AH for {0}", bie.Name); _queueTimer.Start(); } else if (_queueTimer.ElapsedMilliseconds <= 10000) { if (Lua.GetReturnVal <int>("if CanSendAuctionQuery('list') == 1 then return 1 else return 0 end ", 0) == 1) { _totalAuctions = Lua.GetReturnVal <int>("return GetNumAuctionItems('list')", 1); _queueTimer.Stop(); _queueTimer.Reset(); if (_totalAuctions > 0) { string lua = string.Format(BuyFromAHLuaFormat, _counter, bie.BuyAmount, bie.Id, MaxBuyout.TotalCopper, BidOnItem ? 1 : 0); _counter = Lua.GetReturnVal <int>(lua, 0); if (_counter == -1 || ++_page >= (int)Math.Ceiling((double)_totalAuctions / 50)) { done = true; } } else { done = true; } } } else { done = true; } if (done) { _queueTimer = new Stopwatch(); _totalAuctions = 0; _counter = 0; _page = 0; } return(done); }
protected async override Task Run() { using (StyxWoW.Memory.AcquireFrame()) { if ( Lua.GetReturnVal <int>( "if AuctionFrame and AuctionFrame:IsVisible() then return 1 else return 0 end ", 0) == 0) { MovetoAuctioneer(); } else { if (_toQueryNameList == null) { _toQueryNameList = BuildItemList(); _toBuyList = new List <BuyItemEntry>(); } if ((_toQueryNameList == null || _toQueryNameList.Count == 0) && _toBuyList.Count == 0) { IsDone = true; return; } if (_toQueryNameList != null && _toQueryNameList.Count > 0) { string name = GetLocalName(_toQueryNameList[0].Id); if (!string.IsNullOrEmpty(name)) { BuyItemEntry item = _toQueryNameList[0]; item.Name = name; _toBuyList.Add(item); _toQueryNameList.RemoveAt(0); } } if (_toBuyList.Count > 0) { if (BuyFromAH(_toBuyList[0])) { _toBuyList.RemoveAt(0); } } } } }