Skip to content

Commit

Permalink
Fixed mythic+ segments being considered trash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Mar 2, 2024
1 parent 7d8b84a commit 703cee3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 84 deletions.
3 changes: 1 addition & 2 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@
---@field raid_roster table<string, string> [unitName] = unitGUID
---@field overall_added boolean is true when the combat got added into the overall combat
---@field is_mythic_dungeon mythicdungeoninfo
---@field is_mythic_dungeon_trash boolean
---@field is_mythic_dungeon_run_id number
---@field is_mythic_dungeon_segment boolean
---@field trinketProcs table<actorname, table<spellid, {cooldown: number, total: number}>>
---@field _trashoverallalreadyadded boolean
---@field alternate_power table<actorname, alternatepowertable>
---@field totals {key1: table, key2: table, key3: table, key3: table}
---@field totals_grupo {key1: table, key2: table, key3: table, key3: table}
Expand All @@ -259,7 +259,6 @@
---@field GetCombatName fun(combat: combat, bOnlyName: boolean?, bTryFind: boolean?) : string, number?, number?, number?, number? get the name of the combat
---@field GetCombatIcon fun(combat: combat) : df_atlasinfo
---@field GetTrinketProcsForPlayer fun(self: combat, playerName: string) : table<spellid, trinketprocdata> return a key|value table containing the spellId as key and a table with information about the trinket as value
---@field GetMythicDungeonTrashInfo fun(combat: combat) : mythicdungeontrashinfo
---@field IsMythicDungeon fun(combat: combat) : boolean, number return a boolean indicating if the combat is from a mythic+ dungeon, if true, also return the runId
---@field GetMythicDungeonInfo fun(combat: combat) : mythicdungeoninfo
---@field GetCombatType fun(combat: combat) : number
Expand Down
4 changes: 0 additions & 4 deletions classes/class_combat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ local segmentTypeToString = {
return self.is_mythic_dungeon
end

function classCombat:GetMythicDungeonTrashInfo()
return self.is_mythic_dungeon_trash
end

---return if the combat is a mythic dungeon segment and the run id
---@return boolean
---@return number
Expand Down
67 changes: 24 additions & 43 deletions core/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -598,22 +598,23 @@
currentCombat.is_mythic_dungeon_segment = true
currentCombat.is_mythic_dungeon_run_id = Details.mythic_dungeon_id

---@type mythicdungeoninfo
local mythicPlusInfo = {
ZoneName = Details.MythicPlus.DungeonName or zoneName,
MapID = Details.MythicPlus.DungeonID or zoneMapID,
Level = Details.MythicPlus.Level,
EJID = Details.MythicPlus.ejID,
RunID = Details.mythic_dungeon_id,
StartedAt = time() - currentCombat:GetCombatTime(),
EndedAt = time(),
SegmentID = Details.MythicPlus.SegmentID, --segment number within the dungeon
--default to trash
SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH,
SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0), --localize-me
}

currentCombat.is_mythic_dungeon = mythicPlusInfo
if (not currentCombat.is_mythic_dungeon) then
---@type mythicdungeoninfo
local mythicPlusInfo = {
ZoneName = Details.MythicPlus.DungeonName or zoneName,
MapID = Details.MythicPlus.DungeonID or zoneMapID,
Level = Details.MythicPlus.Level,
EJID = Details.MythicPlus.ejID,
RunID = Details.mythic_dungeon_id,
StartedAt = time() - currentCombat:GetCombatTime(),
EndedAt = time(),
SegmentID = Details.MythicPlus.SegmentID, --segment number within the dungeon
--default to trash
SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH,
SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0), --localize-me
}
currentCombat.is_mythic_dungeon = mythicPlusInfo
end
end

--send item level after a combat if is in raid or party group
Expand All @@ -629,25 +630,9 @@
currentCombat.enemy = "[" .. ARENA .. "] " .. currentCombat.is_arena.name
end

if (currentCombat.is_mythic_dungeon_segment) then
--is inside a mythic+ dungeon and this is not a boss segment, so tag it as a dungeon mythic+ trash segment
currentCombat.is_mythic_dungeon.SegmentType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH
currentCombat.is_mythic_dungeon.SegmentName = "Trash #" .. (Details.MythicPlus.SegmentID or 0) --localize-me
currentCombat.is_mythic_dungeon_trash = true

if (Details.debug) then
Details:Msg("segment tagged as mythic+ trash.")
end
end

