Skip to content

Commit 52201c7

Browse files
committed
Added support for TWW S2 tokens, more tokens will be added later
1 parent a0fb114 commit 52201c7

File tree

2 files changed

+84
-12
lines changed

2 files changed

+84
-12
lines changed

TransmogUpgradeMaster.lua

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ local ITEM_MOD_ID_TIERS = {
4040
[1] = TIER_HEROIC,
4141
[3] = TIER_MYTHIC,
4242
}
43+
local ITEM_CONTEXT_TIERS = {
44+
[Enum.ItemCreationContext.RaidFinder] = TIER_LFR,
45+
[Enum.ItemCreationContext.RaidNormal] = TIER_NORMAL,
46+
[Enum.ItemCreationContext.RaidHeroic] = TIER_HEROIC,
47+
[Enum.ItemCreationContext.RaidMythic] = TIER_MYTHIC,
48+
}
4349

4450
local CLOTH = Enum.ItemArmorSubclass.Cloth
4551
local LEATHER = Enum.ItemArmorSubclass.Leather
@@ -125,15 +131,15 @@ end
125131
--- @param classMask number
126132
--- @return number[] classIDList
127133
function TUM:ConvertClassMaskToClassList(classMask)
128-
local classIDList = {};
129-
for classID = 1, GetNumClasses() do
130-
local classAllowed = FlagsUtil.IsSet(classMask, bit.lshift(1, (classID - 1)));
131-
if classAllowed then
132-
table.insert(classIDList, classID);
133-
end
134-
end
135-
136-
return classIDList;
134+
local classIDList = {};
135+
for classID = 1, GetNumClasses() do
136+
local classAllowed = FlagsUtil.IsSet(classMask, bit.lshift(1, (classID - 1)));
137+
if classAllowed then
138+
table.insert(classIDList, classID);
139+
end
140+
end
141+
142+
return classIDList;
137143
end
138144

139145
function TUM:InitItemSourceMap()
@@ -198,6 +204,30 @@ function TUM:InitItemSourceMap()
198204
end)
199205
end
200206

207+
function TUM:IsToken(itemID)
208+
return not not self.data.tokens[itemID]
209+
end
210+
211+
--- @return nil|{season: number, classList: number[], tier: number|nil, slot: number}
212+
function TUM:GetTokenInfo(itemID, itemLink)
213+
local tokenInfo = self.data.tokens[itemID]
214+
if not tokenInfo then
215+
return nil
216+
end
217+
218+
local _, data = LinkUtil.ExtractLink(itemLink)
219+
local parts = strsplittable(':', data)
220+
local itemCreationContext = tonumber(parts[12])
221+
local tier = ITEM_CONTEXT_TIERS[itemCreationContext] or nil
222+
223+
return {
224+
season = tokenInfo.season,
225+
tier = tier,
226+
slot = tokenInfo.slot,
227+
classList = tokenInfo.classList,
228+
}
229+
end
230+
201231
local BONUS_ID_OFFSET = 13;
202232
function TUM:GetItemSeason(itemLink)
203233
if self:IsCurrentSeasonItem(itemLink) then
@@ -206,6 +236,10 @@ function TUM:GetItemSeason(itemLink)
206236

207237
local _, data = LinkUtil.ExtractLink(itemLink);
208238
local parts = strsplittable(':', data);
239+
local itemID = tonumber(parts[1]);
240+
local tokenInfo = self.data.tokens[itemID];
241+
if tokenInfo then return tokenInfo.season; end
242+
209243
local numBonusIDs = tonumber(parts[BONUS_ID_OFFSET]) or 0;
210244
for index = (BONUS_ID_OFFSET + 1), (BONUS_ID_OFFSET + numBonusIDs) do
211245
local bonusID = tonumber(parts[index]);
@@ -344,7 +378,8 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
344378
local catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem = false, false, false
345379

346380
local itemID = tonumber(itemLink:match("item:(%d+)"))
347-
if not itemID or not C_Item.IsDressableItemByID(itemID) then
381+
local isToken = itemID and self:IsToken(itemID)
382+
if not itemID or (not isToken and not C_Item.IsDressableItemByID(itemID)) then
348383
return canCatalyse, canUpgradeToNextBreakpoint,
349384
catalystMissing, catalystUpgradeMissing, upgradeMissing,
350385
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
@@ -381,6 +416,19 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
381416
tryInsert(debugLines, 'itemModID: ' .. tostring(sourceInfo and sourceInfo.itemModID))
382417
end
383418

419+
local tokenInfo = isToken and self:GetTokenInfo(itemID, itemLink)
420+
if tokenInfo then
421+
if not tokenInfo.classList[classID] then
422+
tryInsert(debugLines, 'item is a token for another class')
423+
424+
return canCatalyse, canUpgradeToNextBreakpoint,
425+
catalystMissing, catalystUpgradeMissing, upgradeMissing,
426+
catalystFromOtherItem, catalystUpgradeFromOtherItem, upgradeFromOtherItem
427+
end
428+
429+
currentTier = tokenInfo.tier or currentTier
430+
end
431+
384432
if currentTier == 0 then
385433
local sourceIDs = self:GetSourceIDsForItemID(itemID)
386434
local index = tIndexOf(sourceIDs or {}, sourceID)
@@ -396,7 +444,7 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
396444
end
397445
tryInsert(debugLines, 'currentTier: ' .. tostring(currentTier))
398446

