protected override RunStatus Run(object context) { if (!IsDone) { using (new FrameLock()) { if ( Lua.GetReturnVal <int>( "if AuctionFrame and AuctionFrame:IsVisible() then return 1 else return 0 end ", 0) == 0) { MovetoAuctioneer(); } else { if (_toQueueNameList == null) { _toQueueNameList = BuildItemList(); _toBuyList = new List <BuyItemEntry>(); } if ((_toQueueNameList == null || _toQueueNameList.Count == 0) && _toBuyList.Count == 0) { IsDone = true; return(RunStatus.Failure); } if (_toQueueNameList != null && _toQueueNameList.Count > 0) { string name = GetLocalName(_toQueueNameList[0].Id); if (!string.IsNullOrEmpty(name)) { BuyItemEntry item = _toQueueNameList[0]; item.Name = name; _toBuyList.Add(item); _toQueueNameList.RemoveAt(0); } } if (_toBuyList.Count > 0) { if (BuyFromAH(_toBuyList[0])) { _toBuyList.RemoveAt(0); } } } } if (!IsDone) { return(RunStatus.Success); } } return(RunStatus.Failure); }
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); Professionbuddy.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("local A,totalA= GetNumAuctionItems('list') local amountBought={0} local want={1} local each={3} local useBid={4} local buyPrice=0 for index=1, A do local name, _, count,_,_,_,minBid,minInc, buyoutPrice,bidNum,isHighBidder,_,_ = GetAuctionItemInfo('list', index) if useBid == 1 and buyoutPrice > each*count and isHighBidder == nil then if bidNum == nil then buyPrice =minBid + minInc else buyPrice = bidNum + minInc end else buyPrice = buyoutPrice end if name == \"{2}\" and buyPrice > 0 and buyPrice <= each*count and amountBought < want then amountBought = amountBought + count PlaceAuctionBid('list', index,buyPrice) end if amountBought >= want then return -1 end end return amountBought", counter, bie.BuyAmount, bie.Name.ToFormatedUTF8(), MaxBuyout.TotalCopper, BidOnItem == true ? 1 : 0); //string lua = string.Format("local A,totalA= GetNumAuctionItems('list') local amountBought={0} local want={1} local each={3} local useBid={4} for index=1, A do local name, _, count,_,_,_,minBid,minIncreament, buyoutPrice,_,_,_,_ = GetAuctionItemInfo('list', index) if name == \"{2}\" and ((buyoutPrice > 0 and buyoutPrice <= each*count) or (useBid==1 and (minBid+minIncreament) <= each*count)) and amountBought < want then amountBought = amountBought + count if useBid==1 and buyoutPrice > each*count then PlaceAuctionBid('list', index, minBid+minIncreament) else PlaceAuctionBid('list', index, buyoutPrice) end end if amountBought >= want then return -1 end end return amountBought", // counter, bie.BuyAmount, bie.Name, MaxBuyout.TotalCopper, BidOnItem == true ? 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); }
//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); Professionbuddy.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); }
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); Professionbuddy.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; }
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); Professionbuddy.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("local A,totalA= GetNumAuctionItems('list') local amountBought={0} local want={1} local each={3} local useBid={4} local buyPrice=0 for index=1, A do local name, _, count,_,_,_,_,minBid,minInc, buyoutPrice,bidNum,isHighBidder,_,_ = GetAuctionItemInfo('list', index) if useBid == 1 and buyoutPrice > each*count and isHighBidder == nil then if bidNum == nil then buyPrice =minBid + minInc else buyPrice = bidNum + minInc end else buyPrice = buyoutPrice end if name == \"{2}\" and buyPrice > 0 and buyPrice <= each*count and amountBought < want then amountBought = amountBought + count PlaceAuctionBid('list', index,buyPrice) end if amountBought >= want then return -1 end end return amountBought", counter, bie.BuyAmount, bie.Name.ToFormatedUTF8(), MaxBuyout.TotalCopper, BidOnItem == true ? 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; }