diff --git a/Definitions.lua b/Definitions.lua index 9821b5f00..7ebdc7008 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -238,10 +238,10 @@ ---@field raid_roster table [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> +---@field _trashoverallalreadyadded boolean ---@field alternate_power table ---@field totals {key1: table, key2: table, key3: table, key3: table} ---@field totals_grupo {key1: table, key2: table, key3: table, key3: table} @@ -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 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 diff --git a/classes/class_combat.lua b/classes/class_combat.lua index 999c5f36f..2b66cdf10 100644 --- a/classes/class_combat.lua +++ b/classes/class_combat.lua @@ -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 diff --git a/core/control.lua b/core/control.lua index 7ef6e6dbf..7624821fe 100644 --- a/core/control.lua +++ b/core/control.lua @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/functions/mythicdungeon/segments.lua b/functions/mythicdungeon/segments.lua index b29afdd43..f33c51b4d 100644 --- a/functions/mythicdungeon/segments.lua +++ b/functions/mythicdungeon/segments.lua @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 = "", "" @@ -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 @@ -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 @@ -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 @@ -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 @@ -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