399-
local itemSlot = C_Item.GetItemInventoryTypeByID(itemLink)
447+
local itemSlot = tokenInfo and tokenInfo.slot or C_Item.GetItemInventoryTypeByID(itemLink)
400448
if itemSlot == Enum.InventoryType.IndexRobeType then
401449
-- robes catalyse into chest pieces
402450
itemSlot = Enum.InventoryType.IndexChestType
@@ -427,7 +475,7 @@ function TUM:IsAppearanceMissing(itemLink, classID, debugLines)
427475

428476
local isCatalysed = self:IsItemCatalysed(itemID)
429477
tryInsert(debugLines, 'isCatalysed: ' .. tostring(isCatalysed))
430-
canCatalyse = not isCatalysed and not isConquestPvpItem and self:IsCatalystSlot(itemSlot) and self:IsValidArmorTypeForClass(itemLink, classID)
478+
canCatalyse = tokenInfo or (not isCatalysed and not isConquestPvpItem and self:IsCatalystSlot(itemSlot) and self:IsValidArmorTypeForClass(itemLink, classID))
431479
if canCatalyse then
432480
local catalystCollected, catalystUpgradeCollected
433481
local playerSets = self:GetSetsForClass(classID, seasonID)

data.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,30 @@ data.catalystItems = {
209209
},
210210
}
211211

212+
data.tokens = {
213+
-- TWW S2
214+
[228799] = { season = 14, slot = Enum.InventoryType.IndexChestType, classList = { [6] = true, [12] = true, [9] = true } }, -- Dreadful Greased Gallybux
215+
[228803] = { season = 14, slot = Enum.InventoryType.IndexHandType, classList = { [6] = true, [12] = true, [9] = true } }, -- Dreadful Bloody Gallybux
216+
[228807] = { season = 14, slot = Enum.InventoryType.IndexHeadType, classList = { [6] = true, [12] = true, [9] = true } }, -- Dreadful Gilded Gallybux
217+
[228811] = { season = 14, slot = Enum.InventoryType.IndexLegsType, classList = { [6] = true, [12] = true, [9] = true } }, -- Dreadful Rusty Gallybux
218+
[228815] = { season = 14, slot = Enum.InventoryType.IndexShoulderType, classList = { [6] = true, [12] = true, [9] = true } }, -- Dreadful Polished Gallybux
219+
[228800] = { season = 14, slot = Enum.InventoryType.IndexChestType, classList = { [11] = true, [3] = true, [8] = true } }, -- Mystic Greased Gallybux
220+
[228804] = { season = 14, slot = Enum.InventoryType.IndexHandType, classList = { [11] = true, [3] = true, [8] = true } }, -- Mystic Bloody Gallybux
221+
[228808] = { season = 14, slot = Enum.InventoryType.IndexHeadType, classList = { [11] = true, [3] = true, [8] = true } }, -- Mystic Gilded Gallybux
222+
[228812] = { season = 14, slot = Enum.InventoryType.IndexLegsType, classList = { [11] = true, [3] = true, [8] = true } }, -- Mystic Rusty Gallybux
223+
[228816] = { season = 14, slot = Enum.InventoryType.IndexShoulderType, classList = { [11] = true, [3] = true, [8] = true } }, -- Mystic Polished Gallybux
224+
[228801] = { season = 14, slot = Enum.InventoryType.IndexChestType, classList = { [2] = true, [5] = true, [7] = true } }, -- Venerated Greased Gallybux
225+
[228805] = { season = 14, slot = Enum.InventoryType.IndexHandType, classList = { [2] = true, [5] = true, [7] = true } }, -- Venerated Bloody Gallybux
226+
[228809] = { season = 14, slot = Enum.InventoryType.IndexHeadType, classList = { [2] = true, [5] = true, [7] = true } }, -- Venerated Gilded Gallybux
227+
[228813] = { season = 14, slot = Enum.InventoryType.IndexLegsType, classList = { [2] = true, [5] = true, [7] = true } }, -- Venerated Rusty Gallybux
228+
[228817] = { season = 14, slot = Enum.InventoryType.IndexShoulderType, classList = { [2] = true, [5] = true, [7] = true } }, -- Venerated Polished Gallybux
229+
[228802] = { season = 14, slot = Enum.InventoryType.IndexChestType, classList = { [13] = true, [10] = true, [4] = true, [1] = true } }, -- Zenith Greased Gallybux
230+
[228806] = { season = 14, slot = Enum.InventoryType.IndexHandType, classList = { [13] = true, [10] = true, [4] = true, [1] = true } }, -- Zenith Bloody Gallybux
231+
[228810] = { season = 14, slot = Enum.InventoryType.IndexHeadType, classList = { [13] = true, [10] = true, [4] = true, [1] = true } }, -- Zenith Gilded Gallybux
232+
[228814] = { season = 14, slot = Enum.InventoryType.IndexLegsType, classList = { [13] = true, [10] = true, [4] = true, [1] = true } }, -- Zenith Rusty Gallybux
233+
[228818] = { season = 14, slot = Enum.InventoryType.IndexShoulderType, classList = { [13] = true, [10] = true, [4] = true, [1] = true } }, -- Zenith Polished Gallybux
234+
};
235+
212236
--- @type table<number, number> # [itemID] = seasonID
213237
data.catalystItemByID = {};
214238
do

0 commit comments

Comments
 (0)