local bInInstance = IsInInstance() --garrison returns party as instance type.
if ((instanceType == "party" or instanceType == "raid") and bInInstance) then
if (instanceType == "party") then
if (currentCombat.is_mythic_dungeon_segment) then
--tag the combat as trash clean up
currentCombat.is_trash = true
end
end
currentCombat.is_trash = true
else
if (not bInInstance) then
if (Details.world_combat_is_trash) then
Expand All @@ -658,11 +643,6 @@

if (not currentCombat.enemy) then
local enemy = Details:FindEnemy()

if (enemy and Details.debug) then
--Details:Msg("(debug) enemy found", enemy)
end

currentCombat.enemy = enemy
end

Expand Down Expand Up @@ -1333,12 +1313,13 @@
end

function Details:FlagActorsOnCommonFight()
local damage_container = Details.tabela_vigente [1]
local healing_container = Details.tabela_vigente [2]
local energy_container = Details.tabela_vigente [3]
local misc_container = Details.tabela_vigente [4]
local currentCombat = Details:GetCurrentCombat()
local damage_container = currentCombat[1]
local healing_container = currentCombat[2]
local energy_container = currentCombat[3]
local misc_container = currentCombat[4]

local mythicDungeonRun = Details.tabela_vigente.is_mythic_dungeon_segment
local mythicDungeonRun = currentCombat.is_mythic_dungeon_segment

for class_type, container in ipairs({damage_container, healing_container}) do

Expand Down
68 changes: 33 additions & 35 deletions functions/mythicdungeon/segments.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ function Details222.MythicPlus.OnBossDefeated(encounterID, encounterName)
---@type combat
local pastCombat = segmentsTable[i]
--does the combat exists
if (pastCombat and not pastCombat._trashoverallalreadyadded and pastCombat.is_mythic_dungeon_trash) then
if (pastCombat and not pastCombat._trashoverallalreadyadded) then
--is the combat a mythic segment from this run?
local isMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (isMythicSegment and SegmentID == Details.mythic_dungeon_id and not pastCombat.is_boss) then

local mythicDungeonInfo = pastCombat:GetMythicDungeonInfo() -- .is_mythic_dungeon only boss, trash overall and run overall have it
if (not mythicDungeonInfo or not mythicDungeonInfo.TrashOverallSegment) then
--trash segment found, schedule to merge
local bIsMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (bIsMythicSegment and SegmentID == Details.mythic_dungeon_id) then
local combatType = pastCombat:GetCombatType()
if (combatType == DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH or combatType == DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSSWIPE) then
table.insert(segmentsToMerge, pastCombat)
end
end
Expand All @@ -94,6 +92,7 @@ function Details222.MythicPlus.OnBossDefeated(encounterID, encounterName)
end

--after each boss fight, if enalbed on settings, create an extra segment with all trash segments from the boss just killed
--this function does not have agency over what segments to merge, it just receives a list of segments to merge
function DetailsMythicPlusFrame.MergeTrashCleanup()
if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("Details!", "MergeTrashCleanup() > running", DetailsMythicPlusFrame.TrashMergeScheduled and #DetailsMythicPlusFrame.TrashMergeScheduled)
Expand All @@ -107,7 +106,6 @@ function DetailsMythicPlusFrame.MergeTrashCleanup()

--the first segment is the segment where all other trash segments will be added
local masterSegment = segmentsToMerge[1]
masterSegment.is_mythic_dungeon_trash = nil

--get the current combat just created and the table with all past segments
local newCombat = masterSegment
Expand Down Expand Up @@ -157,6 +155,7 @@ function DetailsMythicPlusFrame.MergeTrashCleanup()
SegmentName = (segmentsToMerge.EncounterName or Loc ["STRING_UNKNOW"]) .. " (" .. string.lower(Loc["STRING_SEGMENTS_LIST_TRASH"]) .. ")",
}

newCombat.is_challenge = true
newCombat.is_mythic_dungeon_segment = true
newCombat.is_mythic_dungeon_run_id = Details.mythic_dungeon_id

Expand Down Expand Up @@ -213,6 +212,8 @@ function DetailsMythicPlusFrame.MergeSegmentsOnEnd() --~merge
local segmentsTable = Details:GetCombatSegments()

newCombat.is_challenge = true
newCombat.is_mythic_dungeon_segment = true
newCombat.is_mythic_dungeon_run_id = Details.mythic_dungeon_id

local timeInCombat = 0
local startDate, endDate = "", ""
Expand Down Expand Up @@ -376,16 +377,15 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone()
Details222.MythicPlus.LogStep("running MergeRemainingTrashAfterAllBossesDone.")

