Skip to content

Commit 37d9fc2

Browse files
committed
Add weekly reward buckets and world boss tracking
* Fixed a lot of the weekly rewards * Fixed how the Delves are tracking * Fixed how the Vault is tracking * Corrected World Boss Tracking
1 parent 0b17b9e commit 37d9fc2

11 files changed

Lines changed: 519 additions & 155 deletions

File tree

Core.lua

Lines changed: 105 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,38 @@ function MR:RegisterModule(def)
170170
self._orderedModulesCache = nil
171171
end
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+
173205
function 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
827871
local 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+
853913
function 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()
886953
end
887954

888955
function 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
12481334
end
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
12541350
end
@@ -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"])

Locales/enUS.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ L["Vault_Dungeon_Label"] = "|cff00ccffDungeon:|r"
145145
L["Vault_TT_Dungeon_Header"] = "Dungeons this week: %d"
146146
L["Vault_World_Label"] = "|cffc8956cWorld:|r"
147147
L["Vault_TT_World_Header"] = "World activities this week: %d"
148-
L["Vault_TT_Slot_Unlocked"] = " Slot %d |cff40e080✓ Unlocked|r"
148+
L["Vault_TT_Slot_Unlocked"] = " Slot %d |cff40e080Unlocked|r"
149149
L["Vault_TT_Slot_Progress"] = " Slot %d %d / %d needed"
150150
L["Myth"] = "Myth"
151151
L["Hero"] = "Hero"
@@ -395,9 +395,9 @@ L["Weekly_SeasonTitle"] = "Season 1 Weeklies"
395395
L["Weekly_Abundance_Label"] = "|cff2ae7c6Weekly: Abundance:|r"
396396
L["Weekly_Legends_Label"] = "|cff2ae7c6Lost Legends:|r"
397397
L["Weekly_Soiree_Label"] = "|cff2ae7c6Saltheril's Soiree:|r"
398-
L["Weekly_Soiree_Note"] = "Attend Saltheril's Soiree and complete 2 favors for the nobles. Rewards a Spark of Radiance or Weekly Cache."
398+
L["Weekly_Soiree_Note"] = "Attend Saltheril's Soiree and complete 2 favors for the nobles."
399399
L["Weekly_Fortify_Label"] = "|cff2ae7c6Fortify the Runestones:|r"
400-
L["Weekly_Fortify_Note"] = "Complete the Fortify the Runestones quest matching your chosen subfaction."
400+
L["Weekly_Fortify_Note"] = "Complete the Fortify the Runestones quest matching your chosen subfaction. Rewards a Weekly Cache."
401401
L["Weekly_Unity_Label"] = "|cff2ae7c6Unity Against the Void:|r"
402402
L["Weekly_Unity_Note"] = "Choose one activity per week. Completing it rewards an Apex Cache."
403403
L["Weekly_SA_Label"] = "|cff2ae7c6Special Assignment:|r"
@@ -582,3 +582,16 @@ L["Currency_VoidlightMarl_Label"] = "|cffc792ffVoidlight Marl:|r"
582582
L["Currency_RestoredCofferKey_Label"] = "|cffe8c96eRestored Coffer Key:|r"
583583
L["Currency_SparkRadiance_Label"] = "|cffffb347Spark of Radiance:|r"
584584
L["Currency_Undercoin_Label"] = "|cffd8c36aUndercoin:|r"
585+
L["WB_Luashal_Label"] = "|cffff4444Lu'ashal:|r"
586+
L["WB_Luashal_Note"] = "World Boss - Eversong Woods"
587+
L["WB_Cragpine_Label"] = "|cffff4444Cragpine:|r"
588+
L["WB_Cragpine_Note"] = "World Boss - Zul'Aman"
589+
L["WB_Thormbelan_Label"] = "|cffff4444Thorm'belan:|r"
590+
L["WB_Thormbelan_Note"] = "World Boss - Harandar"
591+
L["WB_Predaxas_Label"] = "|cffff4444Predaxas:|r"
592+
L["WB_Predaxas_Note"] = "World Boss - Voidstorm"
593+
L["WB_Timer_Active"] = "Active - %s"
594+
L["WB_Timer_Done"] = "Done - %s"
595+
L["WB_Timer_Next"] = "Next - %s"
596+
L["WB_Timer_DaysHours"] = "%dd %dh"
597+
L["WB_Timer_HoursMins"] = "%dh %dm"

