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. 31
      TradeSkillMaster_Shopping/TradeSkillMaster_Shopping.lua
  6. 69
      TradeSkillMaster_Shopping/sidebar/Groups.lua
  7. 12
      TradeSkillMaster_Shopping/sidebar/Other.lua

2
TradeSkillMaster/TradeSkillMaster.toc

@ -2,7 +2,7 @@
## Title: |cff00fe00TradeSkillMaster: Revived|r
## 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...
## Version: 2.3.30
## Version: 2.3.33
## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB
## 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

4
TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc

@ -2,10 +2,10 @@
## Title: |cff00ff00TradeSkillMaster_AuctionDB|r
## Notes: Stores auction house data and calculates market prices.
## Author: Sapu94, Bart39
## Version: 2.3.30
## Version: 2.3.33
## SavedVariables: AscensionTSM_AuctionDB
## 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-ID: tradeskillmaster_auctiondb
## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline

24
TradeSkillMaster_Crafting/Modules/Queue.lua

@ -33,6 +33,9 @@ end
function Queue:CreateRestockQueue(groupInfo)
TSM:UpdateCraftReverseLookup()
local numItems = 0
local bestQueued = {}
local bestSpellID = {}
local seenItems = {}
for _, data in pairs(groupInfo) do
for _, opName in ipairs(data.operations) do
@ -42,6 +45,7 @@ function Queue:CreateRestockQueue(groupInfo)
-- it's a valid operation
for itemString in pairs(data.items) do
itemString = TSMAPI:GetItemString(itemString)
seenItems[itemString] = true
local spellID = TSM.craftReverseLookup[itemString] and TSM.craftReverseLookup[itemString][1]
if spellID and TSM.db.realm.crafts[spellID] then
local maxQueueCount = max(opSettings.maxRestock - TSM.Inventory:GetTotalQuantity(itemString), 0)
@ -61,10 +65,11 @@ function Queue:CreateRestockQueue(groupInfo)
end
local craft = TSM.db.realm.crafts[spellID]
craft.queued = floor(numToQueue / craft.numResult)
craft.queued = craft.queued >= opSettings.minRestock and craft.queued or 0
if craft.queued > 0 then
numItems = numItems + 1
local queued = floor(numToQueue / craft.numResult)
queued = queued >= opSettings.minRestock and queued or 0
if queued > 0 and queued > (bestQueued[itemString] or 0) then
bestQueued[itemString] = queued
bestSpellID[itemString] = spellID
end
end
end
@ -72,6 +77,17 @@ function Queue:CreateRestockQueue(groupInfo)
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
if numItems==0 then
TSM:Printf("There are no items to restock.")
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().
function TSM:RegisterModule()
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 = {
{ key = "Crafting", label = L["Crafting Cost"], callback = "GetCraftingCost" },
{ key = "matPrice", label = L["Crafting Material Cost"], callback = "GetCraftingMatCost" },

31
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().
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.tooltipOptions = { callback = "Options:LoadTooltipOptions" }
TSM.moduleAPIs = {
@ -136,21 +136,26 @@ function TSM:GetTooltip(itemString)
itemString = TSMAPI:GetBaseItemString(itemString, true)
local operations = TSMAPI:GetItemOperation(itemString, "Shopping")
if not operations then return end
local operationName = operations[1]
TSMAPI:UpdateOperation("Shopping", operationName)
local operation = TSM.operations[operationName]
if operation then
local maxPrice = TSM:GetMaxPrice(operation.maxPrice, itemString)
if maxPrice then
local priceText
if moneyCoinsTooltip then
priceText = (TSMAPI:FormatTextMoneyIcon(maxPrice, "|cffffffff", true) or "|cffffffff---|r")
else
priceText = (TSMAPI:FormatTextMoney(maxPrice, "|cffffffff", true) or "|cffffffff---|r")
local maxPrice
for _, operationName in ipairs(operations) do
TSMAPI:UpdateOperation("Shopping", operationName)
local operation = TSM.operations[operationName]
if operation then
local price = TSM:GetMaxPrice(operation.maxPrice, itemString)
if price then
maxPrice = maxPrice and max(maxPrice, price) or price
end
tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) })
end
end
if maxPrice then
local priceText
if moneyCoinsTooltip then
priceText = (TSMAPI:FormatTextMoneyIcon(maxPrice, "|cffffffff", true) or "|cffffffff---|r")
else
priceText = (TSMAPI:FormatTextMoney(maxPrice, "|cffffffff", true) or "|cffffffff---|r")
end
tinsert(text, { left = " " .. L["Max Shopping Price:"], right = format("%s", priceText) })
end
if #text > 0 then
tinsert(text, 1, "|cffffff00" .. "TSM Shopping:")
return text

69
TradeSkillMaster_Shopping/sidebar/Groups.lua

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

12
TradeSkillMaster_Shopping/sidebar/Other.lua

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

Loading…
Cancel
Save