@@ -3,16 +3,17 @@ local MPT = select(2, ...);
33--- @class MPT_Util
44local Util = {};
55MPT .Util = Util ;
6+ local Data = MPT .Data ;
67
78-- whether to support affix-specific scores
89Util .AFFIX_SPECIFIC_SCORES = false ;
910
1011local scoreRarityColors = {
11- colors = {ITEM_STANDARD_COLOR , ITEM_GOOD_COLOR , ITEM_SUPERIOR_COLOR , ITEM_EPIC_COLOR , ITEM_LEGENDARY_COLOR },
12- overallScore = {0 , 1000 , 1500 , 1800 , 2200 },
13- level = {0 , 4 , 7 , 10 , 15 },
14- dungeonAffixScore = {0 , 63 , 94 , 113 , 138 },
15- dungeonOverallScore = {0 , 125 , 188 , 225 , 275 },
12+ colors = { ITEM_STANDARD_COLOR , ITEM_GOOD_COLOR , ITEM_SUPERIOR_COLOR , ITEM_EPIC_COLOR , ITEM_LEGENDARY_COLOR },
13+ overallScore = { 0 , 1000 , 1500 , 1800 , 2200 },
14+ level = { 0 , 4 , 7 , 10 , 15 },
15+ dungeonAffixScore = { 0 , 63 , 94 , 113 , 138 },
16+ dungeonOverallScore = { 0 , 125 , 188 , 225 , 275 },
1617};
1718
1819--- @return ColorMixin
@@ -49,6 +50,16 @@ function Util:GetRarityColor(score, scoreType)
4950 return colors [# colors ];
5051end
5152
53+ --- @param activityID number
54+ --- @return number | nil challengeMapID
55+ --- @return string fullName
56+ --- @return boolean isMythicPlusActivity
57+ function Util :GetMapInfoByLfgActivityID (activityID )
58+ local activityInfo = C_LFGList .GetActivityInfoTable (activityID );
59+
60+ return Data .ActivityIdToChallengeMapIdMap [activityID ], activityInfo .fullName , activityInfo .isMythicPlusActivity ;
61+ end
62+
5263function Util :ExtractTooltipLines (tooltip )
5364 local linesLeft , linesRight = {}, {};
5465 local i = 0 ;
@@ -67,9 +78,10 @@ function Util:ExtractTooltipLines(tooltip)
6778 if not left and not right then break ; end
6879 local leftR , leftG , leftB , _ = lineLeft :GetTextColor ();
6980 local rightR , rightG , rightB , _ = lineRight :GetTextColor ();
70- table.insert (linesLeft , {text = left , r = leftR , g = leftG , b = leftB , wrap = leftWrap });
71- table.insert (linesRight , {text = right , r = rightR , g = rightG , b = rightB });
81+ table.insert (linesLeft , { text = left , r = leftR , g = leftG , b = leftB , wrap = leftWrap , });
82+ table.insert (linesRight , { text = right , r = rightR , g = rightG , b = rightB , });
7283 end
84+
7385 return linesLeft , linesRight ;
7486end
7587
@@ -111,18 +123,18 @@ function Util:GetOverallInfoByMapId(mapId, includeAffixInfo)
111123 local isCurrentAffix = affixInfo .name == localizedAffixName ;
112124 if isCurrentAffix then
113125 currentAffixInfo = {
114- level = affixInfo .level ,
115- levelColor = affixInfo .overTime and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR ,
116- score = affixInfo .score ,
117- scoreColor = self :GetRarityColorDungeonAffixScore (affixInfo .score or 0 ),
118- };
126+ level = affixInfo .level ,
127+ levelColor = affixInfo .overTime and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR ,
128+ score = affixInfo .score ,
129+ scoreColor = self :GetRarityColorDungeonAffixScore (affixInfo .score or 0 ),
130+ };
119131 else
120132 secondaryAffixInfo = {
121- level = affixInfo .level ,
122- levelColor = affixInfo .overTime and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR ,
123- score = affixInfo .score ,
124- scoreColor = self :GetRarityColorDungeonAffixScore (affixInfo .score or 0 ),
125- };
133+ level = affixInfo .level ,
134+ levelColor = affixInfo .overTime and GRAY_FONT_COLOR or HIGHLIGHT_FONT_COLOR ,
135+ score = affixInfo .score ,
136+ scoreColor = self :GetRarityColorDungeonAffixScore (affixInfo .score or 0 ),
137+ };
126138 end
127139 end
128140 end
@@ -160,16 +172,18 @@ end
160172function Util :GetLocalizedAffixName ()
161173 local affixIDs = C_MythicPlus .GetCurrentAffixes ();
162174 if not affixIDs then return nil ; end
175+
163176 local tyrannicalOrFortifiedAffix = affixIDs [1 ];
164177 if not tyrannicalOrFortifiedAffix or not tyrannicalOrFortifiedAffix .id then return nil ; end
165- local name = C_ChallengeMode . GetAffixInfo ( tyrannicalOrFortifiedAffix . id );
166- return name ;
178+
179+ return C_ChallengeMode . GetAffixInfo ( tyrannicalOrFortifiedAffix . id ) ;
167180end
168181
169182function Util :GetAffixInfoByMapId (mapId )
170183 local localizedAffixName = self :GetLocalizedAffixName ();
171184 local affixInfos = C_MythicPlus .GetSeasonBestAffixScoreInfoForMap (mapId );
172185 if not affixInfos then return nil ; end
186+
173187 for _ , affixInfo in pairs (affixInfos ) do
174188 if affixInfo and affixInfo .name == localizedAffixName then
175189 return {
@@ -180,6 +194,7 @@ function Util:GetAffixInfoByMapId(mapId)
180194 };
181195 end
182196 end
197+
183198 return nil ;
184199end
185200
@@ -228,7 +243,7 @@ local scoreCache = {};
228243function Util :GetUnitScores (unit )
229244 local summary = C_PlayerInfo .GetPlayerMythicPlusRatingSummary (unit );
230245 local guid = UnitGUID (unit );
231- if not summary then
246+ if not summary or not guid then
232247 -- data is only available when you're somewhat close to the player, so cache it so it stays available when moving further away
233248 return guid and scoreCache [guid ] or nil ;
234249 end
0 commit comments