10 changed files with 964 additions and 693 deletions
@ -1,340 +1,400 @@ |
|||||||
-- ------------------------------------------------------------------------------ -- |
-- ------------------------------------------------------------------------------ -- |
||||||
-- TradeSkillMaster_Crafting -- |
-- TradeSkillMaster_Crafting -- |
||||||
-- http://www.curse.com/addons/wow/tradeskillmaster_crafting -- |
-- http://www.curse.com/addons/wow/tradeskillmaster_crafting -- |
||||||
-- -- |
-- -- |
||||||
-- A TradeSkillMaster Addon (http://tradeskillmaster.com) -- |
-- A TradeSkillMaster Addon (http://tradeskillmaster.com) -- |
||||||
-- All Rights Reserved* - Detailed license information included with addon. -- |
-- All Rights Reserved* - Detailed license information included with addon. -- |
||||||
-- ------------------------------------------------------------------------------ -- |
-- ------------------------------------------------------------------------------ -- |
||||||
|
|
||||||
-- load the parent file (TSM) into a local variable and register this file as a module |
-- load the parent file (TSM) into a local variable and register this file as a module |
||||||
local TSM = select(2, ...) |
local TSM = select(2, ...) |
||||||
local Inventory = TSM:NewModule("Inventory", "AceEvent-3.0") |
local Inventory = TSM:NewModule("Inventory", "AceEvent-3.0") |
||||||
local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Crafting") -- loads the localization table |
local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Crafting") -- loads the localization table |
||||||
|
|
||||||
|
|
||||||
-- gets the number of an item in the current player's bags |
-- gets the number of an item in the current player's bags |
||||||
function Inventory:GetPlayerBagNum(itemString) |
function Inventory:GetPlayerBagNum(itemString) |
||||||
if not itemString then return end |
if not itemString then return end |
||||||
|
|
||||||
if TSMAPI.SOULBOUND_MATS[itemString] then |
if TSMAPI.SOULBOUND_MATS[itemString] then |
||||||
return GetItemCount(itemString) |
return GetItemCount(itemString) |
||||||
else |
else |
||||||
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", UnitName("player")) or {} |
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", UnitName("player")) or {} |
||||||
return bags and bags[itemString] or 0 |
return bags and bags[itemString] or 0 |
||||||
end |
end |
||||||
end |
end |
||||||
|
|
||||||
function Inventory:GetTotals() |
function Inventory:GetTotals() |
||||||
local bagTotal, auctionTotal, otherTotal, total = {}, {}, {}, {} |
local bagTotal, auctionTotal, otherTotal, total = {}, {}, {}, {} |
||||||
|
|
||||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
||||||
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
||||||
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
||||||
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
||||||
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
||||||
local auctions = TSMAPI:ModuleAPI("ItemTracker", "playerauctions", player) or {} |
local auctions = TSMAPI:ModuleAPI("ItemTracker", "playerauctions", player) or {} |
||||||
for itemString, quantity in pairs(bags) do |
for itemString, quantity in pairs(bags) do |
||||||
if player == UnitName("player") then |
if player == UnitName("player") then |
||||||
bagTotal[itemString] = (bagTotal[itemString] or 0) + quantity |
bagTotal[itemString] = (bagTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
else |
else |
||||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
end |
end |
||||||
end |
end |
||||||
for itemString, quantity in pairs(bank) do |
for itemString, quantity in pairs(bank) do |
||||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
end |
end |
||||||
for itemString, quantity in pairs(mail) do |
for itemString, quantity in pairs(mail) do |
||||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
end |
end |
||||||
for itemString, quantity in pairs(auctions) do |
for itemString, quantity in pairs(auctions) do |
||||||
auctionTotal[itemString] = (auctionTotal[itemString] or 0) + quantity |
auctionTotal[itemString] = (auctionTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
|
||||||
for itemString in pairs(TSMAPI.SOULBOUND_MATS) do |
for itemString in pairs(TSMAPI.SOULBOUND_MATS) do |
||||||
local bagNum = GetItemCount(itemString) |
local bagNum = GetItemCount(itemString) |
||||||
local bankNum = GetItemCount(itemString, true) - GetItemCount(itemString) |
local bankNum = GetItemCount(itemString, true) - GetItemCount(itemString) |
||||||
bagTotal[itemString] = (bagTotal[itemString] or 0) + bagNum |
bagTotal[itemString] = (bagTotal[itemString] or 0) + bagNum |
||||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + bankNum |
otherTotal[itemString] = (otherTotal[itemString] or 0) + bankNum |
||||||
total[itemString] = (total[itemString] or 0) + bagNum + bankNum |
total[itemString] = (total[itemString] or 0) + bagNum + bankNum |
||||||
end |
end |
||||||
|
|
||||||
-- add gbank counts of all non-ignored guilds |
-- add gbank counts of all non-ignored guilds |
||||||
for _, guild in pairs(TSMAPI:ModuleAPI("ItemTracker", "guildlist") or {}) do |
for _, guild in pairs(TSMAPI:ModuleAPI("ItemTracker", "guildlist") or {}) do |
||||||
if not TSM.db.global.ignoreGuilds[guild] then |
if not TSM.db.global.ignoreGuilds[guild] then |
||||||
local gbank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
local gbank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
||||||
for itemString, quantity in pairs(gbank) do |
for itemString, quantity in pairs(gbank) do |
||||||
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
total[itemString] = (total[itemString] or 0) + quantity |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
return bagTotal, auctionTotal, otherTotal, total |
-- Ascension WoW: add personal bank counts for all non-ignored characters |
||||||
end |
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
||||||
|
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
||||||
-- gets the total number of some item that they have |
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {} |
||||||
function Inventory:GetTotalQuantity(itemString) |
for itemString, quantity in pairs(personalBank) do |
||||||
if not itemString then return 0 end |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
local count = 0 |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
|
end |
||||||
-- add bags/bank/mail/auction counts of all non-ignored characters (always including current character) |
end |
||||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
end |
||||||
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
|
||||||
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
-- Ascension WoW: add realm bank counts |
||||||
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {} |
||||||
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
for itemString, quantity in pairs(realmBank) do |
||||||
local auctions = TSMAPI:ModuleAPI("ItemTracker", "playerauctions", player) or {} |
otherTotal[itemString] = (otherTotal[itemString] or 0) + quantity |
||||||
count = count + (bags[itemString] or 0) |
total[itemString] = (total[itemString] or 0) + quantity |
||||||
count = count + (bank[itemString] or 0) |
end |
||||||
count = count + (mail[itemString] or 0) |
|
||||||
count = count + (auctions[itemString] or 0) |
return bagTotal, auctionTotal, otherTotal, total |
||||||
end |
end |
||||||
end |
|
||||||
-- add gbank counts of all non-ignored guilds |
-- gets the total number of some item that they have |
||||||
for _, guild in pairs(TSMAPI:ModuleAPI("ItemTracker", "guildlist") or {}) do |
function Inventory:GetTotalQuantity(itemString) |
||||||
if not TSM.db.global.ignoreGuilds[guild] then |
if not itemString then return 0 end |
||||||
local bank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
local count = 0 |
||||||
count = count + (bank[itemString] or 0) |
|
||||||
end |
-- add bags/bank/mail/auction counts of all non-ignored characters (always including current character) |
||||||
end |
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
||||||
|
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
||||||
if TSMAPI.SOULBOUND_MATS[itemString] then |
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
||||||
count = count + GetItemCount(itemString, true) |
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
||||||
end |
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
||||||
|
local auctions = TSMAPI:ModuleAPI("ItemTracker", "playerauctions", player) or {} |
||||||
return count |
count = count + (bags[itemString] or 0) |
||||||
end |
count = count + (bank[itemString] or 0) |
||||||
|
count = count + (mail[itemString] or 0) |
||||||
function Inventory:GetItemSources(crafter, neededMats) |
count = count + (auctions[itemString] or 0) |
||||||
if not neededMats then return end |
end |
||||||
local sources = {} |
end |
||||||
local gbank = {} |
-- add gbank counts of all non-ignored guilds |
||||||
local next = next |
for _, guild in pairs(TSMAPI:ModuleAPI("ItemTracker", "guildlist") or {}) do |
||||||
local crafterBags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", crafter) or {} |
if not TSM.db.global.ignoreGuilds[guild] then |
||||||
local crafterMail = TSMAPI:ModuleAPI("ItemTracker", "playermail", crafter) or {} |
local bank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
||||||
local crafterBank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", crafter) or {} |
count = count + (bank[itemString] or 0) |
||||||
|
end |
||||||
-- add vendor items |
end |
||||||
local task = {} |
|
||||||
local items = {} |
-- Ascension WoW: add personal bank counts for all non-ignored characters |
||||||
for itemString, quantity in pairs(neededMats) do |
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
||||||
if TSMAPI:GetVendorCost(itemString) then |
if player == UnitName("player") or not TSM.db.global.ignoreCharacters[player] then |
||||||
local vendorNeed = quantity - ((crafterBags[itemString] or 0) + (crafterMail[itemString] or 0) + (crafterBank[itemString] or 0)) |
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {} |
||||||
if vendorNeed > 0 then |
count = count + (personalBank[itemString] or 0) |
||||||
items[itemString] = vendorNeed |
end |
||||||
end |
end |
||||||
elseif TSMAPI.Conversions[itemString] and TSMAPI.InkConversions[itemString] then |
|
||||||
local tradeItem, data = next(TSMAPI.Conversions[itemString]) |
-- Ascension WoW: add realm bank count |
||||||
if data.source == "vendortrade" then |
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {} |
||||||
local num = floor(Inventory:GetTotalQuantity(tradeItem) * data.rate) |
count = count + (realmBank[itemString] or 0) |
||||||
if quantity > Inventory:GetTotalQuantity(itemString) and num >= (quantity - Inventory:GetTotalQuantity(itemString)) then |
|
||||||
items[itemString] = quantity - Inventory:GetTotalQuantity(itemString) |
if TSMAPI.SOULBOUND_MATS[itemString] then |
||||||
neededMats[tradeItem] = (neededMats[tradeItem] or 0) + quantity / data.rate -- add the qty of IOD to needed mats |
count = count + GetItemCount(itemString, true) |
||||||
end |
end |
||||||
end |
|
||||||
end |
return count |
||||||
end |
end |
||||||
if next(items) then |
|
||||||
tinsert(task, { taskType = L["Visit Vendor"], items = items }) |
function Inventory:GetItemSources(crafter, neededMats) |
||||||
tinsert(sources, { sourceName = L["Vendor"], isCrafter = false, isVendor = true, isAH = false, tasks = task }) |
if not neededMats then return end |
||||||
end |
local sources = {} |
||||||
|
local gbank = {} |
||||||
-- double check if crafter already has all the items needed |
local next = next |
||||||
local shortItems = {} |
local crafterBags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", crafter) or {} |
||||||
for itemString, quantity in pairs(neededMats) do |
local crafterMail = TSMAPI:ModuleAPI("ItemTracker", "playermail", crafter) or {} |
||||||
local soulboundBagCount |
local crafterBank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", crafter) or {} |
||||||
if TSMAPI.SOULBOUND_MATS[itemString] then |
-- Ascension WoW: crafter's personal bank |
||||||
soulboundBagCount = GetItemCount(itemString) |
local crafterPersonalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", crafter) or {} |
||||||
end |
|
||||||
local need = max(quantity - (crafterBags[itemString] or soulboundBagCount or 0), 0) |
-- add vendor items |
||||||
if need > 0 then |
local task = {} |
||||||
shortItems[itemString] = need |
local items = {} |
||||||
end |
for itemString, quantity in pairs(neededMats) do |
||||||
end |
if TSMAPI:GetVendorCost(itemString) then |
||||||
if not next(shortItems) then return end |
local vendorNeed = quantity - ((crafterBags[itemString] or 0) + (crafterMail[itemString] or 0) + (crafterBank[itemString] or 0) + (crafterPersonalBank[itemString] or 0)) |
||||||
|
if vendorNeed > 0 then |
||||||
-- add bags/bank/mail "tasks" for needed items of all non-ignored characters (always include crafter) |
items[itemString] = vendorNeed |
||||||
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
end |
||||||
if player == crafter or not TSM.db.global.ignoreCharacters[player] then |
elseif TSMAPI.Conversions[itemString] and TSMAPI.InkConversions[itemString] then |
||||||
local task = {} |
local tradeItem, data = next(TSMAPI.Conversions[itemString]) |
||||||
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
if data.source == "vendortrade" then |
||||||
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
local num = floor(Inventory:GetTotalQuantity(tradeItem) * data.rate) |
||||||
local guild = TSMAPI:ModuleAPI("ItemTracker", "playerguild", player) or {} |
if quantity > Inventory:GetTotalQuantity(itemString) and num >= (quantity - Inventory:GetTotalQuantity(itemString)) then |
||||||
local gbank = {} |
items[itemString] = quantity - Inventory:GetTotalQuantity(itemString) |
||||||
if guild and not TSM.db.global.ignoreGuilds[guild] then |
neededMats[tradeItem] = (neededMats[tradeItem] or 0) + quantity / data.rate -- add the qty of IOD to needed mats |
||||||
gbank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
end |
||||||
end |
end |
||||||
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
end |
||||||
local bankItems = {} |
end |
||||||
local gbankItems = {} |
if next(items) then |
||||||
local mailItems = {} |
tinsert(task, { taskType = L["Visit Vendor"], items = items }) |
||||||
local bagItems = {} |
tinsert(sources, { sourceName = L["Vendor"], isCrafter = false, isVendor = true, isAH = false, tasks = task }) |
||||||
|
end |
||||||
for itemString in pairs(neededMats) do |
|
||||||
local soulboundBagCount, soulboundBankCount |
-- double check if crafter already has all the items needed |
||||||
if TSMAPI.SOULBOUND_MATS[itemString] then |
local shortItems = {} |
||||||
soulboundBagCount = GetItemCount(itemString) |
for itemString, quantity in pairs(neededMats) do |
||||||
soulboundBankCount = GetItemCount(itemString, true) - soulboundBagCount |
local soulboundBagCount |
||||||
end |
if TSMAPI.SOULBOUND_MATS[itemString] then |
||||||
if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) and shortItems[itemString] then |
soulboundBagCount = GetItemCount(itemString) |
||||||
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
end |
||||||
bankItems[itemString] = bank[itemString] or soulboundBankCount |
local need = max(quantity - (crafterBags[itemString] or soulboundBagCount or 0), 0) |
||||||
end |
if need > 0 then |
||||||
end |
shortItems[itemString] = need |
||||||
if gbank[itemString] and shortItems[itemString] then |
end |
||||||
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
end |
||||||
gbankItems[itemString] = gbank[itemString] |
if not next(shortItems) then return end |
||||||
end |
|
||||||
end |
-- add bags/bank/mail "tasks" for needed items of all non-ignored characters (always include crafter) |
||||||
if mail[itemString] and shortItems[itemString] then |
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
||||||
mailItems[itemString] = mail[itemString] |
if player == crafter or not TSM.db.global.ignoreCharacters[player] then |
||||||
end |
local task = {} |
||||||
if bags[itemString] and shortItems[itemString] then |
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
||||||
if player ~= crafter then |
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
||||||
if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then |
local guild = TSMAPI:ModuleAPI("ItemTracker", "playerguild", player) or {} |
||||||
bagItems[itemString] = bags[itemString] |
local gbank = {} |
||||||
end |
if guild and not TSM.db.global.ignoreGuilds[guild] then |
||||||
end |
gbank = TSMAPI:ModuleAPI("ItemTracker", "guildbank", guild) or {} |
||||||
end |
end |
||||||
end |
local mail = TSMAPI:ModuleAPI("ItemTracker", "playermail", player) or {} |
||||||
-- add mail tasks for destroyable items bought through shopping search (exclude items already added to mail tasks) |
-- Ascension WoW: personal bank for this player |
||||||
for itemString, quantity in pairs(TSM.db.realm.gathering.destroyingMats) do |
local personalBank = TSMAPI:ModuleAPI("ItemTracker", "personalbank", player) or {} |
||||||
if mail[itemString] and not shortItems[itemString] then |
local bankItems = {} |
||||||
mailItems[itemString] = quantity |
local gbankItems = {} |
||||||
end |
local mailItems = {} |
||||||
end |
local bagItems = {} |
||||||
|
local personalBankItems = {} |
||||||
if next(bankItems) then |
|
||||||
tinsert(task, { taskType = L["Visit Bank"], items = bankItems }) |
for itemString in pairs(neededMats) do |
||||||
end |
local soulboundBagCount, soulboundBankCount |
||||||
if next(gbankItems) then |
if TSMAPI.SOULBOUND_MATS[itemString] then |
||||||
tinsert(task, { taskType = L["Visit Guild Bank"], items = gbankItems }) |
soulboundBagCount = GetItemCount(itemString) |
||||||
end |
soulboundBankCount = GetItemCount(itemString, true) - soulboundBagCount |
||||||
if next(mailItems) then |
end |
||||||
tinsert(task, { taskType = L["Collect Mail"], items = mailItems }) |
if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) and shortItems[itemString] then |
||||||
end |
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
||||||
if next(bagItems) then |
bankItems[itemString] = bank[itemString] or soulboundBankCount |
||||||
tinsert(task, { taskType = L["Mail Items"], items = bagItems }) |
end |
||||||
end |
end |
||||||
if next(task) then |
if gbank[itemString] and shortItems[itemString] then |
||||||
tinsert(sources, { sourceName = player, isCrafter = player == crafter, isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) |
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
||||||
end |
gbankItems[itemString] = gbank[itemString] |
||||||
end |
end |
||||||
end |
end |
||||||
|
-- Ascension WoW: check personal bank |
||||||
-- add auction house tasks |
if personalBank[itemString] and shortItems[itemString] then |
||||||
local auctionTask = {} |
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
||||||
local auctionItems = {} |
personalBankItems[itemString] = personalBank[itemString] |
||||||
for itemString, quantity in pairs(neededMats) do |
end |
||||||
if not TSMAPI.SOULBOUND_MATS[itemString] and not TSMAPI:GetVendorCost(itemString) then |
end |
||||||
local need |
if mail[itemString] and shortItems[itemString] then |
||||||
if TSM.Inventory.gatherItem == itemString and TSM.Inventory.gatherQuantity then |
mailItems[itemString] = mail[itemString] |
||||||
need = TSM.Inventory.gatherQuantity |
end |
||||||
else |
if bags[itemString] and shortItems[itemString] then |
||||||
need = max(quantity - (TSM.Inventory:GetTotalQuantity(itemString) or 0), 0) |
if player ~= crafter then |
||||||
end |
if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then |
||||||
if need > 0 then |
bagItems[itemString] = bags[itemString] |
||||||
auctionItems[itemString] = need |
end |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
if next(auctionItems) then |
-- add mail tasks for destroyable items bought through shopping search (exclude items already added to mail tasks) |
||||||
tinsert(auctionTask, { taskType = L["Search for Mats"], items = auctionItems }) |
for itemString, quantity in pairs(TSM.db.realm.gathering.destroyingMats) do |
||||||
tinsert(sources, { sourceName = L["Auction House"], isCrafter = false, isVendor = false, isAH = true, tasks = auctionTask }) |
if mail[itemString] and not shortItems[itemString] then |
||||||
end |
mailItems[itemString] = quantity |
||||||
|
end |
||||||
-- add destroying tasks |
end |
||||||
local destroyingTask, millItems, prospectItems, transformItems, deItems = {}, {}, {}, {}, {} |
|
||||||
|
if next(bankItems) then |
||||||
for itemString, quantity in pairs(neededMats) do |
tinsert(task, { taskType = L["Visit Bank"], items = bankItems }) |
||||||
local need = max(quantity - (TSM.Inventory:GetTotalQuantity(itemString) or 0), 0) |
end |
||||||
-- conversion items |
if next(gbankItems) then |
||||||
for destroyItem, data in pairs(TSMAPI.Conversions[itemString] or {}) do |
tinsert(task, { taskType = L["Visit Guild Bank"], items = gbankItems }) |
||||||
if TSM.db.realm.gathering.destroyingMats[destroyItem] then |
end |
||||||
if need > 0 then |
-- Ascension WoW: personal bank task |
||||||
local destroyNeed |
if next(personalBankItems) then |
||||||
if data.source == "mill" then |
tinsert(task, { taskType = L["Visit Personal Bank"], items = personalBankItems }) |
||||||
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 5) |
end |
||||||
if destroyNeed > 0 then |
if next(mailItems) then |
||||||
millItems[destroyItem] = (millItems[destroyItem] or 0) + destroyNeed |
tinsert(task, { taskType = L["Collect Mail"], items = mailItems }) |
||||||
end |
end |
||||||
elseif data.source == "prospect" then |
if next(bagItems) then |
||||||
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 5) |
tinsert(task, { taskType = L["Mail Items"], items = bagItems }) |
||||||
if destroyNeed > 0 then |
end |
||||||
prospectItems[destroyItem] = (prospectItems[destroyItem] or 0) + destroyNeed |
if next(task) then |
||||||
end |
tinsert(sources, { sourceName = player, isCrafter = player == crafter, isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) |
||||||
elseif data.source == "transform" then |
end |
||||||
if data.rate == 1 / 3 then |
end |
||||||
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 3) |
end |
||||||
elseif data.rate == 1 / 10 then |
-- Ascension WoW: add realm bank as a separate source |
||||||
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 10) |
local realmBank = TSMAPI:ModuleAPI("ItemTracker", "realmbank") or {} |
||||||
else |
local realmBankTask = {} |
||||||
destroyNeed = TSM.db.realm.gathering.destroyingMats[destroyItem] |
local realmBankItems = {} |
||||||
end |
for itemString in pairs(neededMats) do |
||||||
if destroyNeed > 0 then |
if realmBank[itemString] and shortItems[itemString] then |
||||||
transformItems[destroyItem] = (transformItems[destroyItem] or 0) + destroyNeed |
if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then |
||||||
end |
realmBankItems[itemString] = realmBank[itemString] |
||||||
end |
end |
||||||
else |
end |
||||||
TSM.db.realm.gathering.destroyingMats[destroyItem] = nil |
end |
||||||
end |
if next(realmBankItems) then |
||||||
end |
tinsert(realmBankTask, { taskType = L["Visit Realm Bank"], items = realmBankItems }) |
||||||
end |
tinsert(sources, { sourceName = L["Realm Bank"], isCrafter = false, isVendor = false, isAH = false, tasks = realmBankTask, isCurrent = true }) |
||||||
-- disenchantable items |
end |
||||||
if next(TSM.db.realm.gathering.destroyingMats) then |
|
||||||
for deItemString, quantity in pairs(TSM.db.realm.gathering.destroyingMats) do |
-- add auction house tasks |
||||||
if Inventory:IsDisenchantable(deItemString) then |
local auctionTask = {} |
||||||
if need > 0 then |
local auctionItems = {} |
||||||
deItems[deItemString] = quantity |
for itemString, quantity in pairs(neededMats) do |
||||||
else |
if not TSMAPI.SOULBOUND_MATS[itemString] and not TSMAPI:GetVendorCost(itemString) then |
||||||
TSM.db.realm.gathering.destroyingMats[deItemString] = nil |
local need |
||||||
end |
if TSM.Inventory.gatherItem == itemString and TSM.Inventory.gatherQuantity then |
||||||
end |
need = TSM.Inventory.gatherQuantity |
||||||
end |
else |
||||||
end |
need = max(quantity - (TSM.Inventory:GetTotalQuantity(itemString) or 0), 0) |
||||||
end |
end |
||||||
|
if need > 0 then |
||||||
if next(millItems) then |
auctionItems[itemString] = need |
||||||
tinsert(destroyingTask, { taskType = L["Milling"], items = millItems }) |
end |
||||||
end |
end |
||||||
if next(prospectItems) then |
end |
||||||
tinsert(destroyingTask, { taskType = L["Prospect"], items = prospectItems }) |
if next(auctionItems) then |
||||||
end |
tinsert(auctionTask, { taskType = L["Search for Mats"], items = auctionItems }) |
||||||
if next(transformItems) then |
tinsert(sources, { sourceName = L["Auction House"], isCrafter = false, isVendor = false, isAH = true, tasks = auctionTask }) |
||||||
tinsert(destroyingTask, { taskType = L["Transform"], items = transformItems }) |
end |
||||||
end |
|
||||||
if next(deItems) then |
-- add destroying tasks |
||||||
tinsert(destroyingTask, { taskType = L["Disenchant"], items = deItems }) |
local destroyingTask, millItems, prospectItems, transformItems, deItems = {}, {}, {}, {}, {} |
||||||
end |
|
||||||
if next(destroyingTask) then |
for itemString, quantity in pairs(neededMats) do |
||||||
tinsert(sources, { sourceName = L["Destroying"], isCrafter = false, isVendor = false, isAH = true, tasks = destroyingTask }) |
local need = max(quantity - (TSM.Inventory:GetTotalQuantity(itemString) or 0), 0) |
||||||
end |
-- conversion items |
||||||
|
for destroyItem, data in pairs(TSMAPI.Conversions[itemString] or {}) do |
||||||
|
if TSM.db.realm.gathering.destroyingMats[destroyItem] then |
||||||
sort(sources, function(a, b) |
if need > 0 then |
||||||
if a.isCurrent then return true end |
local destroyNeed |
||||||
if b.isCurrent then return false end |
if data.source == "mill" then |
||||||
if a.isAH then return false end |
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 5) |
||||||
if b.isAH then return true end |
if destroyNeed > 0 then |
||||||
if a.isVendor then return false end |
millItems[destroyItem] = (millItems[destroyItem] or 0) + destroyNeed |
||||||
if b.isVendor then return true end |
end |
||||||
if a.isCrafter then return false end |
elseif data.source == "prospect" then |
||||||
if b.isCrafter then return true end |
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 5) |
||||||
return a.sourceName < b.sourceName |
if destroyNeed > 0 then |
||||||
end) |
prospectItems[destroyItem] = (prospectItems[destroyItem] or 0) + destroyNeed |
||||||
return sources |
end |
||||||
end |
elseif data.source == "transform" then |
||||||
|
if data.rate == 1 / 3 then |
||||||
function Inventory:IsDisenchantable(itemString) |
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 3) |
||||||
local _, link, quality, _, _, iType = TSMAPI:GetSafeItemInfo(itemString) |
elseif data.rate == 1 / 10 then |
||||||
local WEAPON, ARMOR = GetAuctionItemClasses() |
destroyNeed = floor(TSM.db.realm.gathering.destroyingMats[destroyItem] / 10) |
||||||
if itemString and not TSMAPI.DisenchantingData.notDisenchantable[itemString] and (iType == ARMOR or iType == WEAPON) then |
else |
||||||
return true |
destroyNeed = TSM.db.realm.gathering.destroyingMats[destroyItem] |
||||||
end |
end |
||||||
|
if destroyNeed > 0 then |
||||||
|
transformItems[destroyItem] = (transformItems[destroyItem] or 0) + destroyNeed |
||||||
|
end |
||||||
|
end |
||||||
|
else |
||||||
|
TSM.db.realm.gathering.destroyingMats[destroyItem] = nil |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
-- disenchantable items |
||||||
|
if next(TSM.db.realm.gathering.destroyingMats) then |
||||||
|
for deItemString, quantity in pairs(TSM.db.realm.gathering.destroyingMats) do |
||||||
|
if Inventory:IsDisenchantable(deItemString) then |
||||||
|
if need > 0 then |
||||||
|
deItems[deItemString] = quantity |
||||||
|
else |
||||||
|
TSM.db.realm.gathering.destroyingMats[deItemString] = nil |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
if next(millItems) then |
||||||
|
tinsert(destroyingTask, { taskType = L["Milling"], items = millItems }) |
||||||
|
end |
||||||
|
if next(prospectItems) then |
||||||
|
tinsert(destroyingTask, { taskType = L["Prospect"], items = prospectItems }) |
||||||
|
end |
||||||
|
if next(transformItems) then |
||||||
|
tinsert(destroyingTask, { taskType = L["Transform"], items = transformItems }) |
||||||
|
end |
||||||
|
if next(deItems) then |
||||||
|
tinsert(destroyingTask, { taskType = L["Disenchant"], items = deItems }) |
||||||
|
end |
||||||
|
if next(destroyingTask) then |
||||||
|
tinsert(sources, { sourceName = L["Destroying"], isCrafter = false, isVendor = false, isAH = true, tasks = destroyingTask }) |
||||||
|
end |
||||||
|
|
||||||
|
|
||||||
|
sort(sources, function(a, b) |
||||||
|
if a.isCurrent then return true end |
||||||
|
if b.isCurrent then return false end |
||||||
|
if a.isAH then return false end |
||||||
|
if b.isAH then return true end |
||||||
|
if a.isVendor then return false end |
||||||
|
if b.isVendor then return true end |
||||||
|
if a.isCrafter then return false end |
||||||
|
if b.isCrafter then return true end |
||||||
|
return a.sourceName < b.sourceName |
||||||
|
end) |
||||||
|
return sources |
||||||
|
end |
||||||
|
|
||||||
|
function Inventory:IsDisenchantable(itemString) |
||||||
|
local _, link, quality, _, _, iType = TSMAPI:GetSafeItemInfo(itemString) |
||||||
|
local WEAPON, ARMOR = GetAuctionItemClasses() |
||||||
|
if itemString and not TSMAPI.DisenchantingData.notDisenchantable[itemString] and (iType == ARMOR or iType == WEAPON) then |
||||||
|
return true |
||||||
|
end |
||||||
end |
end |
||||||
Loading…
Reference in new issue