Browse Source

allow multiple shopping and crafting ops

dev
Jørgen Lien Sellæg 4 months ago
parent
commit
5a102f600f
  1. 2
      TradeSkillMaster/TradeSkillMaster.toc
  2. 4
      TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc
  3. 24
      TradeSkillMaster_Crafting/Modules/Queue.lua
  4. 2
      TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua
  5. 13
      TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua
  6. 65
      TradeSkillMaster_Shopping/sidebar/Groups.lua
  7. 10
      TradeSkillMaster_Shopping/sidebar/Other.lua

2
TradeSkillMaster/TradeSkillMaster.toc

@ -2,7 +2,7 @@
## Title: |cff00fe00TradeSkillMaster: Revived|r ## Title: |cff00fe00TradeSkillMaster: Revived|r
## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed. ## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed.
## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors... ## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors...
## Version: 2.3.30 ## Version: 2.3.33
## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB ## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB
## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE ## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE
## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0 ## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0

4
TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc

@ -2,10 +2,10 @@
## Title: |cff00ff00TradeSkillMaster_AuctionDB|r ## Title: |cff00ff00TradeSkillMaster_AuctionDB|r
## Notes: Stores auction house data and calculates market prices. ## Notes: Stores auction house data and calculates market prices.
## Author: Sapu94, Bart39 ## Author: Sapu94, Bart39
## Version: 2.3.30 ## Version: 2.3.33
## SavedVariables: AscensionTSM_AuctionDB ## SavedVariables: AscensionTSM_AuctionDB
## Dependency: TradeSkillMaster ## Dependency: TradeSkillMaster
## X-Curse-Packaged-Version: 2.3.30 ## X-Curse-Packaged-Version: 2.3.33
## X-Curse-Project-Name: TradeSkillMaster_AuctionDB ## X-Curse-Project-Name: TradeSkillMaster_AuctionDB
## X-Curse-Project-ID: tradeskillmaster_auctiondb ## X-Curse-Project-ID: tradeskillmaster_auctiondb
## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline ## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline

24
TradeSkillMaster_Crafting/Modules/Queue.lua

@ -33,6 +33,9 @@ end
function Queue:CreateRestockQueue(groupInfo) function Queue:CreateRestockQueue(groupInfo)
TSM:UpdateCraftReverseLookup() TSM:UpdateCraftReverseLookup()
local numItems = 0 local numItems = 0
local bestQueued = {}
local bestSpellID = {}
local seenItems = {}
for _, data in pairs(groupInfo) do for _, data in pairs(groupInfo) do
for _, opName in ipairs(data.operations) do for _, opName in ipairs(data.operations) do
@ -42,6 +45,7 @@ function Queue:CreateRestockQueue(groupInfo)
-- it's a valid operation -- it's a valid operation
for itemString in pairs(data.items) do for itemString in pairs(data.items) do
itemString = TSMAPI:GetItemString(itemString) itemString = TSMAPI:GetItemString(itemString)
seenItems[itemString] = true
local spellID = TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1] local spellID = TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1]
if spellID and TSM.db.realm.crafts[spellID] then if spellID and TSM.db.realm.crafts[spellID] then
local maxQueueCount = max(opSettings.maxRestock - TSM.Inventory:GetTotalQuantity(itemString), 0) local maxQueueCount = max(opSettings.maxRestock - TSM.Inventory:GetTotalQuantity(itemString), 0)
@ -61,13 +65,25 @@ function Queue:CreateRestockQueue(groupInfo)
end end
local craft = TSM.db.realm.crafts[spellID] local craft = TSM.db.realm.crafts[spellID]
craft.queued = floor(numToQueue / craft.numResult) local queued = floor(numToQueue / craft.numResult)
craft.queued = craft.queued >= opSettings.minRestock and craft.queued or 0 queued = queued >= opSettings.minRestock and queued or 0
if craft.queued > 0 then if queued > 0 and queued > (bestQueued[itemString] or 0) then
numItems = numItems + 1 bestQueued[itemString] = queued
bestSpellID[itemString] = spellID
end
end
end
end end
end end
end end
for itemString in pairs(seenItems) do
local queued = bestQueued[itemString] or 0
local spellID = bestSpellID[itemString] or (TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1])
if spellID and TSM.db.realm.crafts[spellID] then
TSM.db.realm.crafts[spellID].queued = queued
if queued > 0 then
numItems = numItems + 1
end end
end end
end end

2
TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua

