@@ -170,6 +170,38 @@ function MR:RegisterModule(def)
170170 self ._orderedModulesCache = nil
171171end
172172
173+ function MR :GetWeeklyRewardActivityBuckets ()
174+ local buckets = {
175+ dungeon = {},
176+ raid = {},
177+ world = {},
178+ }
179+
180+ if not (C_WeeklyRewards and C_WeeklyRewards .GetActivities ) then
181+ return buckets
182+ end
183+
184+ local activities = C_WeeklyRewards .GetActivities ()
185+ if not activities then
186+ return buckets
187+ end
188+
189+ for _ , activity in ipairs (activities ) do
190+ if activity .type == 1 then
191+ table.insert (buckets .dungeon , activity )
192+ elseif activity .type == 3 then
193+ table.insert (buckets .raid , activity )
194+ elseif activity .type == 6 then
195+ table.insert (buckets .world , activity )
196+ elseif activity .type == 4 and # buckets .world == 0 then
197+ -- Fallback for older clients/builds where delves/world vault data used type 4.
198+ table.insert (buckets .world , activity )
199+ end
200+ end
201+
202+ return buckets
203+ end
204+
173205function MR :GetProgress (moduleKey , rowKey )
174206 local m = self .db .char .progress [moduleKey ]
175207 return m and m [rowKey ] or 0
@@ -729,14 +761,26 @@ function MR:Scan()
729761
730762 for _ , mod in ipairs (self .modules ) do
731763 for _ , row in ipairs (mod .rows ) do
732- if row .questIds then
764+ if row .questIds and not row . turnInTracked then
733765 local done = 0
734766 for _ , qid in ipairs (row .questIds ) do
735767 if C_QuestLog .IsQuestFlaggedCompleted (qid ) then done = done + 1 end
736768 end
737769 if WriteProgress (progress , mod .key , row .key , math.min (done , row .max or done ), self .db .char .manualOverrides ) then
738770 dirty = true
739771 end
772+ elseif row .questIds and row .turnInTracked and row .allowQuestFlagBackfill then
773+ local currentValue = progress [mod .key ] and progress [mod .key ][row .key ] or 0
774+ if currentValue <= 0 then
775+ for _ , qid in ipairs (row .questIds ) do
776+ if C_QuestLog .IsQuestFlaggedCompleted (qid ) then
777+ if WriteProgress (progress , mod .key , row .key , 1 , self .db .char .manualOverrides ) then
778+ dirty = true
779+ end
780+ break
781+ end
782+ end
783+ end
740784 end
741785 if row .currencyId then
742786 local info = C_CurrencyInfo .GetCurrencyInfo (row .currencyId )
@@ -827,17 +871,12 @@ end
827871local TURN_IN_COMPLETIONS = {
828872 [89268 ] = { mod = " s1_weekly" , row = " lost_legends" },
829873 [89289 ] = { mod = " s1_weekly" , row = " saltherils_soiree" },
830- [93889 ] = { mod = " s1_weekly" , row = " saltherils_soiree" },
831874 [91966 ] = { mod = " s1_weekly" , row = " saltherils_soiree" },
832875 [90573 ] = { mod = " s1_weekly" , row = " fortify_runestones" },
833876 [90574 ] = { mod = " s1_weekly" , row = " fortify_runestones" },
834877 [90575 ] = { mod = " s1_weekly" , row = " fortify_runestones" },
835878 [90576 ] = { mod = " s1_weekly" , row = " fortify_runestones" },
836879 [93744 ] = { mod = " s1_weekly" , row = " unity_against_void" },
837- [93909 ] = { mod = " s1_weekly" , row = " unity_against_void" },
838- [93911 ] = { mod = " s1_weekly" , row = " unity_against_void" },
839- [93912 ] = { mod = " s1_weekly" , row = " unity_against_void" },
840- [93910 ] = { mod = " s1_weekly" , row = " unity_against_void" },
841880 [90962 ] = { mod = " midnight_activities" , row = " stormarion_assault" },
842881 [94835 ] = { mod = " pvp_weeklies" , row = " early_training" },
843882}
@@ -850,7 +889,35 @@ local WEEKLY_RESET_SCHEDULE = {
850889 [5 ] = { weekday = 4 , hour = 3 },
851890}
852891
892+ local DAY_SECONDS = 24 * 60 * 60
893+ local WEEK_SECONDS = 7 * DAY_SECONDS
894+
895+ local function GetResetTimestampFromCountdown (secondsUntilReset , cycleSeconds )
896+ if type (secondsUntilReset ) ~= " number" then
897+ return nil
898+ end
899+
900+ secondsUntilReset = math.floor (secondsUntilReset )
901+ if secondsUntilReset < 0 then
902+ return nil
903+ end
904+
905+ local maxExpected = cycleSeconds + (2 * 60 * 60 )
906+ if secondsUntilReset > maxExpected then
907+ return nil
908+ end
909+
910+ return GetServerTime () + secondsUntilReset - cycleSeconds
911+ end
912+
853913function MR :GetLastDailyTimestamp ()
914+ if C_DateAndTime and C_DateAndTime .GetSecondsUntilDailyReset then
915+ local ts = GetResetTimestampFromCountdown (C_DateAndTime .GetSecondsUntilDailyReset (), DAY_SECONDS )
916+ if ts then
917+ return ts
918+ end
919+ end
920+
854921 local cal = C_DateAndTime .GetCurrentCalendarTime ()
855922 if not cal then return nil end
856923 local now = GetServerTime ()
@@ -886,6 +953,13 @@ function MR:DoDailyReset()
886953end
887954
888955function MR :GetLastResetTimestamp ()
956+ if C_DateAndTime and C_DateAndTime .GetSecondsUntilWeeklyReset then
957+ local ts = GetResetTimestampFromCountdown (C_DateAndTime .GetSecondsUntilWeeklyReset (), WEEK_SECONDS )
958+ if ts then
959+ return ts
960+ end
961+ end
962+
889963 local region = GetCurrentRegion () or 1
890964 local resetInfo = WEEKLY_RESET_SCHEDULE [region ]
891965 if not resetInfo then return nil end
@@ -1134,6 +1208,7 @@ function MR:OnEnable()
11341208
11351209 self :RegisterEvent (" UNIT_SPELLCAST_SUCCEEDED" , " OnSpellCast" )
11361210 self :RegisterEvent (" ENCOUNTER_END" , " OnEncounterEnd" )
1211+ self :RegisterEvent (" BOSS_KILL" , " OnBossKill" )
11371212 self :RegisterEvent (" PLAYER_ENTERING_WORLD" , " OnEnteringWorld" )
11381213
11391214 self :ScheduleRepeatingTimer (" CheckWeeklyReset" , 60 )
@@ -1147,6 +1222,17 @@ function MR:OnEnable()
11471222 local entry = TURN_IN_COMPLETIONS [questID ]
11481223 if not entry or not addon .db then return end
11491224 local ch = addon .db .char
1225+ local modProgress = ch .progress and ch .progress [entry .mod ]
1226+ if entry .mod == " s1_weekly" and entry .row == " saltherils_soiree" then
1227+ if not modProgress or modProgress [" soiree_active_quest" ] ~= questID then
1228+ return
1229+ end
1230+ modProgress [" soiree_completed_name" ] = modProgress [" soiree_active_name" ]
1231+ elseif entry .mod == " s1_weekly" and entry .row == " unity_against_void" then
1232+ if modProgress then
1233+ modProgress [" uatv_completed_branch_name" ] = modProgress [" uatv_branch_name" ]
1234+ end
1235+ end
11501236 if not ch .progress [entry .mod ] then ch .progress [entry .mod ] = {} end
11511237 ch .progress [entry .mod ][entry .row ] = 1
11521238 addon :RefreshUI ()
@@ -1247,8 +1333,18 @@ function MR:OnZoneChanged()
12471333 end
12481334end
12491335
1250- function MR :OnEncounterEnd (_ , _ , _ , _ , _ , success )
1336+ function MR :OnEncounterEnd (_ , _ , encounterName , _ , _ , success )
12511337 if success == 1 then
1338+ if encounterName and self .SyncCurrentWorldBossKillByName then
1339+ self :SyncCurrentWorldBossKillByName (encounterName )
1340+ end
1341+ self :ScheduleTimer (function () self :Scan () end , 1.5 )
1342+ end
1343+ end
1344+
1345+ function MR :OnBossKill (_ , bossName )
1346+ if bossName and self .SyncCurrentWorldBossKillByName then
1347+ self :SyncCurrentWorldBossKillByName (bossName )
12521348 self :ScheduleTimer (function () self :Scan () end , 1.5 )
12531349 end
12541350end
@@ -1266,8 +1362,8 @@ SlashCmdList["MIDROUTE"] = function(msg)
12661362 end
12671363 end
12681364
1269- if msg == " reset" then MR :DoWeeklyReset ()
1270- elseif msg == " lock" then
1365+ if msg == " reset" then MR :DoWeeklyReset ()
1366+ elseif msg == " lock" then
12711367 MR .db .profile .locked = true
12721368 if MR .frame then MR .frame :SetMovable (false ) end
12731369 print (L [" Frame_Locked" ])
0 commit comments