From 9f29b4ab021d2ff947ca964c07443aea94fd8c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Wed, 14 Jan 2026 19:41:14 +0100 Subject: [PATCH] asmart avg --- TradeSkillMaster/TradeSkillMaster.lua | 3 ++ TradeSkillMaster_Accounting/Locale/enUS.lua | 2 + .../TradeSkillMaster_Accounting.lua | 51 +++++++++++++++---- .../TradeSkillMaster_Auctioning.lua | 1 - TradeSkillMaster_Auctioning/locale/enUS.lua | 1 - .../modules/Options.lua | 6 --- .../modules/manage.lua | 3 -- 7 files changed, 45 insertions(+), 22 deletions(-) diff --git a/TradeSkillMaster/TradeSkillMaster.lua b/TradeSkillMaster/TradeSkillMaster.lua index f321a6b..56a4684 100644 --- a/TradeSkillMaster/TradeSkillMaster.lua +++ b/TradeSkillMaster/TradeSkillMaster.lua @@ -735,6 +735,9 @@ function TSMAPI:GetItemPrices(itemLink) -- Use TSM:GetCustomPrice to get avgBuy price prices.avgBuy = TSM:GetCustomPrice("avgBuy", itemString) or 0 + -- Use TSM:GetCustomPrice to get smartAvgBuy price + prices.smartAvgBuy = TSM:GetCustomPrice("smartAvgBuy", itemString) or 0 + -- Use TSM:GetCustomPrice to get avgSell price prices.avgSell = TSM:GetCustomPrice("avgSell", itemString) or 0 diff --git a/TradeSkillMaster_Accounting/Locale/enUS.lua b/TradeSkillMaster_Accounting/Locale/enUS.lua index 34325eb..e9369dc 100644 --- a/TradeSkillMaster_Accounting/Locale/enUS.lua +++ b/TradeSkillMaster_Accounting/Locale/enUS.lua @@ -24,6 +24,8 @@ L["Average Prices:"] = true L["Avg Buy Price"] = true L["Avg Resale Profit"] = true L["Avg Sell Price"] = true +L["Smart Avg Buy Price:"] = true +L["Smart Avg Buy Price"] = true L["Back to Previous Page"] = true L["Balance"] = true L["Below is a graph of the your character's gold on hand over time.\n\nThe x-axis is time and goes from %s to %s\nThe y-axis is gold."] = true diff --git a/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua b/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua index 63ee874..9e1eb9b 100644 --- a/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua +++ b/TradeSkillMaster_Accounting/TradeSkillMaster_Accounting.lua @@ -125,6 +125,7 @@ function TSM:RegisterModule() TSM.priceSources = { { key = "avgSell", label = L["Avg Sell Price"], callback = "GetAvgSellPrice" }, { key = "avgBuy", label = L["Avg Buy Price"], callback = "GetAvgBuyPrice" }, + { key = "smartAvgBuy", label = L["Smart Avg Buy Price"], callback = "GetSmartAvgBuyPrice" }, { key = "maxSell", label = L["Max Sell Price"], callback = "GetMaxSellPrice" }, { key = "maxBuy", label = L["Max Buy Price"], callback = "GetMaxBuyPrice" }, { key = "minSell", label = L["Min Sell Price"], callback = "GetMinSellPrice" }, @@ -202,11 +203,19 @@ function TSM:GetTooltip(itemString) else local avgPrice = TSM:GetAvgBuyPrice(itemString) local maxPrice = TSM:GetMaxBuyPrice(itemString) + local smartAvgPrice = TSM:GetSmartAvgBuyPrice(itemString) if moneyCoinsTooltip then tinsert(text, { left = " " .. L["Purchased (Avg/Max Price):"], right = format("%s (%s / %s)", "|cffffffff" .. totalNum .. "|r", (TSMAPI:FormatTextMoneyIcon(avgPrice, "|cffffffff", true) or ("|cffffffff" .. "?")), (TSMAPI:FormatTextMoneyIcon(maxPrice, "|cffffffff", true) or ("|cffffffff" .. "?"))) }) else tinsert(text, { left = " " .. L["Purchased (Avg/Max Price):"], right = format("%s (%s / %s)", "|cffffffff" .. totalNum .. "|r", (TSMAPI:FormatTextMoney(avgPrice, "|cffffffff", true) or ("|cffffffff" .. "?")), (TSMAPI:FormatTextMoney(maxPrice, "|cffffffff", true) or ("|cffffffff" .. "?"))) }) end + if smartAvgPrice then + if moneyCoinsTooltip then + tinsert(text, { left = " " .. L["Smart Avg Buy Price:"], right = (TSMAPI:FormatTextMoneyIcon(smartAvgPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) + else + tinsert(text, { left = " " .. L["Smart Avg Buy Price:"], right = (TSMAPI:FormatTextMoney(smartAvgPrice, "|cffffffff", true) or ("|cffffffff" .. "?")) }) + end + end end if lastPurchased then local timeDiff = SecondsToTime(time() - lastPurchased) @@ -424,12 +433,24 @@ function TSM:GetAvgSellPrice(itemString) return TSM.cache[itemString].avgSellPrice, TSM.cache[itemString].avgSellNum end -local function GetAvgerageBuyPrice(itemString, noBaseItem) +local function GetSmartBuyItemCount(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 + return player + alts + guild + auctions +end + +local function GetAvgerageBuyPrice(itemString, noBaseItem, useSmart) if not noBaseItem and itemString and baseItemLookup[itemString] then local totalPrice, totalNum = 0, 0 for _, item in ipairs(baseItemLookup[itemString]) do if not baseItemLookup[item] then - local price, num = GetAvgerageBuyPrice(item, true) + local price, num = GetAvgerageBuyPrice(item, true, useSmart) if price and num and num > 0 then totalPrice = totalPrice + price totalNum = totalNum + num @@ -443,16 +464,11 @@ local function GetAvgerageBuyPrice(itemString, noBaseItem) if not (TSM.items[itemString] and #TSM.items[itemString].buys > 0) then return end local itemCount = 0 - if TSM.db.realm.smartBuyPrice then - local player, alts = TSMAPI:ModuleAPI("ItemTracker", "playertotal", itemString) - if not player then - alts = nil + if useSmart or TSM.db.realm.smartBuyPrice then + itemCount = GetSmartBuyItemCount(itemString) + if useSmart and itemCount <= 0 then + return 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 - itemCount = player + alts + guild + auctions end local num, totalPrice = 0, 0 @@ -482,6 +498,19 @@ function TSM:GetAvgBuyPrice(itemString) return TSM.cache[itemString].avgBuyPrice, TSM.cache[itemString].avgBuyNum end +function TSM:GetSmartAvgBuyPrice(itemString) + itemString = TSMAPI:GetItemString(select(2, TSMAPI:GetSafeItemInfo(itemString))) + if not itemString then return end + TSM.cache[itemString] = TSM.cache[itemString] or {} + TSM:UpdateBaseItemLookup() + if not TSM.cache[itemString].smartAvgBuyPrice then + local price, num = GetAvgerageBuyPrice(itemString, nil, true) + TSM.cache[itemString].smartAvgBuyPrice = price + TSM.cache[itemString].smartAvgBuyNum = num + end + return TSM.cache[itemString].smartAvgBuyPrice, TSM.cache[itemString].smartAvgBuyNum +end + function TSM:GetMaxSellPrice(itemString) itemString = TSMAPI:GetItemString(select(2, TSMAPI:GetSafeItemInfo(itemString))) if not (itemString and TSM.items[itemString] and #TSM.items[itemString].sales > 0) then return end diff --git a/TradeSkillMaster_Auctioning/TradeSkillMaster_Auctioning.lua b/TradeSkillMaster_Auctioning/TradeSkillMaster_Auctioning.lua index c333571..365aab9 100644 --- a/TradeSkillMaster_Auctioning/TradeSkillMaster_Auctioning.lua +++ b/TradeSkillMaster_Auctioning/TradeSkillMaster_Auctioning.lua @@ -22,7 +22,6 @@ local savedDBDefaults = { global = { optionsTreeStatus = {}, scanCompleteSound = 1, - flashClientOnComplete = false, cancelWithBid = false, matchWhitelist = true, roundNormalPrice = false, diff --git a/TradeSkillMaster_Auctioning/locale/enUS.lua b/TradeSkillMaster_Auctioning/locale/enUS.lua index da58556..11b22d8 100644 --- a/TradeSkillMaster_Auctioning/locale/enUS.lua +++ b/TradeSkillMaster_Auctioning/locale/enUS.lua @@ -100,7 +100,6 @@ L["Duration"] = true L["Edit Post Price"] = true L["Enable Reset Scan"] = true L["Enable Sounds"] = true -L["Flash Client Icon"] = true L["Error creating operation. Operation with name '%s' already exists."] = true L["General Operation Options"] = true L["General Options"] = true diff --git a/TradeSkillMaster_Auctioning/modules/Options.lua b/TradeSkillMaster_Auctioning/modules/Options.lua index 1eb71a5..c35aa85 100644 --- a/TradeSkillMaster_Auctioning/modules/Options.lua +++ b/TradeSkillMaster_Auctioning/modules/Options.lua @@ -107,12 +107,6 @@ function Options:DrawGeneralSettings(container) settingInfo = { TSM.db.global, "scanCompleteSound" }, tooltip = L["Play the selected sound when a post / cancel scan is complete and items are ready to be posted / canceled (the gray bar is all the way across).Select None to disable sounds"], }, - { - type = "CheckBox", - label = L["Flash Client Icon"], - settingInfo = { TSM.db.global, "flashClientOnComplete" }, - tooltip = L["If checked, the game client icon will flash when a scan is complete."], - }, { type = "Button", text = L["Test Selected Sound"], diff --git a/TradeSkillMaster_Auctioning/modules/manage.lua b/TradeSkillMaster_Auctioning/modules/manage.lua index b8a930b..cc45217 100644 --- a/TradeSkillMaster_Auctioning/modules/manage.lua +++ b/TradeSkillMaster_Auctioning/modules/manage.lua @@ -119,9 +119,6 @@ function Manage:ScanComplete(interrupted) elseif TSM.db.global.scanCompleteSound ~= 1 then PlaySound(TSM.Options:GetScanCompleteSound(TSM.db.global.scanCompleteSound), "Master") end - if TSM.db.global.flashClientOnComplete then - FlashClientIcon() - end end end