private bool SellOnAh(AuctionEntry ae) { if (!_posted) { int subAmount = AmountType == AmountBasedType.Amount ? Amount - (int)ae.MyAuctions : Amount; int amount = AmountType == AmountBasedType.Everything ? (_leftOver == 0 ? int.MaxValue : _leftOver) : (_leftOver == 0 ? subAmount : _leftOver); string lua = string.Format(SellOnAHLuaFormat, ae.Id, amount, StackSize, ae.Bid, ae.Buyout, (int)RunTime); var ret = Lua.GetReturnVal <int>(lua, 0); if (ret != -1) // returns -1 if waiting for auction to finish posting.. { _leftOver = ret; } if (_leftOver == 0) { _posted = true; } } //wait for auctions to finish listing before moving on if (_posted) { bool ret = Lua.GetReturnVal <int>( "if AuctionProgressFrame:IsVisible() == nil then return 1 else return 0 end ", 0) == 1; if (ret) // we're done listing this item so reset to default values { _posted = false; _leftOver = 0; } return(ret); } return(false); }
protected override RunStatus Run(object context) { if (!IsDone) { try { if (Lua.GetReturnVal <int>("if AuctionFrame and AuctionFrame:IsVisible() == 1 then return 1 else return 0 end ", 0) == 0) { MoveToAh(); } else if (Lua.GetReturnVal <int>("if CanSendAuctionQuery('owner') == 1 then return 1 else return 0 end ", 0) == 1) { if (_toScanItemList == null) { _toScanItemList = BuildScanItemList(); _toCancelItemList = new List <AuctionEntry>(); } if (_toScanItemList.Count > 0) { AuctionEntry ae = _toScanItemList[0]; bool scanDone = ScanAh(ref ae); _toScanItemList[0] = ae; // update if (scanDone) { _toCancelItemList.Add(ae); _toScanItemList.RemoveAt(0); } if (_toScanItemList.Count == 0) { Professionbuddy.Debug("Finished scanning for items"); } } else { if (_toCancelItemList.Count == 0) { _toScanItemList = null; IsDone = true; return(RunStatus.Failure); } if (CancelAuction(_toCancelItemList[0])) { _toCancelItemList.RemoveAt(0); } } } return(RunStatus.Success); } catch (Exception ex) { Professionbuddy.Err(ex.ToString()); } } return(RunStatus.Failure); }
bool CancelAuction(AuctionEntry ae) { string lua = String.Format(CancelAuctionLuaFormat, ae.Id, MinBuyout.TotalCopper, ae.LowestBo); var numCanceled = Lua.GetReturnVal <int>(lua, 0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return(true); }
bool CancelAuction(AuctionEntry ae) { int numCanceled = Lua.GetReturnVal <int>(String.Format("local A =GetNumAuctionItems('owner') local cnt=0 for i=A,1,-1 do local name,_,cnt,_,_,_,_,_,_,buyout,_,_,_,sold,id=GetAuctionItemInfo('owner', i) if id == {0} and sold ~= 1 and {2} > {1} and (buyout/cnt) > {2} then CancelAuction(i) cnt=cnt+1 end end return cnt", ae.Id, MinBuyout.TotalCopper, ae.LowestBo), 0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return(true); }
bool ScanAh(ref AuctionEntry ae) { bool scanned = false; if (!queueTimer.IsRunning) { string lua = string.Format("QueryAuctionItems(\"{0}\" ,nil,nil,nil,nil,nil,{1}) return 1", ae.Name.ToFormatedUTF8(), page); Lua.GetReturnVal <int>(lua, 0); Professionbuddy.Debug("Searching AH for {0}", ae.Name); queueTimer.Start(); } else if (queueTimer.ElapsedMilliseconds <= 10000) { using (new FrameLock()) { if (Lua.GetReturnVal <int>("if CanSendAuctionQuery('list') == 1 then return 1 else return 0 end ", 0) == 1) { queueTimer.Stop(); queueTimer.Reset(); totalAuctions = Lua.GetReturnVal <int>("return GetNumAuctionItems('list')", 1); string lua = string.Format("local A,totalA= GetNumAuctionItems('list') local me = GetUnitName('player') local auctionInfo = {{{0},{1}}} for index=1, A do local name, _, count,_,_,_,minBid,_, buyoutPrice,_,_,owner,_ = GetAuctionItemInfo('list', index) if name == \"{2}\" and owner ~= me and buyoutPrice > 0 and buyoutPrice/count < auctionInfo[1] then auctionInfo[1] = floor(buyoutPrice/count) end if owner == me then auctionInfo[2] = auctionInfo[2] + 1 end end return unpack(auctionInfo) ", ae.LowestBo, ae.myAuctions, ae.Name.ToFormatedUTF8()); //Logging.Write("****Copy Below this line****"); //Logging.Write(lua); //Logging.Write("****End of copy/paste****"); List <string> retVals = Lua.GetReturnValues(lua); uint.TryParse(retVals[0], out ae.LowestBo); uint.TryParse(retVals[1], out ae.myAuctions); if (++page >= (int)Math.Ceiling((double)totalAuctions / 50)) { scanned = true; } } } } else { scanned = true; } // reset to default values in preparations for next scan if (scanned) { Professionbuddy.Debug("lowest buyout {0}", ae.LowestBo); queueTimer.Stop(); queueTimer.Reset(); totalAuctions = 0; page = 0; } return(scanned); }
private bool ScanAh(ref AuctionEntry ae) { bool scanned = false; if (!_queueTimer.IsRunning) { string lua = string.Format("QueryAuctionItems(\"{0}\" ,nil,nil,nil,nil,nil,{1}) return 1", ae.Name.ToFormatedUTF8(), _page); Lua.GetReturnVal <int>(lua, 0); Professionbuddy.Debug("Searching AH for {0}", ae.Name); _queueTimer.Start(); } else if (_queueTimer.ElapsedMilliseconds <= 10000) { using (new FrameLock()) { if ( Lua.GetReturnVal <int>("if CanSendAuctionQuery('list') == 1 then return 1 else return 0 end ", 0) == 1) { _queueTimer.Reset(); _totalAuctions = Lua.GetReturnVal <int>("return GetNumAuctionItems('list')", 1); string lua = string.Format(ScanAHFormatLua, ae.LowestBo, ae.MyAuctions, ae.Id, IgnoreStackSizeBelow, StackSize); List <string> retVals = Lua.GetReturnValues(lua); uint.TryParse(retVals[0], out ae.LowestBo); uint.TryParse(retVals[1], out ae.MyAuctions); if (++_page >= (int)Math.Ceiling((double)_totalAuctions / 50)) { scanned = true; } } } } else { scanned = true; } // reset to default values in preparations for next scan if (scanned) { Professionbuddy.Debug("lowest buyout {0}", ae.LowestBo); _queueTimer.Stop(); _queueTimer.Reset(); _totalAuctions = 0; _page = 0; } return(scanned); }
bool SellOnAh(AuctionEntry ae) { if (!_posted) { uint subAmount = AmountType == AmountBasedType.Amount ? Amount - ae.myAuctions : Amount; uint amount = AmountType == AmountBasedType.Everything ? (_leftOver == 0 ? int.MaxValue : _leftOver) : (_leftOver == 0 ? subAmount : _leftOver); string lua = string.Format( "local itemID = {0} " + "local amount = {1} " + "local bid = {3} " + "local bo = {4} " + "local runtime = {5} " + "local stack = {2} " + "local sold = 0 " + "local leftovers = 0 " + "local numItems = GetItemCount(itemID) " + "if numItems == 0 then return -1 end " + "if AuctionProgressFrame:IsVisible() == nil then " + "AuctionFrameTab3:Click() " + "local _,_,_,_,_,_,_,maxStack= GetItemInfo(itemID) " + "if maxStack < stack then stack = maxStack end " + "if amount * stack > numItems then " + "amount = floor(numItems/stack) " + "if amount <= 0 then " + "amount = 1 " + "stack = numItems " + "else " + "leftovers = numItems-(amount*stack) " + "end " + "end " + "for bag = 0,4 do " + "for slot=GetContainerNumSlots(bag),1,-1 do " + "local id = GetContainerItemID(bag,slot) " + "local _,c,l = GetContainerItemInfo(bag, slot) " + "if id == itemID and l == nil then " + "PickupContainerItem(bag, slot) " + "ClickAuctionSellItemButton() " + "StartAuction(bid*stack, bo*stack, runtime,stack,amount) " + "return leftovers " + "end " + "end " + "end " + "else " + "return -1 " + "end", ae.Id, amount, StackSize, ae.Bid, ae.Buyout, (int)RunTime); int ret = Lua.GetReturnVal <int>(lua, 0); if (ret != -1) // returns -1 if waiting for auction to finish posting.. { _leftOver = (uint)ret; } if (_leftOver == 0) { _posted = true; } } //wait for auctions to finish listing before moving on if (_posted) { bool ret = Lua.GetReturnVal <int>("if AuctionProgressFrame:IsVisible() == nil then return 1 else return 0 end ", 0) == 1; if (ret) // we're done listing this item so reset to default values { _posted = false; _leftOver = 0; } return(ret); } else { return(false); } }
protected override RunStatus Run(object context) { if (!IsDone) { if (Lua.GetReturnVal <int>("if AuctionFrame and AuctionFrame:IsVisible() then return 1 else return 0 end ", 0) == 0) { MoveToAh(); } else { if (ToScanItemList == null) { ToScanItemList = BuildScanItemList(); ToSellItemList = new List <AuctionEntry>(); } if (ToScanItemList.Count == 0 && ToSellItemList.Count == 0) { ToScanItemList = null; IsDone = true; return(RunStatus.Failure); } if (ToScanItemList.Count > 0) { AuctionEntry ae = ToScanItemList[0]; bool scanDone = ScanAh(ref ae); ToScanItemList[0] = ae; // update if (scanDone) { uint lowestBo = ae.LowestBo; if (lowestBo > MaxBuyout.TotalCopper) { ae.Buyout = MaxBuyout.TotalCopper; } else if (lowestBo < MinBuyout.TotalCopper) { ae.Buyout = MinBuyout.TotalCopper; } else { ae.Buyout = lowestBo - (uint)Math.Ceiling(((double)(lowestBo * UndercutPrecent) / 100d)); } ae.Bid = (uint)((double)(ae.Buyout * BidPrecent) / 100d); bool enoughItemsPosted = AmountType == AmountBasedType.Amount && ae.myAuctions >= Amount; bool tooLowBuyout = !PostIfBelowMinBuyout && lowestBo < MinBuyout.TotalCopper; Professionbuddy.Debug("PB: PostIfBelowMinBuyout:{0} ", PostIfBelowMinBuyout, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: lowestBo:{0} MinBuyout.TotalCopper: {1}", lowestBo, MinBuyout.TotalCopper); Professionbuddy.Debug("PB: tooLowBuyout:{0} enoughItemsPosted: {1}", enoughItemsPosted, enoughItemsPosted); if (!enoughItemsPosted && !tooLowBuyout) { ToSellItemList.Add(ae); } else { Professionbuddy.Log("Skipping {0} since {1}", ae.Name, tooLowBuyout ? string.Format("lowest buyout:{0} is below MinBuyout:{1}", AuctionEntry.GoldString(lowestBo), MinBuyout) : string.Format("{0} items from me are already posted. Max amount is {1}", ae.myAuctions, Amount)); } ToScanItemList.RemoveAt(0); } if (ToScanItemList.Count == 0) { Professionbuddy.Debug("Finished scanning for items"); } } if (ToSellItemList.Count > 0) { if (SellOnAh(ToSellItemList[0])) { Professionbuddy.Log("Selling {0}", ToSellItemList[0]); ToSellItemList.RemoveAt(0); } } } return(RunStatus.Running); } return(RunStatus.Failure); }
bool CancelAuction(AuctionEntry ae) { int numCanceled = Lua.GetReturnVal<int>(String.Format("local A =GetNumAuctionItems('owner') local cnt=0 for i=A,1,-1 do local name,_,cnt,_,_,_,_,_,_,buyout,_,_,_,sold,id=GetAuctionItemInfo('owner', i) if id == {0} and sold ~= 1 and {2} > {1} and (buyout/cnt) > {2} then CancelAuction(i) cnt=cnt+1 end end return cnt", ae.Id,MinBuyout.TotalCopper,ae.LowestBo),0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return true; }
bool ScanAh(ref AuctionEntry ae) { bool scanned = false; if (!queueTimer.IsRunning) { string lua = string.Format("QueryAuctionItems(\"{0}\" ,nil,nil,nil,nil,nil,{1}) return 1", ae.Name.ToFormatedUTF8(), page); Lua.GetReturnVal<int>(lua, 0); Professionbuddy.Debug("Searching AH for {0}", ae.Name); queueTimer.Start(); } else if (queueTimer.ElapsedMilliseconds <= 10000) { using (new FrameLock()) { if (Lua.GetReturnVal<int>("if CanSendAuctionQuery('list') == 1 then return 1 else return 0 end ", 0) == 1) { queueTimer.Reset(); totalAuctions = Lua.GetReturnVal<int>("return GetNumAuctionItems('list')", 1); string lua = string.Format("local A,totalA= GetNumAuctionItems('list') local me = GetUnitName('player') local auctionInfo = {{{0},{1}}} for index=1, A do local name, _, count,_,_,_,_,minBid,_, buyoutPrice,_,_,owner,_ = GetAuctionItemInfo('list', index) if name == \"{2}\" and owner ~= me and buyoutPrice > 0 and buyoutPrice/count < auctionInfo[1] then auctionInfo[1] = floor(buyoutPrice/count) end if owner == me then auctionInfo[2] = auctionInfo[2] + 1 end end return unpack(auctionInfo) ", ae.LowestBo, ae.myAuctions, ae.Name.ToFormatedUTF8()); List<string> retVals = Lua.GetReturnValues(lua); uint.TryParse(retVals[0], out ae.LowestBo); uint.TryParse(retVals[1], out ae.myAuctions); if (++page >= (int)Math.Ceiling((double)totalAuctions / 50)) scanned = true; } } } else { scanned = true; } // reset to default values in preparations for next scan if (scanned) { Professionbuddy.Debug("lowest buyout {0}", ae.LowestBo); queueTimer.Reset(); totalAuctions = 0; page = 0; } return scanned; }
private bool SellOnAh(AuctionEntry ae) { if (!_posted) { int subAmount = AmountType == AmountBasedType.Amount ? Amount - (int)ae.MyAuctions : Amount; int amount = AmountType == AmountBasedType.Everything ? (_leftOver == 0 ? int.MaxValue : _leftOver) : (_leftOver == 0 ? subAmount : _leftOver); string lua = string.Format(SellOnAhLuaFormat, ae.Id, amount, StackSize, ae.Bid, ae.Buyout, (int)RunTime); var ret = Lua.GetReturnVal<int>(lua, 0); if (ret != -1) // returns -1 if waiting for auction to finish posting.. _leftOver = ret; if (_leftOver == 0) _posted = true; } //wait for auctions to finish listing before moving on if (_posted) { bool ret = Lua.GetReturnVal<int>( "if AuctionProgressFrame:IsVisible() == nil then return 1 else return 0 end ", 0) == 1; if (ret) // we're done listing this item so reset to default values { _posted = false; _leftOver = 0; } return ret; } return false; }
private bool ScanAh(ref AuctionEntry ae) { bool scanned = false; if (!_queueTimer.IsRunning) { string lua = string.Format("QueryAuctionItems(\"{0}\" ,nil,nil,nil,nil,nil,{1}) return 1", ae.Name.ToFormatedUTF8(), _page); Lua.GetReturnVal<int>(lua, 0); Professionbuddy.Debug("Searching AH for {0}", ae.Name); _queueTimer.Start(); } else if (_queueTimer.ElapsedMilliseconds <= 10000) { using (StyxWoW.Memory.AcquireFrame()) { if ( Lua.GetReturnVal<int>("if CanSendAuctionQuery('list') == 1 then return 1 else return 0 end ", 0) == 1) { _queueTimer.Reset(); _totalAuctions = Lua.GetReturnVal<int>("return GetNumAuctionItems('list')", 1); string lua = string.Format(ScanAhFormatLua, ae.LowestBo, ae.MyAuctions, ae.Id, IgnoreStackSizeBelow, StackSize); List<string> retVals = Lua.GetReturnValues(lua); uint.TryParse(retVals[0], out ae.LowestBo); uint.TryParse(retVals[1], out ae.MyAuctions); if (++_page >= (int)Math.Ceiling((double)_totalAuctions / 50)) scanned = true; } } } else { scanned = true; } // reset to default values in preparations for next scan if (scanned) { _queueTimer.Stop(); _queueTimer.Reset(); _totalAuctions = 0; _page = 0; } return scanned; }
bool SellOnAh(AuctionEntry ae) { if (!_posted) { uint subAmount = AmountType == AmountBasedType.Amount ? Amount - ae.myAuctions : Amount; uint amount = AmountType == AmountBasedType.Everything ? (_leftOver == 0 ? int.MaxValue : _leftOver) : (_leftOver == 0 ? subAmount : _leftOver); string lua = string.Format( "local itemID = {0} " + "local amount = {1} " + "local bid = {3} " + "local bo = {4} " + "local runtime = {5} " + "local stack = {2} " + "local sold = 0 " + "local leftovers = 0 " + "local numItems = GetItemCount(itemID) " + "if numItems == 0 then return -1 end " + "if AuctionProgressFrame:IsVisible() == nil then " + "AuctionFrameTab3:Click() " + "local _,_,_,_,_,_,_,maxStack= GetItemInfo(itemID) " + "if maxStack < stack then stack = maxStack end " + "if amount * stack > numItems then " + "amount = floor(numItems/stack) " + "if amount <= 0 then " + "amount = 1 " + "stack = numItems " + "else " + "leftovers = numItems-(amount*stack) " + "end " + "end " + "for bag = 0,4 do " + "for slot=GetContainerNumSlots(bag),1,-1 do " + "local id = GetContainerItemID(bag,slot) " + "local _,c,l = GetContainerItemInfo(bag, slot) " + "if id == itemID and l == nil then " + "PickupContainerItem(bag, slot) " + "ClickAuctionSellItemButton() " + "StartAuction(bid*stack, bo*stack, runtime,stack,amount) " + "return leftovers " + "end " + "end " + "end " + "else " + "return -1 " + "end", ae.Id, amount, StackSize, ae.Bid, ae.Buyout, (int)RunTime); int ret = Lua.GetReturnVal<int>(lua, 0); if (ret != -1) // returns -1 if waiting for auction to finish posting.. _leftOver = (uint)ret; if (_leftOver == 0) _posted = true; } //wait for auctions to finish listing before moving on if (_posted) { bool ret = Lua.GetReturnVal<int>("if AuctionProgressFrame:IsVisible() == nil then return 1 else return 0 end ", 0) == 1; if (ret) // we're done listing this item so reset to default values { _posted = false; _leftOver = 0; } return ret; } else return false; }
bool CancelAuction(AuctionEntry ae) { string lua = String.Format(CancelAuctionLuaFormat,ae.Id, MinBuyout.TotalCopper, ae.LowestBo); var numCanceled = Lua.GetReturnVal<int>(lua, 0); if (numCanceled > 0) { Professionbuddy.Log("Canceled {0} x{1}", ae.Name, numCanceled); } return true; }