local segmentsToMerge = DetailsMythicPlusFrame.TrashMergeScheduled2
local overallCombat = DetailsMythicPlusFrame.TrashMergeScheduled2_OverallCombat
local latestBossTrashMergedCombat = DetailsMythicPlusFrame.TrashMergeScheduled2_OverallCombat

--needs to merge, add the total combat time, set the date end to the date of the first segment
local totalTime = 0
local startDate, endDate = "", ""
local lastSegment

--add segments
for i, pastCombat in ipairs(segmentsToMerge) do
overallCombat = overallCombat + pastCombat
latestBossTrashMergedCombat = latestBossTrashMergedCombat + pastCombat
if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MergeRemainingTrashAfterAllBossesDone() > segment added")
end
Expand All @@ -398,29 +398,30 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone()
local _, whenEnded = pastCombat:GetDate()
endDate = whenEnded
end
lastSegment = pastCombat
end

--set the segment time / using a sum of combat times, this combat time is reliable
local startTime = overallCombat:GetStartTime()
overallCombat:SetStartTime (startTime - totalTime)
local startTime = latestBossTrashMergedCombat:GetStartTime()
latestBossTrashMergedCombat:SetStartTime (startTime - totalTime)
if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MergeRemainingTrashAfterAllBossesDone() > total combat time:", totalTime)
end

--set the segment date
local startDate = overallCombat:GetDate()
overallCombat:SetDate (startDate, endDate)
startDate = latestBossTrashMergedCombat:GetDate()
latestBossTrashMergedCombat:SetDate(startDate, endDate)
if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MergeRemainingTrashAfterAllBossesDone() > new end date:", endDate)
end

local mythicDungeonInfo = overallCombat:GetMythicDungeonInfo()
local mythicDungeonInfo = latestBossTrashMergedCombat:GetMythicDungeonInfo()

if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MergeRemainingTrashAfterAllBossesDone() > elapsed time before:", mythicDungeonInfo.EndedAt - mythicDungeonInfo.StartedAt)
end

mythicDungeonInfo.StartedAt = mythicDungeonInfo.StartedAt - (Details.MythicPlus.EndedAt - Details.MythicPlus.PreviousBossKilledAt)

if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MergeRemainingTrashAfterAllBossesDone() > elapsed time after:", mythicDungeonInfo.EndedAt - mythicDungeonInfo.StartedAt)
end
Expand Down Expand Up @@ -448,7 +449,7 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone()

if (removedCurrentSegment) then
--find another current segment
local segmentsTable = Details:GetCombatSegments()
segmentsTable = Details:GetCombatSegments()
Details:SetCurrentCombat(segmentsTable[1])

if (not Details:GetCurrentCombat()) then
Expand Down Expand Up @@ -493,20 +494,14 @@ function Details222.MythicPlus.MergeTrashAfterLastBoss()
end

--is the combat a mythic segment from this run?
local isMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (isMythicSegment and SegmentID == Details.mythic_dungeon_id and pastCombat.is_mythic_dungeon_trash) then

--if have mythic dungeon info, cancel the loop
local mythicDungeonInfo = pastCombat:GetMythicDungeonInfo()
if (mythicDungeonInfo) then
break
end

--merge this segment
table.insert(segmentsToMerge, pastCombat)

if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MythicDungeonFinished() > found after last boss combat")
local bIsMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (bIsMythicSegment and SegmentID == Details.mythic_dungeon_id) then
local combatType = pastCombat:GetCombatType()
if (combatType == DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH or combatType == DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSSWIPE) then
table.insert(segmentsToMerge, pastCombat)
if (DetailsMythicPlusFrame.DevelopmentDebug) then
print("MythicDungeonFinished() > found after last boss combat")
end
end
end
end
Expand All @@ -522,9 +517,12 @@ function Details222.MythicPlus.MergeTrashAfterLastBoss()
local latestTrashOverall
for i = 1, #segmentsTable do
local pastCombat = segmentsTable[i]
if (pastCombat and pastCombat.is_mythic_dungeon and pastCombat.is_mythic_dungeon.SegmentID == "trashoverall") then
latestTrashOverall = pastCombat
break
if (pastCombat and pastCombat.is_mythic_dungeon) then
local combatType = pastCombat:GetCombatType()
if (combatType == DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSSTRASH) then
latestTrashOverall = pastCombat
break
end
end
end

Expand Down

0 comments on commit 703cee3

Please sign in to comment.