|
|
|
|
@ -111,6 +111,15 @@
|
|
|
|
|
return count |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local function IsSamePlayer(a, b) |
|
|
|
|
if not a or not b then return false end |
|
|
|
|
local function Normalize(name) |
|
|
|
|
local base = strmatch(name, "^[^-]+") or name |
|
|
|
|
return strlower(base) |
|
|
|
|
end |
|
|
|
|
return Normalize(a) == Normalize(b) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Inventory:GetItemSources(crafter, neededMats) |
|
|
|
|
if not neededMats then return end |
|
|
|
|
local sources = {} |
|
|
|
|
@ -161,7 +170,7 @@
|
|
|
|
|
|
|
|
|
|
-- add bags/bank/mail "tasks" for needed items of all non-ignored characters (always include crafter) |
|
|
|
|
for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do |
|
|
|
|
if player == crafter or not TSM.db.global.ignoreCharacters[player] then |
|
|
|
|
if IsSamePlayer(player, crafter) or not TSM.db.global.ignoreCharacters[player] then |
|
|
|
|
local task = {} |
|
|
|
|
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} |
|
|
|
|
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} |
|
|
|
|
@ -182,24 +191,21 @@
|
|
|
|
|
soulboundBagCount = GetItemCount(itemString) |
|
|
|
|
soulboundBankCount = GetItemCount(itemString, true) - soulboundBagCount |
|
|
|
|
end |
|
|
|
|
if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) and shortItems[itemString] then |
|
|
|
|
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
|
|
|
|
bankItems[itemString] = bank[itemString] or soulboundBankCount |
|
|
|
|
local remainingNeed = shortItems[itemString] and shortItems[itemString] - (crafterMail[itemString] or 0) or 0 |
|
|
|
|
if remainingNeed > 0 then |
|
|
|
|
if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) then |
|
|
|
|
bankItems[itemString] = min(bank[itemString] or soulboundBankCount, remainingNeed) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if gbank[itemString] and shortItems[itemString] then |
|
|
|
|
if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then |
|
|
|
|
gbankItems[itemString] = gbank[itemString] |
|
|
|
|
if gbank[itemString] then |
|
|
|
|
gbankItems[itemString] = min(gbank[itemString], remainingNeed) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if mail[itemString] and shortItems[itemString] then |
|
|
|
|
mailItems[itemString] = mail[itemString] |
|
|
|
|
end |
|
|
|
|
if bags[itemString] and shortItems[itemString] then |
|
|
|
|
if player ~= crafter then |
|
|
|
|
if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then |
|
|
|
|
bagItems[itemString] = bags[itemString] |
|
|
|
|
end |
|
|
|
|
if bags[itemString] and shortItems[itemString] and not IsSamePlayer(player, crafter) then |
|
|
|
|
if remainingNeed > 0 then |
|
|
|
|
bagItems[itemString] = min(bags[itemString], remainingNeed) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
@ -223,7 +229,7 @@
|
|
|
|
|
tinsert(task, { taskType = L["Mail Items"], items = bagItems }) |
|
|
|
|
end |
|
|
|
|
if next(task) then |
|
|
|
|
tinsert(sources, { sourceName = player, isCrafter = player == crafter, isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) |
|
|
|
|
tinsert(sources, { sourceName = player, isCrafter = IsSamePlayer(player, crafter), isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|