@@ -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
4450local CLOTH = Enum .ItemArmorSubclass .Cloth
4551local LEATHER = Enum .ItemArmorSubclass .Leather
@@ -125,15 +131,15 @@ end
125131--- @param classMask number
126132--- @return number[] classIDList
127133function 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 ;
137143end
138144
139145function TUM :InitItemSourceMap ()
@@ -198,6 +204,30 @@ function TUM:InitItemSourceMap()
198204 end )
199205end
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+
201231local BONUS_ID_OFFSET = 13 ;
202232function 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 )
0 commit comments