@ -105,7 +105,7 @@ end
-- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule(). -- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule().
function TSM:RegisterModule() function TSM:RegisterModule()
TSM.icons = { { side = "module", desc = "Crafting", slashCommand = "crafting", callback = "Options:LoadCrafting", icon = "Interface\\Icons\\INV_Misc_Gear_08" } } TSM.icons = { { side = "module", desc = "Crafting", slashCommand = "crafting", callback = "Options:LoadCrafting", icon = "Interface\\Icons\\INV_Misc_Gear_08" } }
TSM.operations = { maxOperations = 1, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } TSM.operations = { maxOperations = 5, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" }
TSM.priceSources = { TSM.priceSources = {
{ key = "Crafting", label = L["Crafting Cost"], callback = "GetCraftingCost" }, { key = "Crafting", label = L["Crafting Cost"], callback = "GetCraftingCost" },
{ key = "matPrice", label = L["Crafting Material Cost"], callback = "GetCraftingMatCost" }, { key = "matPrice", label = L["Crafting Material Cost"], callback = "GetCraftingMatCost" },

13
TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua

@ -53,7 +53,7 @@ end
-- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule(). -- registers this module with TSM by first setting all fields and then calling TSMAPI:NewModule().
function TSM:RegisterModule() function TSM:RegisterModule()
TSM.operations = { maxOperations = 1, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" } TSM.operations = { maxOperations = 5, callbackOptions = "Options:Load", callbackInfo = "GetOperationInfo" }
TSM.auctionTab = { callbackShow = "Search:Show", callbackHide = "Search:Hide" } TSM.auctionTab = { callbackShow = "Search:Show", callbackHide = "Search:Hide" }
TSM.tooltipOptions = { callback = "Options:LoadTooltipOptions" } TSM.tooltipOptions = { callback = "Options:LoadTooltipOptions" }
TSM.moduleAPIs = { TSM.moduleAPIs = {
@ -136,11 +136,17 @@ function TSM:GetTooltip(itemString)
itemString = TSMAPI:GetBaseItemString(itemString, true) itemString = TSMAPI:GetBaseItemString(itemString, true)
local operations = TSMAPI:GetItemOperation(itemString, "Shopping") local operations = TSMAPI:GetItemOperation(itemString, "Shopping")
if not operations then return end if not operations then return end
local operationName = operations[1] local maxPrice
for _, operationName in ipairs(operations) do
TSMAPI:UpdateOperation("Shopping", operationName) TSMAPI:UpdateOperation("Shopping", operationName)
local operation = TSM.operations[operationName] local operation = TSM.operations[operationName]
if operation then if operation then
local maxPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) local price = TSM:GetMaxPrice(operation.maxPrice, itemString)
if price then
maxPrice = maxPrice and max(maxPrice, price) or price
end
end
end
if maxPrice then if maxPrice then
local priceText local priceText
if moneyCoinsTooltip then if moneyCoinsTooltip then
@ -150,7 +156,6 @@ function TSM:GetTooltip(itemString)
end end
tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) }) tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) })
end end
end
if #text > 0 then if #text > 0 then
tinsert(text, 1, "|cffffff00" .. "TSM Shopping:") tinsert(text, 1, "|cffffff00" .. "TSM Shopping:")
return text return text

65
TradeSkillMaster_Shopping/sidebar/Groups.lua

