You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

895 lines
29 KiB

4 years ago
local Details = _G.Details
local _
local addonName, Details222 = ...
3 years ago
local combatClass = Details.combate
local segmentClass = Details.historico
local bitBand = bit.band
local wipe = table.wipe
4 years ago
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--API
4 years ago
3 years ago
--reset only the overall data
function Details:ResetSegmentOverallData()
return segmentClass:ResetOverallData()
4 years ago
end
3 years ago
--reset segments and overall data
function Details:ResetSegmentData()
return segmentClass:ResetAllCombatData()
4 years ago
end
3 years ago
--returns the current active segment
function Details:GetCurrentCombat()
return Details.tabela_vigente
4 years ago
end
function Details:GetOverallCombat()
return Details.tabela_overall
end
function Details:GetCombat(combat)
if (not combat) then
return Details:GetCurrentCombat()
elseif (type(combat) == "number") then
if (combat == -1) then --overall
return Details:GetOverallCombat()
elseif (combat == 0) then --current
return Details:GetCurrentCombat()
else
local segmentsTable = Details:GetCombatSegments()
return segmentsTable[combat]
end
elseif (type(combat) == "string") then
if (combat == "overall") then
return Details:GetOverallCombat()
elseif (combat == "current") then
return Details:GetCurrentCombat()
end
end
return nil
end
---get a unique combat id and check if exists a combat with this id
---@param uniqueCombatId number
---@return boolean bExistsCombat
function Details:DoesCombatWithUIDExists(uniqueCombatId)
local segmentsTable = Details:GetCombatSegments()
for segmentId, combatObject in ipairs(segmentsTable) do
if (combatObject.combat_counter == uniqueCombatId) then
return true
end
end
return false
end
---get a unique combat id and return the combat object
---@param uniqueCombatId number
---@return combat|boolean combatObject
function Details:GetCombatByUID(uniqueCombatId)
local segmentsTable = Details:GetCombatSegments()
for segmentId, combatObject in ipairs(segmentsTable) do
if (combatObject.combat_counter == uniqueCombatId) then
return combatObject
end
end
return false
end
---remove a segment from the segments table
---@param segmentIndex number
---@return boolean, combat
function Details:RemoveSegment(segmentIndex)
assert(type(segmentIndex) == "number", "Usage: Details:RemoveSegment(segmentIndex: number)")
local segmentsTable = Details:GetCombatSegments()
local segmentRemoved = table.remove(segmentsTable, segmentIndex)
return segmentRemoved ~= nil, segmentRemoved
end
---remove a combat from the segments list by it's combat object
---@param combatObject any
---@return boolean, combat|nil
function Details:RemoveSegmentByCombatObject(combatObject)
if (combatObject) then
local segmentsTable = Details:GetCombatSegments()
for i = 1, #segmentsTable do
if (segmentsTable[i] == combatObject) then
local combatObjectRemoved = table.remove(segmentsTable, i)
return true, combatObjectRemoved
end
end
end
return false
end
3 years ago
--returns a private table containing all stored segments
function Details:GetCombatSegments()
return Details.tabela_historico.tabelas
4 years ago
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3 years ago
--internal
4 years ago
function Details222.GuessSpecSchedules.ClearSchedules()
for i = 1, #Details222.GuessSpecSchedules.Schedules do
local schedule = Details222.GuessSpecSchedules.Schedules[i]
if (schedule) then
Details:CancelTimer(schedule)
end
end
wipe(Details222.GuessSpecSchedules.Schedules)
end
function segmentClass:CreateNewSegmentDatabase()
local newSegmentDatabase = {tabelas = {}}
setmetatable(newSegmentDatabase, segmentClass)
return newSegmentDatabase
4 years ago
end
function segmentClass:AddToOverallData(combatObject)
4 years ago
local zoneName, zoneType = GetInstanceInfo()
if (zoneType ~= "none" and combatObject:GetCombatTime() <= Details.minimum_overall_combat_time) then
4 years ago
return
end
3 years ago
if (Details.overall_clear_newboss) then
--only for raids
if (combatObject.instance_type == "raid" and combatObject.is_boss) then
3 years ago
if (Details.last_encounter ~= Details.last_encounter2) then
if (Details.debug) then
Details:Msg("(debug) new boss detected 'overall_clear_newboss' is true, cleaning overall data.")
4 years ago
end
for index, combat in ipairs(Details:GetCombatSegments()) do
4 years ago
combat.overall_added = false
end
segmentClass:ResetOverallData()
4 years ago
end
end
end
3 years ago
if (combatObject.overall_added) then
Details:Msg("error > attempt to add a segment already added > func historico:AddToOverallData()")
4 years ago
return
end
3 years ago
local mythicInfo = combatObject.is_mythic_dungeon
4 years ago
if (mythicInfo) then
3 years ago
--do not add overall mythic+ dungeon segments
4 years ago
if (mythicInfo.TrashOverallSegment) then
Details:Msg("error > attempt to add a TrashOverallSegment > func historico:AddToOverallData()")
4 years ago
return
4 years ago
elseif (mythicInfo.OverallSegment) then
Details:Msg("error > attempt to add a OverallSegment > func historico:AddToOverallData()")
4 years ago
return
end
end
3 years ago
--store the segments added to the overall data
Details.tabela_overall.segments_added = Details.tabela_overall.segments_added or {}
local startDate = combatObject.data_inicio
3 years ago
local combatName = combatObject:GetCombatName(true)
local combatTime = combatObject:GetCombatTime()
local combatType = combatObject:GetCombatType()
4 years ago
table.insert(Details.tabela_overall.segments_added, 1, {name = combatName, elapsed = combatTime, clock = startDate, type = combatType})
3 years ago
if (#Details.tabela_overall.segments_added > 40) then
table.remove(Details.tabela_overall.segments_added, 41)
4 years ago
end
3 years ago
if (Details.debug) then
Details:Msg("(debug) adding the segment to overall data: " .. (combatObject:GetCombatName(true) or "no name") .. " with time of: " .. (combatObject:GetCombatTime() or "no time"))
4 years ago
end
3 years ago
Details.tabela_overall = Details.tabela_overall + combatObject
combatObject.overall_added = true
3 years ago
if (not Details.tabela_overall.overall_enemy_name) then
Details.tabela_overall.overall_enemy_name = combatObject.is_boss and combatObject.is_boss.name or combatObject.enemy
4 years ago
else
if (Details.tabela_overall.overall_enemy_name ~= (combatObject.is_boss and combatObject.is_boss.name or combatObject.enemy)) then
3 years ago
Details.tabela_overall.overall_enemy_name = "-- x -- x --"
4 years ago
end
end
3 years ago
if (Details.tabela_overall.start_time == 0) then
Details.tabela_overall:SetStartTime(combatObject.start_time)
Details.tabela_overall:SetEndTime(combatObject.end_time)
4 years ago
else
Details.tabela_overall:SetStartTime(combatObject.start_time - Details.tabela_overall:GetCombatTime())
Details.tabela_overall:SetEndTime(combatObject.end_time)
4 years ago
end
local currentCombat = Details:GetCurrentCombat()
3 years ago
if (Details.tabela_overall.data_inicio == 0) then
Details.tabela_overall.data_inicio = currentCombat.data_inicio or 0
4 years ago
end
Details.tabela_overall:seta_data(Details._detalhes_props.DATA_TYPE_END)
3 years ago
Details:ClockPluginTickOnSegment()
4 years ago
3 years ago
for id, instance in Details:ListInstances() do
4 years ago
if (instance:IsEnabled()) then
if (instance:GetSegment() == DETAILS_SEGMENTID_OVERALL) then
4 years ago
instance:ForceRefresh()
end
end
end
end
---return true if the combatObject can be added to the overall data
---@param self details
---@param combatObject table
---@return boolean canAdd
function Details:CanAddCombatToOverall(combatObject)
3 years ago
--already added
if (combatObject.overall_added) then
4 years ago
return false
end
3 years ago
--special cases
local mythicInfo = combatObject.is_mythic_dungeon
4 years ago
if (mythicInfo) then
3 years ago
--do not add overall mythic+ dungeon segments
4 years ago
if (mythicInfo.TrashOverallSegment) then
return false
3 years ago
4 years ago
elseif (mythicInfo.OverallSegment) then
return false
end
end
3 years ago
--raid boss - flag 0x1
if (bitBand(Details.overall_flag, 0x1) ~= 0) then
if (combatObject.is_boss and combatObject.instance_type == "raid" and not combatObject.is_pvp) then
if (combatObject:GetCombatTime() >= 30) then
4 years ago
return true
end
end
end
3 years ago
--raid trash - flag 0x2
if (bitBand(Details.overall_flag, 0x2) ~= 0) then
if (combatObject.is_trash and combatObject.instance_type == "raid") then
4 years ago
return true
end
end
3 years ago
--dungeon boss - flag 0x4
if (bitBand(Details.overall_flag, 0x4) ~= 0) then
if (combatObject.is_boss and combatObject.instance_type == "party" and not combatObject.is_pvp) then
4 years ago
return true
end
end
3 years ago
--dungeon trash - flag 0x8
if (bitBand(Details.overall_flag, 0x8) ~= 0) then
if ((combatObject.is_trash or combatObject.is_mythic_dungeon_trash) and combatObject.instance_type == "party") then
4 years ago
return true
end
end
3 years ago
--any combat
if (bitBand(Details.overall_flag, 0x10) ~= 0) then
4 years ago
return true
end
3 years ago
--is a PvP combat
if (combatObject.is_pvp or combatObject.is_arena) then
4 years ago
return true
end
3 years ago
4 years ago
return false
end
---count boss tries and set the value in the combat object
---@param combatToBeAdded combat
local setBossTryCounter = function(combatToBeAdded, segmentsTable, amountSegmentsInUse)
---@type string
local bossName = combatToBeAdded.is_boss and combatToBeAdded.is_boss.name
if (bossName) then
local tryNumber = Details.encounter_counter[bossName]
if (not tryNumber) then
---@type combat
local previousCombatObject
for i = 1, amountSegmentsInUse do
previousCombatObject = segmentsTable[i]
if (previousCombatObject and previousCombatObject.is_boss and previousCombatObject.is_boss.name and previousCombatObject.is_boss.try_number and previousCombatObject.is_boss.name == bossName and not previousCombatObject.is_boss.killed) then
tryNumber = previousCombatObject.is_boss.try_number + 1
4 years ago
break
end
end
3 years ago
if (not tryNumber) then
tryNumber = 1
4 years ago
end
else
tryNumber = Details.encounter_counter[bossName] + 1
4 years ago
end
3 years ago
Details.encounter_counter[bossName] = tryNumber
combatToBeAdded.is_boss.try_number = tryNumber
4 years ago
end
end
3 years ago
---add the combat to the segment table, check adding to overall
---@param combatToBeAdded combat
function Details222.Combat.AddCombat(combatToBeAdded)
---@type number how many segments the user wants to store
local maxSegmentsAllowed = Details.segments_amount
3 years ago
---@type combat[]
local segmentsTable = Details:GetCombatSegments()
3 years ago
---@type number amount of segments currently stored
local amountSegmentsInUse = #segmentsTable
3 years ago
---@debug check if there's a destroyed segment within the segment container
if (amountSegmentsInUse > 0) then
for i = 1, amountSegmentsInUse do
local thisCombatObject = segmentsTable[i]
if (thisCombatObject.__destroyed) then
Details:Msg("(debug) container_segments line: 329 (__destroyed combat in segments container)")
4 years ago
end
end
end
---@end-debug
---@type boolean
local bSegmentDestroyed = false
--check all instances for freeze state
if (amountSegmentsInUse < maxSegmentsAllowed) then
--if there's no segment stored, then this as the first segment
if (amountSegmentsInUse == 0) then
Details:InstanciaCallFunction(Details.CheckFreeze, amountSegmentsInUse + 1, combatToBeAdded)
else
---@type combat
local oldestCombatObject = segmentsTable[amountSegmentsInUse]
Details:InstanciaCallFunction(Details.CheckFreeze, amountSegmentsInUse + 1, oldestCombatObject)
4 years ago
end
end
3 years ago
setBossTryCounter(combatToBeAdded, segmentsTable, amountSegmentsInUse)
3 years ago
--shutdown actors from the previous combat from the time machine
---@type combat
local previousCombatObject = segmentsTable[1]
if (previousCombatObject) then
---@type actorcontainer
local containerDamage = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
---@type actorcontainer
local containerHeal = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL)
3 years ago
for _, actorObject in containerDamage:ListActors() do
---@cast actorObject actor
--clear last events table (death logs)
actorObject.last_events_table = nil
--remove from the time machine
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in containerHeal:ListActors() do
---@cast actorObject actor
--clear last events table (death logs)
actorObject.last_events_table = nil
--remove from the time machine
Details222.TimeMachine.RemoveActor(actorObject)
end
end
---@type boolean user choise to remove trash combats or nor
local bAutoRemoveTrashCombats = Details.trash_auto_remove
if (bAutoRemoveTrashCombats) then
---@type combat
local combatToCheckForTrash = segmentsTable[2]
if (combatToCheckForTrash) then
local bIsFromMythicDungeon = combatToCheckForTrash.is_mythic_dungeon_segment
if (not bIsFromMythicDungeon) then
local bCombatIsTrash = combatToCheckForTrash.is_trash and not combatToCheckForTrash.is_boss
local bCombatIsWorldTrash = combatToCheckForTrash.is_world_trash_combat
if (bCombatIsTrash or bCombatIsWorldTrash) then
---@type boolean, combat|nil
local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegmentByCombatObject(combatToCheckForTrash)
if (bSegmentRemoved and combatObjectRemoved == combatToCheckForTrash) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
4 years ago
end
end
end
end
end
--update the amount of segments in use in case a segment was removed
amountSegmentsInUse = #segmentsTable
--add +1 into the amount of segments in use to count for the combat which will be added at the end of this function
local amountOfSegmentsInUsePlusOne = amountSegmentsInUse + 1
--check if the segment table will exceed the amount of segments allowed (user setting)
if (amountOfSegmentsInUsePlusOne > maxSegmentsAllowed) then
---@type combat last combat in the segment table
local combatObjectToBeRemoved = segmentsTable[amountSegmentsInUse]
3 years ago
---@type boolean, combat|nil
local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegmentByCombatObject(combatObjectToBeRemoved)
if (bSegmentRemoved and combatObjectRemoved == combatObjectToBeRemoved) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
end
end
--update the amount of segments in use in case a segment was removed
amountSegmentsInUse = #segmentsTable
---@debug check if there's a destroyed segment within the segment container
if (amountSegmentsInUse > 0) then
for i = 1, amountSegmentsInUse do
local thisCombatObject = segmentsTable[i]
if (thisCombatObject.__destroyed) then
Details:Msg("(debug) container_segments line: 418 (__destroyed combat in segments container)")
4 years ago
end
end
end
---@end-debug
4 years ago
--insert the combat into the segments table
table.insert(segmentsTable, 1, combatToBeAdded)
--see if can add the encounter to overall data
local bCanAddToOverall = Details:CanAddCombatToOverall(combatToBeAdded)
if (bCanAddToOverall) then
if (Details.debug) then
Details:Msg("(debug) overall data flag match addind the combat to overall data.")
4 years ago
end
--add to overall data
segmentClass:AddToOverallData(combatToBeAdded)
end
Details:InstanceCall(function(instanceObject) instanceObject:RefreshCombat() end)
3 years ago
--update the combat shown on all instances
Details:InstanciaCallFunction(Details.AtualizaSegmentos_AfterCombat)
if (bSegmentDestroyed) then
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
4 years ago
end
end
4 years ago
3 years ago
---add the combat to the segment table, check adding to overall
---@param combatObject combat
function segmentClass:AddCombat(combatObject)
if true then
return Details222.Combat.AddCombat(combatObject)
end
3 years ago
---@type combat[]
local segmentsTable = Details:GetCombatSegments()
---@type number
local maxSegmentsAllowed = Details.segments_amount
3 years ago
local bSegmentDestroyed = false
3 years ago
--check all instances for freeze state
if (#segmentsTable < maxSegmentsAllowed) then --done
---@type combat
local oldestCombatObject = segmentsTable[#segmentsTable]
--if there's no segment stored, then this as the first segment
if (not oldestCombatObject) then
oldestCombatObject = combatObject
end
Details:InstanciaCallFunction(Details.CheckFreeze, #segmentsTable + 1, oldestCombatObject)
end
3 years ago
--add to the first index of the segment table
--table.insert(segmentsTable, 1, combatObject) --will be added at the end
3 years ago
--count boss tries
---@type string
local bossName = combatObject.is_boss and combatObject.is_boss.name
if (bossName) then --done
local tryNumber = Details.encounter_counter[bossName]
if (not tryNumber) then
---@type combat
local previousCombatObject
for i = 2, #segmentsTable do
previousCombatObject = segmentsTable[i]
if (previousCombatObject and previousCombatObject.is_boss and previousCombatObject.is_boss.name and previousCombatObject.is_boss.try_number and previousCombatObject.is_boss.name == bossName and not previousCombatObject.is_boss.killed) then
tryNumber = previousCombatObject.is_boss.try_number + 1
break
4 years ago
end
end
3 years ago
if (not tryNumber) then
tryNumber = 1
4 years ago
end
else
tryNumber = Details.encounter_counter[bossName] + 1
4 years ago
end
3 years ago
Details.encounter_counter[bossName] = tryNumber
combatObject.is_boss.try_number = tryNumber
end
--see if can add the encounter to overall data
local canAddToOverall = Details:CanAddCombatToOverall(combatObject)
if (canAddToOverall) then
if (Details.debug) then
Details:Msg("(debug) overall data flag match addind the combat to overall data.")
end
segmentClass:AddToOverallData(combatObject)
end
--erase trash segments
if (segmentsTable[2]) then
---@type combat
local previousCombatObject = segmentsTable[2]
---@type actorcontainer
local containerDamage = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
---@type actorcontainer
local containerHeal = previousCombatObject:GetContainer(DETAILS_ATTRIBUTE_HEAL)
--regular cleanup
for _, actorObject in containerDamage:ListActors() do
---@cast actorObject actor
--clear last events table
actorObject.last_events_table = nil
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in containerHeal:ListActors() do
---@cast actorObject actor
actorObject.last_events_table = nil
Details222.TimeMachine.RemoveActor(actorObject)
4 years ago
end
if (Details.trash_auto_remove) then
---@type combat
local thirdCombat = segmentsTable[3]
if (thirdCombat and not thirdCombat.is_mythic_dungeon_segment) then
if ((thirdCombat.is_trash and not thirdCombat.is_boss) or(thirdCombat.is_temporary)) then
--verify again the time machine
for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in thirdCombat:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do
Details222.TimeMachine.RemoveActor(actorObject)
end
--remove
---@type boolean, combat
local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegment(3)
if (bSegmentRemoved) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
end
end
4 years ago
end
end
end
local segmentsTable = Details:GetCombatSegments()
--check if the segment table is full
if (#segmentsTable > maxSegmentsAllowed) then
---@type combat
local combatObjectToBeRemoved
---@type number
local segmentIdToBeRemoved
--verify if the last combat is a boss and if there's more bosses with the same bossId in the segment table
--then check which combat has the least amount of elapsed time and remove it
--won't remove the latest 3 segments as they are fresh and the player may still look into them
local bossId = combatObject.is_boss and combatObject.is_boss.id
---@type combat
local oldestSegment = segmentsTable[#segmentsTable]
local oldestBossId = oldestSegment.is_boss and oldestSegment.is_boss.id
if (Details.zone_type == "raid" and bossId and oldestBossId and bossId == oldestBossId) then
---@type combat
local shorterCombatObject
---@type number
local shorterSegmentId
local minTime = 99999
for segmentId = 4, #segmentsTable do
---@type combat
local thisCombatObject = segmentsTable[segmentId]
if (thisCombatObject.is_boss and thisCombatObject.is_boss.id == bossId and thisCombatObject:GetCombatTime() < minTime and not thisCombatObject.is_boss.killed) then
shorterCombatObject = thisCombatObject
shorterSegmentId = segmentId
minTime = thisCombatObject:GetCombatTime()
end
end
if (shorterCombatObject) then
combatObjectToBeRemoved = shorterCombatObject
segmentIdToBeRemoved = shorterSegmentId
4 years ago
end
end
3 years ago
--if couldn't find a boss to remove, then remove the oldest segment
if (not combatObjectToBeRemoved) then
combatObjectToBeRemoved = segmentsTable[#segmentsTable]
segmentIdToBeRemoved = #segmentsTable
end
--check time machine
for _, actorObject in combatObjectToBeRemoved:GetContainer(DETAILS_ATTRIBUTE_DAMAGE):ListActors() do
Details222.TimeMachine.RemoveActor(actorObject)
end
for _, actorObject in combatObjectToBeRemoved:GetContainer(DETAILS_ATTRIBUTE_HEAL):ListActors() do
Details222.TimeMachine.RemoveActor(actorObject)
end
--remove it
segmentsTable = Details:GetCombatSegments()
---@type boolean, combat
local bSegmentRemoved, combatObjectRemoved = Details:RemoveSegment(segmentIdToBeRemoved)
if (bSegmentRemoved) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
end
end
---@debug check if there's a destroyed segment within the segment container
local segments = Details:GetCombatSegments()
if (#segments > 0) then
for i = 1, #segments do
local thisCombatObject = segments[i]
if (thisCombatObject.__destroyed) then
Details:Msg("(debug) container_segments line: 419 (__destroyed combat in segments container)")
end
end
3 years ago
end
---@end-debug
3 years ago
Details:InstanceCall(function(instanceObject) instanceObject:RefreshCombat() end)
--update the combat shown on all instances
3 years ago
Details:InstanciaCallFunction(Details.AtualizaSegmentos_AfterCombat, self)
if (bSegmentDestroyed) then
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
4 years ago
end
---verify if the instance is freezed, if true unfreeze it
---@param instanceObject instance
---@param segmentId number
---@param combatObject combat
function Details:CheckFreeze(instanceObject, segmentId, combatObject)
if (instanceObject.freezed) then
if (instanceObject:GetSegmentId() == segmentId) then
instanceObject:RefreshCombat()
instanceObject:UnFreeze()
4 years ago
end
end
end
function Details:SetOverallResetOptions(resetOnNewBoss, resetOnNewChallenge, resetOnLogoff, resetOnNewPVP)
if (resetOnNewBoss == nil) then
resetOnNewBoss = Details.overall_clear_newboss
4 years ago
end
if (resetOnNewChallenge == nil) then
resetOnNewChallenge = Details.overall_clear_newchallenge
4 years ago
end
if (resetOnLogoff == nil) then
resetOnLogoff = Details.overall_clear_logout
3 years ago
end
if (resetOnNewPVP == nil) then
resetOnNewPVP = Details.overall_clear_pvp
4 years ago
end
3 years ago
Details.overall_clear_newboss = resetOnNewBoss
Details.overall_clear_newchallenge = resetOnNewChallenge
Details.overall_clear_logout = resetOnLogoff
Details.overall_clear_pvp = resetOnNewPVP
4 years ago
end
function segmentClass:ResetOverallData()
Details:CloseBreakdownWindow()
3 years ago
Details:DestroyCombat(Details.tabela_overall)
Details.tabela_overall = combatClass:NovaTabela()
3 years ago
for index, instanceObject in ipairs(Details:GetAllInstances()) do
if (instanceObject:IsEnabled()) then
local segmentId = instanceObject:GetSegmentId()
if (segmentId == DETAILS_SEGMENTID_OVERALL) then
instanceObject:InstanceReset()
instanceObject:ReajustaGump()
4 years ago
end
end
end
3 years ago
--stop bar testing if any
Details:StopTestBarUpdate()
Details:ClockPluginTickOnSegment()
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
4 years ago
end
function segmentClass:ResetAllCombatData()
if (Details:IsInCombat()) then
Details:EndCombat()
end
3 years ago
if (Details.bosswindow) then
Details.bosswindow:Reset()
end
Details222.GuessSpecSchedules.ClearSchedules()
3 years ago
--stop bar testing if any
Details:StopTestBarUpdate()
--close breakdown window
Details:CloseBreakdownWindow()
--empty damage class cache tables
Details.atributo_damage:ClearCacheTables()
--clear caches
Details:ClearSpellCache()
Details:Destroy(Details.ShieldCache)
Details:Destroy(Details.cache_damage_group)
Details:Destroy(Details.cache_healing_group)
3 years ago
Details222.Pets.PetContainerCleanup()
Details:ResetSpecCache(true)
3 years ago
--stop combat ticker
Details:StopCombatTicker()
3 years ago
--remove mythic dungeon schedules if any
Details.schedule_mythicdungeon_trash_merge = nil
Details.schedule_mythicdungeon_endtrash_merge = nil
Details.schedule_mythicdungeon_overallrun_merge = nil
--clear other schedules
Details.schedule_flag_boss_components = nil
Details.schedule_store_boss_encounter = nil
--> handle segments destruction
do
---@type combat
local currentCombat = Details:GetCurrentCombat()
--handle segments
local segmentsTable = Details:GetCombatSegments()
--destroy all combat objects stored in the segments table
for i = #segmentsTable, 1, -1 do
---@type combat
local thisCombatObject = segmentsTable[i]
Details:DestroyCombat(thisCombatObject)
end
3 years ago
--the current combat when finished will be moved to the first index of "segmentsTable", need the check if the current combat was already destroyed
if (not currentCombat.__destroyed) then
Details:DestroyCombat(currentCombat)
end
3 years ago
--destroy the overall combat object
Details:DestroyCombat(Details.tabela_overall)
3 years ago
end
--> handle the creation of new combat objects and segment container
do
--create new segment container
Details.tabela_historico = segmentClass:CreateNewSegmentDatabase()
--create new overall combat object
Details.tabela_overall = combatClass:NovaTabela() --joga fora a tabela antiga e cria uma nova
--create a new current combat object
Details.tabela_vigente = combatClass:NovaTabela(nil, Details.tabela_overall)
--create new container to store pets
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdatePetCache()
Details.container_pets:BuscarPets()
3 years ago
end
---@type instance[]
local allInstances = Details:GetAllInstances()
3 years ago
for i = 1, #allInstances do
---@type instance
local instance = allInstances[i]
if (instance:IsEnabled()) then
Details:UpdateCombatObjectInUse(instance)
end
end
3 years ago
4 years ago
--marca o addon como fora de combate
3 years ago
Details.in_combat = false
4 years ago
--zera o contador de combates
Details:GetOrSetCombatId(0)
3 years ago
--reinicia a time machine
Details222.TimeMachine.Restart()
3 years ago
Details:UpdateParserGears()
if (not InCombatLockdown() and not UnitAffectingCombat("player")) then
--workarround for the "script run too long" issue while outside the combat lockdown
4 years ago
local cleargarbage = function()
collectgarbage()
end
3 years ago
local successful, errortext = pcall(cleargarbage)
4 years ago
if (not successful) then
3 years ago
Details:Msg("couldn't call collectgarbage()")
4 years ago
end
else
3 years ago
Details.schedule_hard_garbage_collect = true
end
Details:InstanciaCallFunction(Details.UpdateCombatObjectInUse) -- atualiza o instancia.showing para as novas tabelas criadas
3 years ago
Details:InstanciaCallFunction(Details.AtualizaSoloMode_AfertReset) -- verifica se precisa zerar as tabela da janela solo mode
Details:InstanciaCallFunction(Details.ResetaGump) --_detalhes:ResetaGump("de todas as instancias")
3 years ago
Details:InstanciaCallFunction(Details.FadeHandler.Fader, "IN", nil, "barras")
Details:RefreshMainWindow(-1) --atualiza todas as instancias
Details:SendEvent("DETAILS_DATA_RESET", nil, nil)
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
4 years ago
end
function Details.refresh:r_historico(este_historico)
3 years ago
setmetatable(este_historico, segmentClass)
4 years ago
--este_historico.__index = historico
end
--[[
elseif (_detalhes.trash_concatenate) then
3 years ago
4 years ago
if (true) then
return
end
3 years ago
4 years ago
if (_terceiro_combate) then
if (_terceiro_combate.is_trash and _segundo_combate.is_trash and not _terceiro_combate.is_boss and not _segundo_combate.is_boss) then
3 years ago
--tabela 2 deve ser deletada e somada a tabela 1
4 years ago
if (_detalhes.debug) then
3 years ago
detalhes:Msg("(debug) concatenating two trash segments.")
4 years ago
end
3 years ago
4 years ago
_segundo_combate = _segundo_combate + _terceiro_combate
_detalhes.tabela_overall = _detalhes.tabela_overall - _terceiro_combate
3 years ago
4 years ago
_segundo_combate.is_trash = true
3 years ago
--verificar novamente a time machine
for _, jogador in ipairs(_terceiro_combate [1]._ActorTable) do --damage
Details222.TimeMachine.RemoveActor(jogador)
4 years ago
end
3 years ago
for _, jogador in ipairs(_terceiro_combate [2]._ActorTable) do --heal
Details222.TimeMachine.RemoveActor(jogador)
4 years ago
end
3 years ago
--remover
_table_remove(self.tabelas, 3)
_detalhes:SendEvent("DETAILS_DATA_SEGMENTREMOVED", nil, nil)
4 years ago
end
end
--]]