|
|
|
|
@ -15,6 +15,7 @@ TSMAPI:RegisterForTracing(private, "TradeSkillMaster.AuctionControl_private")
|
|
|
|
|
LibStub("AceEvent-3.0"):Embed(private) |
|
|
|
|
private.matchList = {} |
|
|
|
|
private.currentPage = {} |
|
|
|
|
private.shoppingPurchasedCounts = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function GetNumInBags(baseItemString) |
|
|
|
|
@ -43,6 +44,57 @@ local function ValidateAuction(index, list)
|
|
|
|
|
return count == private.currentAuction.count and buyout == private.currentAuction.buyout and itemString == private.currentAuction.itemString, data |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function GetShoppingTotalQuantity(itemString) |
|
|
|
|
itemString = TSMAPI:GetBaseItemString(itemString, true) or itemString |
|
|
|
|
local player, alts = TSMAPI:ModuleAPI("ItemTracker", "playertotal", itemString) |
|
|
|
|
if not player then |
|
|
|
|
alts = nil |
|
|
|
|
end |
|
|
|
|
player = player or 0 |
|
|
|
|
alts = alts or 0 |
|
|
|
|
local guild = TSMAPI:ModuleAPI("ItemTracker", "guildtotal", itemString) or 0 |
|
|
|
|
local auctions = TSMAPI:ModuleAPI("ItemTracker", "auctionstotal", itemString) or 0 |
|
|
|
|
local bought = private.shoppingPurchasedCounts[itemString] or 0 |
|
|
|
|
return player + alts + guild + auctions + bought |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function GetOperationMaxPrice(opSettings, itemString) |
|
|
|
|
if not opSettings or opSettings.maxPrice == nil then return end |
|
|
|
|
if type(opSettings.maxPrice) == "number" then |
|
|
|
|
return opSettings.maxPrice |
|
|
|
|
elseif type(opSettings.maxPrice) == "string" then |
|
|
|
|
local func = TSMAPI:ParseCustomPrice(opSettings.maxPrice) |
|
|
|
|
return func and func(itemString) or nil |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function ShoppingBuyoutAllowed(itemString, count, perItemBuyout) |
|
|
|
|
local operations = TSMAPI:GetItemOperation(itemString, "Shopping") |
|
|
|
|
if not operations or #operations == 0 then return true end |
|
|
|
|
itemString = TSMAPI:GetBaseItemString(itemString, true) or itemString |
|
|
|
|
for _, opName in ipairs(operations) do |
|
|
|
|
TSMAPI:UpdateOperation("Shopping", opName) |
|
|
|
|
local opSettings = TSM.operations["Shopping"] and TSM.operations["Shopping"][opName] |
|
|
|
|
if opSettings then |
|
|
|
|
local maxRestock = tonumber(opSettings.maxRestock) or 0 |
|
|
|
|
local totalQty = GetShoppingTotalQuantity(itemString) |
|
|
|
|
if maxRestock > 0 and (totalQty + count) > maxRestock then |
|
|
|
|
-- over restock for this operation |
|
|
|
|
elseif opSettings.evenStacks and count % 5 ~= 0 then |
|
|
|
|
-- not an even stack for this operation |
|
|
|
|
elseif opSettings.showAboveMaxPrice then |
|
|
|
|
return true |
|
|
|
|
else |
|
|
|
|
local opMaxPrice = GetOperationMaxPrice(opSettings, itemString) |
|
|
|
|
if opMaxPrice and perItemBuyout and perItemBuyout > 0 and perItemBuyout <= opMaxPrice then |
|
|
|
|
return true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
return false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local diffFrame = CreateFrame("Frame") |
|
|
|
|
diffFrame:Hide() |
|
|
|
|
diffFrame.num = 0 |
|
|
|
|
@ -146,6 +198,15 @@ end
|
|
|
|
|
|
|
|
|
|
function private:DoBuyout() |
|
|
|
|
if private.isSearching or not private.currentAuction or not private.confirmationFrame:IsVisible() then return end |
|
|
|
|
local perItemBuyout = private.currentAuction.buyout and private.currentAuction.count and (private.currentAuction.buyout / private.currentAuction.count) |
|
|
|
|
if TSM.groupBuyoutCheck and (not perItemBuyout or not TSM.groupBuyoutCheck(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout)) then |
|
|
|
|
TSM:Print("Max restock quantity reached for this item.") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
if private.module == "Shopping" and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then |
|
|
|
|
TSM:Print("Max restock quantity reached for this item.") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
for i=#private.matchList, 1, -1 do |
|
|
|
|
local aucIndex = private.matchList[i] |
|
|
|
|
@ -275,6 +336,10 @@ function private:AUCTION_ITEM_LIST_UPDATE()
|
|
|
|
|
TSMAPI.AuctionScan:CacheRemove(prevAuction.itemString, private.currentCacheIndex) |
|
|
|
|
private.currentCacheIndex = nil |
|
|
|
|
end |
|
|
|
|
if private.module == "Shopping" and prevAuction.itemString and prevAuction.count then |
|
|
|
|
local baseItemString = TSMAPI:GetBaseItemString(prevAuction.itemString, true) |
|
|
|
|
private.shoppingPurchasedCounts[baseItemString] = (private.shoppingPurchasedCounts[baseItemString] or 0) + prevAuction.count |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
TSM:AuctionControlCallback("OnBuyout", prevAuction) |
|
|
|
|
TSMAPI:FireEvent("TSM:AUCTIONCONTROL:ITEMBOUGHT", prevAuction) |
|
|
|
|
@ -312,6 +377,9 @@ function TSMAPI.AuctionControl:ShowControlButtons(parent, rt, callback, module,
|
|
|
|
|
private.rt = rt |
|
|
|
|
private.callback = callback |
|
|
|
|
private.module = module |
|
|
|
|
if module == "Shopping" then |
|
|
|
|
wipe(private.shoppingPurchasedCounts) |
|
|
|
|
end |
|
|
|
|
private.postBidPercent = postBidPercent |
|
|
|
|
private.postUndercut = postUndercut |
|
|
|
|
return private.controlButtons |
|
|
|
|
@ -348,6 +416,17 @@ function private:ShowConfirmationWindow()
|
|
|
|
|
end |
|
|
|
|
private:SetCurrentAuction(private.rt:GetSelectedAuction()) |
|
|
|
|
if not private.currentAuction then return end |
|
|
|
|
if private.confirmationMode == "Buyout" then |
|
|
|
|
local perItemBuyout = private.currentAuction.buyout and private.currentAuction.count and (private.currentAuction.buyout / private.currentAuction.count) |
|
|
|
|
if TSM.groupBuyoutCheck and (not perItemBuyout or not TSM.groupBuyoutCheck(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout)) then |
|
|
|
|
TSM:Print("Max restock quantity reached for this item.") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
if private.module == "Shopping" and not ShoppingBuyoutAllowed(private.currentAuction.itemString, private.currentAuction.count, perItemBuyout) then |
|
|
|
|
TSM:Print("Max restock quantity reached for this item.") |
|
|
|
|
return |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
private:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") |
|
|
|
|
diffFrame.num = 0 |
|
|
|
|
|