Modules/Activities.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MR:RegisterModule({
1313
label = L["Act_Stormarion_Label"],
1414
max = 1,
1515
note = L["Act_Stormarion_Note"],
16-
questIds = { 90962 },
16+
questIds = { 90962 },
1717
timerEpoch = 1772370083,
1818
timerInterval = 1800,
1919
timerDuration = 900,

Modules/Delves.lua

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local SCAN_THROTTLE = 2
2-
local DELVE_ACTIVITY_TYPE = 4
32
local DELVE_T8_MIN_LEVEL = 8
43
local DELVERS_BOUNTY_ITEM = 233071
54

@@ -114,19 +113,25 @@ MR:RegisterModule({
114113
if (now - lastScan) < SCAN_THROTTLE then return end
115114
lastScan = now
116115

117-
if C_WeeklyRewards and C_WeeklyRewards.GetActivities then
118-
local activities = C_WeeklyRewards.GetActivities()
119-
if activities then
120-
for _, act in ipairs(activities) do
121-
if act.type == DELVE_ACTIVITY_TYPE then
122-
local runs = act.progress or 0
123-
local t8 = ((act.level or 0) >= DELVE_T8_MIN_LEVEL) and 1 or 0
124-
if mdb["delve_runs"] ~= runs then mdb["delve_runs"] = runs end
125-
if mdb["delve_t8"] ~= t8 then mdb["delve_t8"] = t8 end
126-
break
127-
end
116+
local buckets = MR.GetWeeklyRewardActivityBuckets and MR:GetWeeklyRewardActivityBuckets() or nil
117+
if buckets and buckets.world and buckets.world[1] then
118+
local bestRuns = 0
119+
local bestLevel = 0
120+
for _, act in ipairs(buckets.world) do
121+
if (act.progress or 0) > bestRuns then
122+
bestRuns = act.progress or 0
123+
end
124+
if (act.level or 0) > bestLevel then
125+
bestLevel = act.level or 0
128126
end
129127
end
128+
129+
local t8 = (bestLevel >= DELVE_T8_MIN_LEVEL) and 1 or 0
130+
if mdb["delve_runs"] ~= bestRuns then mdb["delve_runs"] = bestRuns end
131+
if mdb["delve_t8"] ~= t8 then mdb["delve_t8"] = t8 end
132+
else
133+
if mdb["delve_runs"] ~= 0 then mdb["delve_runs"] = 0 end
134+
if mdb["delve_t8"] ~= 0 then mdb["delve_t8"] = 0 end
130135
end
131136

132137
local bountyCount = C_Item.GetItemCount and C_Item.GetItemCount(DELVERS_BOUNTY_ITEM) or 0

Modules/GreatVault.lua

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local DUNGEON_TIERS = {
55
{ 7, L["Hero"], "#0070dd" },
66
{ 4, L["Champion"], "#f1c232" },
77
{ 2, L["Veteran"], "#1eff00" },
8-
{ 0, L["Follower"], "#b7b7b7" },
8+
{ 0, L["Mythic"], "#b7b7b7" },
99
}
1010

1111
local RAID_DIFF = {
@@ -17,6 +17,10 @@ local RAID_DIFF = {
1717

1818
local DIFF_RANK = { [17]=1, [14]=2, [15]=3, [16]=4 }
1919

20+
local function UpdateMax(current, candidate)
21+
return math.max(current or 0, candidate or 0)
22+
end
23+
2024
local function GetDungeonTier(level)
2125
level = level or 0
2226
for _, t in ipairs(DUNGEON_TIERS) do
@@ -27,7 +31,7 @@ end
2731

2832
local function GetRaidDiffName(diffId)
2933
local d = RAID_DIFF[diffId]
30-
return d and d[1] or L["Normal"], d and d[2] or "#1eff00"
34+
return d and d[1] or L["LFR"], d and d[2] or "#b7b7b7"
3135
end
3236

3337
local function SlotLine(tt, slotNum, count, threshold)
@@ -46,37 +50,43 @@ MR:RegisterModule({
4650
defaultOpen = true,
4751

4852
onScan = function(mod)
49-
if not C_WeeklyRewards or not C_WeeklyRewards.GetActivities then return end
50-
local activities = C_WeeklyRewards.GetActivities()
51-
if not activities then return end
5253
local db = MR.db.char.progress
5354
if not db[mod.key] then db[mod.key] = {} end
5455
local vd = db[mod.key]
56+
local buckets = MR.GetWeeklyRewardActivityBuckets and MR:GetWeeklyRewardActivityBuckets() or nil
57+
if not buckets then return end
5558

5659
vd["vault_d_progress"] = 0
5760
vd["vault_d_max_level"] = 0
5861
vd["vault_r_progress"] = 0
59-
vd["vault_r_diff_id"] = 14
62+
vd["vault_r_diff_id"] = nil
6063
vd["vault_w_progress"] = 0
6164

62-
for _, act in ipairs(activities) do
63-
if act.type == 1 then
64-
vd["vault_d_progress"] = act.progress or 0
65-
if (act.level or 0) > (vd["vault_d_max_level"] or 0) then
66-
vd["vault_d_max_level"] = act.level or 0
67-
end
68-
elseif act.type == 3 then
69-
local prog = act.progress or 0
70-
if prog > vd["vault_r_progress"] then
71-
vd["vault_r_progress"] = prog
72-
end
73-
local newRank = DIFF_RANK[act.difficultyId]
74-
if newRank and newRank > (DIFF_RANK[vd["vault_r_diff_id"]] or 0) then
75-
vd["vault_r_diff_id"] = act.difficultyId
76-
end
77-
elseif act.type == 4 then
78-
vd["vault_w_progress"] = act.progress or 0
65+
for _, act in ipairs(buckets.dungeon) do
66+
vd["vault_d_progress"] = UpdateMax(vd["vault_d_progress"], act.progress)
67+
if (act.level or 0) > (vd["vault_d_max_level"] or 0) then
68+
vd["vault_d_max_level"] = act.level or 0
69+
end
70+
end
71+
72+
for _, act in ipairs(buckets.raid) do
73+
local prog = act.progress or 0
74+
vd["vault_r_progress"] = UpdateMax(vd["vault_r_progress"], prog)
75+
local difficultyId = act.difficultyId
76+
if (not difficultyId) and C_WeeklyRewards and C_WeeklyRewards.GetDifficultyIDForActivityTier and act.activityTierID then
77+
difficultyId = C_WeeklyRewards.GetDifficultyIDForActivityTier(act.activityTierID)
7978
end
79+
if (not difficultyId or not DIFF_RANK[difficultyId]) and DIFF_RANK[act.level] then
80+
difficultyId = act.level
81+
end
82+
local newRank = DIFF_RANK[difficultyId]
83+
if newRank and newRank > (DIFF_RANK[vd["vault_r_diff_id"]] or 0) then
84+
vd["vault_r_diff_id"] = difficultyId
85+
end
86+
end
87+
88+
for _, act in ipairs(buckets.world) do
89+
vd["vault_w_progress"] = UpdateMax(vd["vault_w_progress"], act.progress)
8090
end
8191

8292
if vd["vault_r_progress"] > 0 then

0 commit comments

Comments
 (0)