More bug fixes for destroyed combats; TimeData code modernizations

This commit is contained in:
Tercio Jose
2023-06-14 18:43:33 -03:00
parent efd131ef04
commit a2c5e926c9
9 changed files with 446 additions and 142 deletions
+6 -6
View File
@@ -67,10 +67,10 @@
--api functions
--combat (container type, actor name)
Details.call_combate = function(self, class_type, name)
local container = self[class_type]
local index_mapa = container._NameIndexTable [name]
local actor = container._ActorTable [index_mapa]
Details.call_combate = function(self, classType, actorName)
local container = self[classType]
local index_mapa = container._NameIndexTable[actorName]
local actor = container._ActorTable[index_mapa]
return actor
end
classCombat.__call = Details.call_combate
@@ -81,7 +81,7 @@
end
--set the combat date
function classCombat:SetDate (started, ended)
function classCombat:SetDate(started, ended)
if (started and type(started) == "string") then
self.data_inicio = started
end
@@ -95,7 +95,7 @@
return self.TimeData[name]
end
function classCombat:GetContainer (attribute)
function classCombat:GetContainer(attribute)
return self [attribute]
end
+25 -3
View File
@@ -16,6 +16,9 @@ local _UnitName = UnitName --wow api locals
local _UnitIsPlayer = UnitIsPlayer --wow api locals
local _UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned --wow api locals
local segmentClass = Details.historico
local combatClass = Details.combate
local _detalhes = _G.Details
local _
local addonName, Details222 = ...
@@ -217,11 +220,30 @@ local instanceMixins = {
---@type segmentid
local segmentId = instance:GetSegmentId()
if (segmentId == DETAILS_SEGMENTID_OVERALL) then
instance.showing = Details:GetOverallCombat()
---@type combat
local combatObject = Details:GetOverallCombat()
if (combatObject.__destroyed) then
combatObject = combatClass:NovaTabela()
end
instance.showing = combatObject
elseif (segmentId == DETAILS_SEGMENTID_CURRENT) then
instance.showing = Details:GetCurrentCombat()
---@type combat
local combatObject = Details:GetCurrentCombat()
if (combatObject.__destroyed) then
combatObject = combatClass:NovaTabela(nil, Details.tabela_overall)
end
instance.showing = combatObject
else
instance.showing = Details:GetCombat(segmentId)
---@type combat
local combatObject = Details:GetCombat(segmentId)
if (combatObject.__destroyed) then
table.remove(Details:GetCombatSegments(), segmentId)
combatObject = combatClass:NovaTabela()
table.insert(Details:GetCombatSegments(), segmentId, combatObject)
end
instance.showing = combatObject
end
---@type combat
+24 -15
View File
@@ -314,7 +314,6 @@ function segmentClass:AddCombat(combatObject)
for _, actorObject in containerHeal:ListActors() do
---@cast actorObject actor
--clear last events table
actorObject.last_events_table = nil
Details222.TimeMachine.RemoveActor(actorObject)
end
@@ -344,8 +343,10 @@ function segmentClass:AddCombat(combatObject)
end
end
local segmentsTable = Details.tabela_historico.tabelas
--check if the segment table is full
if (#segmentTable > maxSegmentsAllowed) then
if (#segmentsTable > maxSegmentsAllowed) then
---@type combat
local combatObjectToBeRemoved
---@type number
@@ -357,7 +358,7 @@ function segmentClass:AddCombat(combatObject)
local bossId = combatObject.is_boss and combatObject.is_boss.id
---@type combat
local oldestSegment = segmentTable[#segmentTable]
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
@@ -367,9 +368,9 @@ function segmentClass:AddCombat(combatObject)
local shorterSegmentId
local minTime = 99999
for segmentId = 4, #segmentTable do
for segmentId = 4, #segmentsTable do
---@type combat
local thisCombatObject = segmentTable[segmentId]
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
@@ -385,8 +386,8 @@ function segmentClass:AddCombat(combatObject)
--if couldn't find a boss to remove, then remove the oldest segment
if (not combatObjectToBeRemoved) then
combatObjectToBeRemoved = segmentTable[#segmentTable]
segmentIdToBeRemoved = #segmentTable
combatObjectToBeRemoved = segmentsTable[#segmentsTable]
segmentIdToBeRemoved = #segmentsTable
end
--check time machine
@@ -398,14 +399,17 @@ function segmentClass:AddCombat(combatObject)
end
--remove it
segmentsTable = Details.tabela_historico.tabelas
---@type combat
local combatObjectRemoved = table.remove(segmentTable, segmentIdToBeRemoved)
local combatObjectRemoved = table.remove(segmentsTable, segmentIdToBeRemoved)
if (combatObjectRemoved) then
Details:DestroyCombat(combatObjectRemoved)
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
end
Details:InstanceCall(function(instanceObject) instanceObject:RefreshCombat() end)
--update the combat shown on all instances
Details:InstanciaCallFunction(Details.AtualizaSegmentos_AfterCombat, self)
end
@@ -499,15 +503,19 @@ function segmentClass:ResetAllCombatData()
--empty temporary tables
Details.atributo_damage:ClearTempTables()
for _, combatObject in ipairs(Details.tabela_historico.tabelas) do
---@cast combatObject combat
Details:DestroyCombat(combatObject)
for i = #Details.tabela_historico.tabelas, 1, -1 do
---@type combat
local combtaObjectRemoved = table.remove(Details.tabela_historico.tabelas, i)
Details:DestroyCombat(combtaObjectRemoved)
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
--the current combat when finished will be moved to the first index of "tabela_historico.tabelas", need the check if the current combat was already destroyed
if (not Details.tabela_vigente.__destroyed) then
Details:DestroyCombat(Details.tabela_vigente)
if (Details.tabela_vigente == Details.tabela_historico.tabelas[1]) then
table.remove(Details.tabela_historico.tabelas, 1)
end
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
@@ -525,15 +533,16 @@ function segmentClass:ResetAllCombatData()
-- novo container de historico
Details.tabela_historico = segmentClass:CreateNewSegmentDatabase() --joga fora a tabela antiga e cria uma nova
--novo container para armazenar pets
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdateContainerCombatentes()
Details.container_pets:BuscarPets()
-- nova tabela do overall e current
Details.tabela_overall = combatClass:NovaTabela() --joga fora a tabela antiga e cria uma nova
-- cria nova tabela do combate atual
Details.tabela_vigente = combatClass:NovaTabela(nil, Details.tabela_overall)
--novo container para armazenar pets
Details.tabela_pets = Details.container_pets:NovoContainer()
Details:UpdateContainerCombatentes()
Details.container_pets:BuscarPets()
---@type instance[]
local allInstances = Details:GetAllInstances()