Skip to content

Commit 81ff99e

Browse files
committed
fix adding abandoned runs to history data
1 parent 9d7c1b0 commit 81ff99e

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

Data.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ MPT.maptoID = { -- MapChallengeMode = JournalInstance
8484
[382] = {1187, "Theater"},
8585
[391] = {1194, "Streets"},
8686
[392] = {1194, "Gambit"},
87-
8887
-- Dragonflight
8988

9089
[399] = {1202, "Ruby Pools"},

EventHandler.lua

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ function MPT:ToggleEventRegister(On)
3939
end
4040

4141
function MPT:EventHandler(e, ...) -- internal checks whether the event comes from addon comms. We don't want to allow blizzard events to be fired manually
42-
if e == "INSTANCE_ABANDON_VOTE_FINISHED" then
42+
if e == "INSTANCE_ABANDON_VOTE_FINISHED" and C_ChallengeMode.IsChallengeModeActive() then
4343
local success = ...
44-
print(success, "abandon vote finished", C_ChallengeMode.IsChallengeModeActive(), self.seasonID, self.cmap, self.level)
45-
end
46-
if e == "CHALLENGE_MODE_KEYSTONE_SLOTTED" and MPTSV.CloseBags then
44+
self:AddHistory(false, self.cmap, self.level, false, success)
45+
elseif e == "CHALLENGE_MODE_KEYSTONE_SLOTTED" and MPTSV.CloseBags then
4746
CloseAllBags()
4847
elseif e == "CHALLENGE_MODE_KEYSTONE_RECEPTABLE_OPEN" and MPTSV.KeySlot then
4948
local index = select(3, GetInstanceInfo())
@@ -109,12 +108,6 @@ function MPT:EventHandler(e, ...) -- internal checks whether the event comes fro
109108
elseif e == "CHALLENGE_MODE_START" then
110109
self:Init()
111110
self:ToggleEventRegister(true)
112-
elseif e == "INSTANCE_ABANDON_VOTE_FINISHED" and C_ChallengeMode.IsChallengeModeActive() then
113-
local success = ...
114-
if success then
115-
self:AddHistory(false, self.cmap, self.level, false, true) -- add as abandoned run
116-
end
117-
self:ToggleEventRegister(false)
118111
elseif e == "CHALLENGE_MODE_COMPLETED" then
119112
self:UpdateTimerBar(false, true, false)
120113
self:UpdateEnemyForces(false, false, true)

PBData.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function MPT:AddCharacterHistory(tryagain)
4444
if not MPTSV.History then MPTSV.History = {} end
4545
if not MPTSV.History[self.seasonID] then MPTSV.History[self.seasonID] = {} end
4646
-- clear current character data to avoid duplicates
47+
local olddata = MPTSV.History[self.seasonID][G] and CopyTable(MPTSV.History[self.seasonID][G]) -- need this to keep abandoned data
4748
MPTSV.History[self.seasonID][G] = {name = UnitName("player"), realm = GetNormalizedRealmName(), class = select(2, UnitClass("player"))}
4849
for i, v in ipairs(data) do
4950
local cmap = v.mapChallengeModeID
@@ -52,8 +53,8 @@ function MPT:AddCharacterHistory(tryagain)
5253
local intime = v.completed
5354
-- only add runs from dungeons of the current season. Might be relevant for remix?
5455
if self.SeasonData[self.seasonID] and self.SeasonData[self.seasonID].Dungeons and tContains(self.SeasonData[self.seasonID].Dungeons, cmap) then
55-
if not MPTSV.History[self.seasonID][G][cmap] then MPTSV.History[self.seasonID][G][cmap] = {intime = 0, depleted = 0, highestrun = 0, abandoned = 0} end
56-
if not MPTSV.History[self.seasonID][G][cmap][level] then MPTSV.History[self.seasonID][G][cmap][level] = {intime = 0, depleted = 0, abandoned = 0} end
56+
if not MPTSV.History[self.seasonID][G][cmap] then MPTSV.History[self.seasonID][G][cmap] = {intime = 0, depleted = 0, highestrun = 0, abandoned = (olddata and olddata[cmap] and olddata[cmap].abandoned) or 0} end
57+
if not MPTSV.History[self.seasonID][G][cmap][level] then MPTSV.History[self.seasonID][G][cmap][level] = {intime = 0, depleted = 0, abandoned = (olddata and olddata[cmap] and olddata[cmap][level] and olddata[cmap][level].abandoned) or 0} end
5758
if not MPTSV.History[self.seasonID][G].keys then MPTSV.History[self.seasonID][G].keys = {} end
5859
MPTSV.History[self.seasonID][G].keys[i] = true
5960
self:AddHistory(time, cmap, level, intime, false)
@@ -65,13 +66,12 @@ function MPT:AddHistory(time, cmap, level, intime, abandoned) -- abandoned runs
6566
local G = UnitGUID("player")
6667
if abandoned and level and cmap then
6768
if not MPTSV.History[self.seasonID] then MPTSV.History[self.seasonID] = {} end
68-
if (not self.SeasonData[self.seasonID]) or (not self.SeasonData[self.seasonID].Dungeons) or (not t.contains(self.SeasonData[self.seasonID].Dungeons, cmap)) then return end -- only add runs from dungeons of the current season
69+
if (not self.SeasonData[self.seasonID]) or (not self.SeasonData[self.seasonID].Dungeons) or (not tContains(self.SeasonData[self.seasonID].Dungeons, cmap)) then return end -- only add runs from dungeons of the current season
6970
if not MPTSV.History[self.seasonID][G] then MPTSV.History[self.seasonID][G] = {name = UnitName("player"), realm = GetNormalizedRealmName(), class = select(3, UnitClass("player"))} end
7071
if not MPTSV.History[self.seasonID][G][cmap] then MPTSV.History[self.seasonID][G][cmap] = {intime = 0, depleted = 0, highestrun = 0, abandoned = 0} end
7172
if not MPTSV.History[self.seasonID][G][cmap][level] then MPTSV.History[self.seasonID][G][cmap][level] = {intime = 0, depleted = 0, abandoned = 0} end
72-
MPTSV.History[self.seasonID][G][cmap].abandoned = MPTSV.History[self.seasonID][G][cmap].abandoned + 1
73-
MPTSV.History[self.seasonID][G][cmap][level].abandoned = MPTSV.History[self.seasonID][G][cmap][level].abandoned + 1
74-
print('adding abandoned run for', cmap, level)
73+
MPTSV.History[self.seasonID][G][cmap].abandoned = (MPTSV.History[self.seasonID][G][cmap].abandoned or 0) + 1
74+
MPTSV.History[self.seasonID][G][cmap][level].abandoned = (MPTSV.History[self.seasonID][G][cmap][level].abandoned or 0) + 1
7575
return
7676
end
7777
if time and not MPTSV.History[self.seasonID][G][cmap].fastestrun then
@@ -86,7 +86,7 @@ function MPT:AddHistory(time, cmap, level, intime, abandoned) -- abandoned runs
8686
elseif level == MPTSV.History[self.seasonID][G][cmap].highestrun and time*1000 < MPTSV.History[self.seasonID][G][cmap].fastestrun then
8787
MPTSV.History[self.seasonID][G][cmap].fastestrun = time*1000 -- save faster run if same level
8888
end
89-
else
89+
elseif time then
9090
MPTSV.History[self.seasonID][G][cmap][level].depleted = MPTSV.History[self.seasonID][G][cmap][level].depleted + 1
9191
MPTSV.History[self.seasonID][G][cmap].depleted = MPTSV.History[self.seasonID][G][cmap].depleted + 1
9292
end

0 commit comments

Comments
 (0)