breakdown 2.0

This commit is contained in:
Tercio Jose
2023-04-09 22:26:05 -03:00
parent e55a818fb7
commit 50d848e1d1
21 changed files with 2847 additions and 1911 deletions
+135 -2
View File
@@ -4,7 +4,6 @@ local detailsFramework = _G.DetailsFramework
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0", true)
local addonName, Details222 = ...
Details222.Mixins.ActorMixin = {
---return a spellContainer from an actor
---@param actor actor
@@ -39,4 +38,138 @@ Details222.Mixins.ActorMixin = {
return spellTable
end
end,
}
---return a table containing pet names
---@param actor actor
---@return table<number, string>
GetPets = function(actor)
return actor.pets
end,
---return a table containing spellTables
---@param actor actor
---@return table<number, spelltable>
GetSpellList = function(actor)
return actor.spells._ActorTable
end,
---this function sums all the targets of all spellTables conteining on a 'breakdownspelldata'
---@param actor actor
---@param bkSpellData breakdownspelldata
---@param targetTableName string
---@return table<string, number>
BuildSpellTargetFromBreakdownSpellData = function(actor, bkSpellData, targetTableName)
targetTableName = targetTableName or "targets"
local spellTables = bkSpellData.spellTables
---@type table<string, number> store the index of the target name in the result table
local cacheIndex = {}
---@type table<string, number> store the result which is returned by this function
local result = {}
for i = 1, #spellTables do
---@type spelltable
local spellTable = spellTables[i]
---@type table<string, number>
local targets = spellTable[targetTableName]
for targetName, value in pairs(targets) do
local index = cacheIndex[targetName]
if (index) then
result[index][2] = result[index][2] + value
else
result[#result+1] = {targetName, value}
cacheIndex[targetName] = #result
end
end
end
table.sort(result, function(t1, t2)
return t1[2] > t2[2]
end)
return result
end,
---this function receives a target table name and return a table containing the targets and the damage done in order of bigger to lower value
---@param actor actor
---@param spellTable spelltable
---@param targetTableName string
---@return table<string, number>
BuildSpellTargetFromSpellTable = function(actor, spellTable, targetTableName)
targetTableName = targetTableName or "targets"
---@type table<string, number>[] store the result which is returned by this function
local result = {}
---@type table<string, number>
local targets = spellTable[targetTableName]
for targetName, value in pairs(targets) do
---@cast targetName string
---@cast value number
result[#result+1] = {targetName, value}
end
table.sort(result, function(t1, t2)
return t1[2] > t2[2]
end)
return result
end,
}
--need to transfer the function bellow to another file
--this are the fields from spellTable that can be summed
local spellTable_FieldsToSum = {
["counter"] = true,
["total"] = true,
["c_amt"] = true,
["c_min"] = true,
["c_max"] = true,
["c_dmg"] = true,
["n_amt"] = true,
["n_dmg"] = true,
["n_min"] = true,
["n_max"] = true,
["successful_casted"] = true,
["g_amt"] = true,
["g_dmg"] = true,
["r_amt"] = true,
["r_dmg"] = true,
["b_amt"] = true,
["b_dmg"] = true,
["a_amt"] = true,
["a_dmg"] = true,
}
---get the array of spelltables and sum each spellTable with the first spellTable found or on targetTable
---only sum the keys found in the spellTable_FieldsToSum table
---@param spellTables table<number, spelltable>[]
---@param targetTable table
function Details:SumSpellTables(spellTables, targetTable)
local amtSpellTables = #spellTables
if (amtSpellTables == 0) then
return
end
targetTable = targetTable or spellTables[1]
for i = 1, amtSpellTables do
---@type spelltable
local spellTable = spellTables[i]
if (spellTable) then
for key, value in pairs(spellTable) do
if (spellTable_FieldsToSum[key]) then
targetTable[key] = (targetTable[key] or 0) + value
end
end
end
end
end
+12
View File
@@ -1407,6 +1407,18 @@ local default_global_data = {
},
},
--breakdown spell tab
breakdown_spell_tab = {
blockcontainer_width = 430,
blockcontainer_height = 270,
blockspell_height = 50,
blockspellline_height = 13,
blockspell_spark_offset = -2,
blockspell_spark_width = 2,
blockspell_spark_show = true,
blockspell_spark_color = {1, 1, 1, 0.7},
},
--profile by spec
profile_by_spec = {},