@ -3,6 +3,19 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Shopping") -- loa
local private = {itemOperations={}} local private = {itemOperations={}}
local function GetActiveOperations(itemString, operations)
if not operations or #operations == 0 then return end
local active = {}
for _, opName in ipairs(operations) do
TSMAPI:UpdateOperation("Shopping", opName)
local opSettings = TSM.operations[opName]
if opSettings then
tinsert(active, opSettings)
end
end
return active
end
function private.Create(parent) function private.Create(parent)
local frame = CreateFrame("Frame", nil, parent) local frame = CreateFrame("Frame", nil, parent)
frame:SetAllPoints() frame:SetAllPoints()
@ -39,33 +52,57 @@ function private.ScanCallback(event, ...)
local filter = ... local filter = ...
local maxPrice local maxPrice
for _, itemString in ipairs(filter.items) do for _, itemString in ipairs(filter.items) do
local operation = private.itemOperations[itemString] local operations = GetActiveOperations(itemString, private.itemOperations[itemString])
local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString) if not operations or #operations == 0 then return end
if not operationPrice then return end local itemMaxPrice
for _, operation in ipairs(operations) do
if operation.showAboveMaxPrice then if operation.showAboveMaxPrice then
itemMaxPrice = nil
break
end
local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString)
if operationPrice then
itemMaxPrice = itemMaxPrice and max(itemMaxPrice, operationPrice) or operationPrice
end
end
if itemMaxPrice == nil then
maxPrice = nil maxPrice = nil
break break
end end
maxPrice = maxPrice and max(maxPrice, operationPrice) or operationPrice if not itemMaxPrice then return end
maxPrice = maxPrice and max(maxPrice, itemMaxPrice) or itemMaxPrice
end end
return maxPrice return maxPrice
elseif event == "process" then elseif event == "process" then
local itemString, auctionItem = ... local itemString, auctionItem = ...
-- filter out auctions according to operation settings -- filter out auctions according to operation settings
itemString = TSMAPI:GetBaseItemString(itemString, true) itemString = TSMAPI:GetBaseItemString(itemString, true)
local operation = private.itemOperations[itemString] local operations = GetActiveOperations(itemString, private.itemOperations[itemString])
if not operation then return end if not operations or #operations == 0 then return end
local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString)
if not operationPrice then return end
auctionItem:FilterRecords(function(record) auctionItem:FilterRecords(function(record)
local buyout = record:GetItemBuyout() or 0
for _, operation in ipairs(operations) do
if operation.evenStacks and record.count % 5 ~= 0 then if operation.evenStacks and record.count % 5 ~= 0 then
return true -- not an even stack for this operation
elseif operation.showAboveMaxPrice then
return false
else
local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString)
if operationPrice and buyout <= operationPrice then
return false
end end
if not operation.showAboveMaxPrice then
return (record:GetItemBuyout() or 0) > operationPrice
end end
end
return true
end) end)
auctionItem:SetMarketValue(operationPrice) local marketValue
for _, operation in ipairs(operations) do
local operationPrice = TSM:GetMaxPrice(operation.maxPrice, itemString)
if operationPrice then
marketValue = marketValue and max(marketValue, operationPrice) or operationPrice
end
end
auctionItem:SetMarketValue(marketValue)
return auctionItem return auctionItem
elseif event == "done" then elseif event == "done" then
TSM.Search:SetSearchBarDisabled(false) TSM.Search:SetSearchBarDisabled(false)
@ -87,11 +124,13 @@ function private.StartScan()
else else
-- it's a valid operation -- it's a valid operation
for itemString in pairs(data.items) do for itemString in pairs(data.items) do
local baseItemString = TSMAPI:GetBaseItemString(itemString, true) or itemString
local _, err = TSM:GetMaxPrice(opSettings.maxPrice, itemString) local _, err = TSM:GetMaxPrice(opSettings.maxPrice, itemString)
if err then if err then
TSM:Printf(L["Invalid custom price source for %s. %s"], TSMAPI:GetSafeItemInfo(itemString) or itemString, err) TSM:Printf(L["Invalid custom price source for %s. %s"], TSMAPI:GetSafeItemInfo(itemString) or itemString, err)
else else
private.itemOperations[itemString] = opSettings private.itemOperations[baseItemString] = private.itemOperations[baseItemString] or {}
tinsert(private.itemOperations[baseItemString], opName)
end end
end end
end end

10
TradeSkillMaster_Shopping/sidebar/Other.lua

@ -230,9 +230,15 @@ function private.SniperScanCallback(event, itemString, auctionItem)
vendorPrice = vendor vendorPrice = vendor
end end
local operations = TSMAPI:GetItemOperation(itemString, "Shopping") local operations = TSMAPI:GetItemOperation(itemString, "Shopping")
local opSettings = operations and operations[1] and TSM.operations[operations[1]] for _, opName in ipairs(operations or {}) do
TSMAPI:UpdateOperation("Shopping", opName)
local opSettings = TSM.operations[opName]
if opSettings and opSettings.maxPrice then if opSettings and opSettings.maxPrice then
maxPrice = TSM:GetMaxPrice(opSettings.maxPrice, itemString) local opPrice = TSM:GetMaxPrice(opSettings.maxPrice, itemString)
if opPrice then
maxPrice = maxPrice and max(maxPrice, opPrice) or opPrice
end
end
end end
customPrice = TSM:GetMaxPrice(TSM.db.global.sniperCustomPrice, itemString) customPrice = TSM:GetMaxPrice(TSM.db.global.sniperCustomPrice, itemString)
end end

Loading…
Cancel
Save