📄 aucfilter.lua
字号:
--[[ Auctioneer Addon for World of Warcraft(tm). Version: 3.5.0.0917 (Platypus) Revision: $Id: AucFilter.lua 856 2006-05-11 00:23:22Z luke1410 $ Auctioneer filtering functions. Functions to filter auctions based upon various parameters. License: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program(see GPL.txt); if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.]]--Local function prototypeslocal brokerFilter, bidBrokerFilter, auctionOwnerFilter, competingFilter, percentLessFilter, plainFilter, querySnapshot, doBroker, doBidBroker, doCompeting, doPercentLessfunction brokerFilter (minProfit, signature) --function brokerFilter(minProfit, signature) local filterAuction = true; local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature); local itemKey = id..":"..rprop..":"..enchant; if (buyout and buyout > 0 and buyout <= Auctioneer.Core.Constants.MaxBuyoutPrice and Auctioneer.Statistic.GetUsableMedian(itemKey)) then local auctKey = Auctioneer.Util.GetAuctionKey(); local itemCat = Auctioneer.Util.GetCatForKey(itemKey); local snap = Auctioneer.Core.GetSnapshot(auctKey, itemCat, signature); if (snap) then local timeLeft = snap.timeLeft; local elapsedTime = time() - snap.lastSeenTime; local secondsLeft = Auctioneer.Core.Constants.TimeLeft.Seconds[timeLeft] - elapsedTime; if (secondsLeft > 0) then local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, auctKey); local profit = (hsp * count) - buyout; local profitPricePercent = math.floor((profit / buyout) * 100); if (profit >= minProfit and profitPricePercent >= Auctioneer.Core.Constants.MinProfitPricePercent and seenCount >= Auctioneer.Core.Constants.MinBuyoutSeenCount and not Auctioneer.Statistic.IsBadResaleChoice(signature)) then filterAuction = false; end end end end return filterAuction;end-- filters out all auctions except those that have no more than maximumTime remaining and meet profit requirementsfunction bidBrokerFilter(minProfit, signature, maximumTime, category, minQuality,itemName) local filterAuction = true; local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature); local itemKey = id..":"..rprop..":"..enchant; if (not maximumTime) then maximumTime = 100000 end if (not category) then category = 0 end if (not minQuality) then minQuality = 0 end if (itemName) then local iName local oName = string.lower(name) local iCount = table.getn(itemName) local match = false for iPos=1, iCount do iName = itemName[iPos] if (iName and iName ~= "") then local i,j = string.find(oName, string.lower(iName)) if (i) then match = true end end end if (not match) then return true end end if Auctioneer.Statistic.GetUsableMedian(itemKey) then -- only add if we have seen it enough times to have a usable median local auctKey = Auctioneer.Util.GetAuctionKey(); local currentBid = Auctioneer.Statistic.GetCurrentBid(signature); local sbuy = Auctioneer.Core.GetSnapshotInfo(auctKey, itemKey); local buyoutValues = {}; if (sbuy) then buyoutValues = sbuy.buyoutPrices end local lowest, second = Auctioneer.Statistic.GetLowest(buyoutValues); local itemCat = Auctioneer.Util.GetCatForKey(itemKey); if (category == 0 or itemCat == category) then local snap = Auctioneer.Core.GetSnapshot(auctKey, itemCat, signature); if (snap) then if (tonumber(snap.quality) >= tonumber(minQuality)) then local timeLeft = tonumber(snap.timeLeft); local elapsedTime = time() - tonumber(snap.lastSeenTime); local secondsLeft = Auctioneer.Core.Constants.TimeLeft.Seconds[timeLeft] - elapsedTime; if (secondsLeft <= maximumTime and secondsLeft > 0) then -- hsp is the HSP with the lowest priced item still in the auction, nshp is the next highest price. local hsp, seenCount, x, x, nhsp = Auctioneer.Statistic.GetHSP(itemKey, auctKey, buyoutValues); local profit = (hsp * count) - currentBid; local profitPricePercent = math.floor((profit / currentBid) * 100); if ((minProfit == 0 or profit >= minProfit) and seenCount >= Auctioneer.Core.Constants.MinBuyoutSeenCount and not Auctioneer.Statistic.IsBadResaleChoice(signature)) then filterAuction = false; end end end end end end return filterAuction;endfunction auctionOwnerFilter(owner, signature) local auctKey = Auctioneer.Util.GetAuctionKey(); local itemCat = Auctioneer.Util.GetCatForSig(signature); local snap = Auctioneer.Core.GetSnapshot(auctKey, itemCat, signature); if (snap and snap.owner == owner) then return false; end return true;endfunction competingFilter(minLess, signature, myAuctions) local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature); if (count > 1) then buyout = buyout/count; end local itemKey = id..":"..rprop..":"..enchant; local auctKey = Auctioneer.Util.GetAuctionKey(); local itemCat = Auctioneer.Util.GetCatForSig(signature); local snap = Auctioneer.Core.GetSnapshot(auctKey, itemCat, signature); if (snap and snap.owner ~= UnitName("player")) and (myAuctions[itemKey]) and (buyout > 0) and (buyout+minLess < myAuctions[itemKey]) then return false; end return true;end-- filters out all auctions that are not a given percentless than the median for that item.function percentLessFilter(percentLess, signature, category, minQuality, itemName) local filterAuction = true; local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature); local itemKey = id .. ":" .. rprop..":"..enchant; local auctKey = Auctioneer.Util.GetAuctionKey(); if (not category) then category = 0 end if (not minQuality) then minQuality = 0 end if (itemName) then local iName local oName = string.lower(name) local iCount = table.getn(itemName) local match = false for iPos=1, iCount do iName = itemName[iPos] if (iName and iName ~= "") then local i,j = string.find(oName, string.lower(iName)) if (i) then match = true end end end if (not match) then return true end end local hsp, seenCount = Auctioneer.Statistic.GetHSP(itemKey, auctKey) if hsp > 0 and seenCount >= Auctioneer.Core.Constants.MinBuyoutSeenCount then local profit = (hsp * count) - buyout; --see if this auction should not be filtered if (buyout > 0 and Auctioneer.Statistic.PercentLessThan(hsp, buyout / count) >= tonumber(percentLess) and profit >= Auctioneer.Core.Constants.MinProfitMargin) then local itemCat = Auctioneer.Util.GetCatForKey(itemKey); if (category == 0 or itemCat == category) then local snap = Auctioneer.Core.GetSnapshot(auctKey, itemCat, signature); if (snap) then if (tonumber(snap.quality) >= tonumber(minQuality)) then local timeLeft = tonumber(snap.timeLeft); local elapsedTime = time() - tonumber(snap.lastSeenTime); local secondsLeft = Auctioneer.Core.Constants.TimeLeft.Seconds[timeLeft] - elapsedTime; if (secondsLeft > 0) then filterAuction = false; end end end end end end return filterAuction;end-- filters out all auctions that are not below a certain price.function plainFilter(maxPrice, signature, category, minQuality, itemName) local filterAuction = true; local id,rprop,enchant, name, count,min,buyout,uniq = Auctioneer.Core.GetItemSignature(signature); local itemKey = id .. ":" .. rprop..":"..enchant; local auctKey = Auctioneer.Util.GetAuctionKey(); if (not category) then category = 0 end if (not minQuality) then minQuality = 0 end if (not maxPrice or maxPrice == 0) then maxPrice = 100000000 end if (itemName) then local iName local oName = string.lower(name) local iCount = table.getn(itemName) local match = false for iPos=1, iCount do iName = itemName[iPos] if (iName and iName ~= "") then local i,j = string.find(oName, string.lower(iName)) if (i) then match = true end end end if (not match) then return true end end if (count and count > 1) then maxPrice = maxPrice * count end -- check to see if we need to retrieve the current bid before actually getting it local currentBid = min if (min <= maxPrice and (not buyout or buyout == 0 or buyout > maxPrice)) then local bid = Auctioneer.Statistic.GetCurrentBid(signature); if (bid) then currentBid = bid end end if (currentBid <= maxPrice or (buyout and buyout > 0 and buyout <= maxPrice)) then local itemCat = Auctioneer.Util.GetCatForKey(itemKey); if (category == 0 or itemCat == category) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -