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;
        }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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;
 }