Sort by critpercent and casts are now working; new class 'SpellTable'
This commit is contained in:
+4
-5
@@ -284,7 +284,6 @@
|
||||
---@field GetCombat fun(self: details) : combat
|
||||
---@field GetSpellSchoolFormatedName fun(self: details, spellschool: number) : string
|
||||
---@field CommaValue fun(self: details, number: number) : string
|
||||
---@field SumSpellTables fun(self: details, spellTables: spelltable[], targetTable: table)
|
||||
---@field CreateEventListener fun(self: details) : table
|
||||
|
||||
---@class detailseventlistener : table
|
||||
@@ -301,9 +300,9 @@
|
||||
---@field GetEndTime fun(combat: combat, time: number)
|
||||
---@field SetEndTime fun(combat: combat, time: number)
|
||||
---@field CopyDeathsFrom fun(combat1: combat, combat2: combat, bMythicPlus: boolean) copy the deaths from combat2 to combat1, use true on bMythicPlus if the combat is from a mythic plus run
|
||||
---@field GetContainer fun(combat: combat, containerType: number) get an actor container, containerType can be 1 for damage, 2 heal, 3 energy, 4 utility
|
||||
---@field GetSpellCastAmount fun(combat: combat, actorName: string, spellId: number) get the amount of times a spell was casted
|
||||
---@field GetSpellUptime fun(combat: combat, actorName: string, spellId: number, auraType: string|nil) get the uptime of a buff or debuff
|
||||
---@field GetContainer fun(combat: combat, containerType: number) : table get an actor container, containerType can be 1 for damage, 2 heal, 3 energy, 4 utility
|
||||
---@field GetSpellCastAmount fun(combat: combat, actorName: string, spellId: number) : number get the amount of times a spell was casted
|
||||
---@field GetSpellUptime fun(combat: combat, actorName: string, spellId: number, auraType: string|nil) : number get the uptime of a buff or debuff
|
||||
---@field is_mythic_dungeon_trash boolean
|
||||
---@field is_mythic_dungeon_run_id number
|
||||
---@field is_mythic_dungeon_segment boolean
|
||||
@@ -459,7 +458,7 @@
|
||||
---@field AddFrameToHeaderAlignment fun(self: breakdownspellbar, frame: uiobject)
|
||||
---@field AlignWithHeader fun(self: breakdownspellbar, header: table, align: string|"left")
|
||||
|
||||
---@class breakdownspelldata : table
|
||||
---@class breakdownspelldata : table, spelltablemixin
|
||||
---@field id number main spellId to be used on the tooltip, name and icon
|
||||
---@field total number total done by the spell
|
||||
---@field counter number amount of hits
|
||||
|
||||
@@ -114,6 +114,7 @@ frames\window_statistics.lua
|
||||
frames\window_aura_tracker.lua
|
||||
|
||||
classes\class_error.lua
|
||||
classes\class_spelltable.lua
|
||||
classes\class_combat.lua
|
||||
classes\class_damage.lua
|
||||
classes\class_spelldamage.lua
|
||||
|
||||
+5
-2
@@ -3339,8 +3339,11 @@ function DF:OpenInterfaceProfile()
|
||||
end
|
||||
|
||||
-----------------------------
|
||||
--safe copy from blizz api
|
||||
function DF:Mixin(object, ...)
|
||||
---copy all members from #2 ... to #1 object
|
||||
---@param object table
|
||||
---@param ... any
|
||||
---@return any
|
||||
function DF:Mixin(object, ...) --safe copy from blizz api
|
||||
for i = 1, select("#", ...) do
|
||||
local mixin = select(i, ...)
|
||||
for key, value in pairs(mixin) do
|
||||
|
||||
@@ -4569,6 +4569,7 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of
|
||||
spellTables = {spellTable}, --sub spell tables to show if the spell is expanded
|
||||
petNames = {""},
|
||||
}
|
||||
detailsFramework:Mixin(bkSpellData, Details.SpellTableMixin)
|
||||
|
||||
breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData
|
||||
alreadyAdded[spellName] = #breakdownSpellDataList
|
||||
@@ -4613,6 +4614,8 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of
|
||||
spellTables = {spellTable},
|
||||
petNames = {petName},
|
||||
}
|
||||
detailsFramework:Mixin(bkSpellData, Details.SpellTableMixin)
|
||||
|
||||
breakdownSpellDataList[#breakdownSpellDataList+1] = bkSpellData
|
||||
alreadyAdded[spellName] = #breakdownSpellDataList
|
||||
end
|
||||
@@ -4626,7 +4629,7 @@ function atributo_damage:MontaInfoDamageDone() --I guess this fills the list of
|
||||
for i = 1, #breakdownSpellDataList do
|
||||
---@type breakdownspelldata
|
||||
local bkSpellData = breakdownSpellDataList[i]
|
||||
Details:SumSpellTables(bkSpellData.spellTables, bkSpellData)
|
||||
Details.SpellTableMixin.SumSpellTables(bkSpellData.spellTables, bkSpellData)
|
||||
end
|
||||
|
||||
breakdownSpellDataList.totalValue = actorTotal
|
||||
|
||||
@@ -1975,7 +1975,7 @@ function atributo_heal:MontaInfoHealingDone()
|
||||
for i = 1, #actorSpellsSorted do
|
||||
---@type breakdownspelldata
|
||||
local bkSpellData = actorSpellsSorted[i]
|
||||
Details:SumSpellTables(bkSpellData.spellTables, bkSpellData)
|
||||
Details.SpellTableMixin.SumSpellTables(bkSpellData.spellTables, bkSpellData)
|
||||
end
|
||||
|
||||
--table.sort(actorSpellsSorted, Details.Sort2)
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
|
||||
local addonName, Details222 = ...
|
||||
local Details = Details
|
||||
local detailsFramework = DetailsFramework
|
||||
|
||||
--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_total"] = true,
|
||||
["n_amt"] = true,
|
||||
["n_total"] = 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,
|
||||
["totalabsorb"] = true,
|
||||
["absorbed"] = true,
|
||||
["overheal"] = true,
|
||||
["totaldenied"] = true,
|
||||
}
|
||||
|
||||
---@class spelltablemixin
|
||||
---@field GetCritPercent fun(spellTable: spelltable) : number
|
||||
---@field GetCritAverage fun(spellTable: spelltable) : number
|
||||
---@field SumSpellTables fun(spellTables: spelltable[], targetTable: table)
|
||||
---@field GetCastsAmount fun(spellTable: spelltable, actorName: string, combatObject: combat)
|
||||
|
||||
Details.SpellTableMixin = {
|
||||
---return the critical hits percent
|
||||
---@param spellTable spelltable
|
||||
---@return number
|
||||
GetCritPercent = function(spellTable)
|
||||
return (spellTable.c_amt / math.max(spellTable.counter, 0.0001)) * 100
|
||||
end,
|
||||
|
||||
---return the average value of critical hits
|
||||
---@param spellTable spelltable
|
||||
---@return number
|
||||
GetCritAverage = function(spellTable)
|
||||
return spellTable.c_total / math.max(spellTable.c_amt, 0.0001)
|
||||
end,
|
||||
|
||||
---return the amount of casts the spell had
|
||||
---@param spellTable spelltable
|
||||
---@param actorName string
|
||||
---@param combatObject combat
|
||||
---@return number
|
||||
GetCastsAmount = function(spellTable, actorName, combatObject)
|
||||
return combatObject:GetSpellCastAmount(actorName, spellTable.id)
|
||||
end,
|
||||
|
||||
---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 spelltable[]
|
||||
---@param targetTable table
|
||||
SumSpellTables = function(spellTables, targetTable)
|
||||
local amtSpellTables = #spellTables
|
||||
|
||||
if (amtSpellTables == 0) then
|
||||
return
|
||||
end
|
||||
|
||||
targetTable = targetTable or spellTables[1]
|
||||
|
||||
for i = 1, amtSpellTables do
|
||||
local spellTable = spellTables[i]
|
||||
if (spellTable) then
|
||||
for key, value in pairs(spellTable) do
|
||||
---@cast key string
|
||||
---@cast value number
|
||||
if (spellTable_FieldsToSum[key]) then
|
||||
targetTable[key] = (targetTable[key] or 0) + value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
}
|
||||
|
||||
--detailsFramework:Mixin(Details, Details.SpellTableMixin)
|
||||
@@ -14,7 +14,7 @@ local GameTooltip = GameTooltip
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local DF = DetailsFramework
|
||||
|
||||
--Expose the object to the global namespace
|
||||
--expose the object to the global namespace
|
||||
DetailsSpellBreakdownTab = spellsTab
|
||||
|
||||
local iconTableSummary = {
|
||||
@@ -43,14 +43,17 @@ Details.SpellGroups = {
|
||||
[193473] = 15407, --mind flay
|
||||
}
|
||||
|
||||
---@return actor
|
||||
function spellsTab.GetActor()
|
||||
return spellsTab.currentActor
|
||||
end
|
||||
|
||||
---@return combat
|
||||
function spellsTab.GetCombat()
|
||||
return spellsTab.combatObject
|
||||
end
|
||||
|
||||
---@return instance
|
||||
function spellsTab.GetInstance()
|
||||
return spellsTab.instance or Details:GetActiveWindowFromBreakdownWindow()
|
||||
end
|
||||
@@ -101,9 +104,9 @@ local spellContainerColumnInfo = {
|
||||
{name = "name", label = "spell name", width = 246, align = "left", enabled = true, offset = columnOffset},
|
||||
{name = "amount", label = "total", key = "total", selected = true, width = 50, align = "left", enabled = true, canSort = true, sortKey = "total", dataType = "number", order = "DESC", offset = columnOffset},
|
||||
{name = "persecond", label = "ps", key = "total", width = 50, align = "left", enabled = true, canSort = true, sortKey = "ps", offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "percent", label = "%", key = "percent", width = 50, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "percent", label = "%", key = "total", width = 50, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "casts", label = "casts", key = "casts", width = 40, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "critpercent", label = "crit %", key = "total", width = 40, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "critpercent", label = "crit %", key = "critpercent", width = 40, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "hits", label = "hits", key = "counter", width = 40, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "castavg", label = "cast avg", key = "total", width = 50, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
{name = "uptime", label = "uptime", key = "total", width = 45, align = "left", enabled = true, canSort = true, offset = columnOffset, order = "DESC", dataType = "number"},
|
||||
@@ -533,7 +536,7 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no
|
||||
critHitsBlock:Show()
|
||||
blockIndex = blockIndex + 1
|
||||
|
||||
local percent = criticalHitsAmt / math.max(totalHits, 0.0001) * 100
|
||||
local percent = Details.SpellTableMixin.GetCritPercent(spellTable)
|
||||
critHitsBlock:SetValue(percent)
|
||||
critHitsBlock.sparkTexture:SetPoint("left", critHitsBlock, "left", percent / 100 * critHitsBlock:GetWidth() + spellBreakdownSettings.blockspell_spark_offset, 0)
|
||||
critHitsBlock:SetStatusBarColor(1, 1, 1, .5)
|
||||
@@ -545,7 +548,7 @@ local onEnterBreakdownSpellBar = function(spellBar) --parei aqui: precisa por no
|
||||
blockLine2.leftText:SetText(Loc ["STRING_MINIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_min))
|
||||
blockLine2.rightText:SetText(Loc ["STRING_MAXIMUM_SHORT"] .. ": " .. Details:CommaValue(spellTable.c_max))
|
||||
|
||||
local critAverage = spellTable.c_total / math.max(criticalHitsAmt, 0.0001)
|
||||
local critAverage = Details.SpellTableMixin.GetCritAverage(spellTable)
|
||||
blockLine3.leftText:SetText(Loc ["STRING_AVERAGE"] .. ": " .. Details:CommaValue(critAverage))
|
||||
|
||||
local tempo = (elapsedTime * spellTable.c_total) / math.max(spellTable.total, 0.001)
|
||||
@@ -1346,15 +1349,24 @@ function spellsTab.CreateSpellScrollContainer(tabFrame)
|
||||
--get which column is currently selected and the sort order
|
||||
local columnIndex, order, key = scrollFrame.Header:GetSelectedColumn()
|
||||
|
||||
--key = "casts", key = "percent",
|
||||
--at this stage, data does not have the information about amount of casts and percent, it only has the total value, how to solve this?
|
||||
--need to pre process the data before sorting it
|
||||
--key "total" is workng as intended
|
||||
--examples of values from key: "casts", "percent", "total"
|
||||
|
||||
---@type string
|
||||
local keyToSort = "total"
|
||||
if (columnIndex == 1) then
|
||||
keyToSort = "total"
|
||||
local keyToSort = key
|
||||
if (keyToSort == "critpercent") then
|
||||
for i = 1, #data do
|
||||
---@type breakdownspelldata
|
||||
local bkSpellData = data[i]
|
||||
--as the bkSpellData is a copy from the actual spelltable from the actor spell, it can have methods inherited from spelltablemixin
|
||||
bkSpellData.critpercent = bkSpellData:GetCritPercent()
|
||||
end
|
||||
|
||||
elseif (keyToSort == "casts") then
|
||||
for i = 1, #data do
|
||||
---@type breakdownspelldata
|
||||
local bkSpellData = data[i]
|
||||
bkSpellData.casts = bkSpellData:GetCastsAmount(spellsTab.GetActor():Name(), spellsTab.GetCombat())
|
||||
end
|
||||
end
|
||||
|
||||
if (order == "DESC") then
|
||||
|
||||
+1
-57
@@ -121,60 +121,4 @@ Details222.Mixins.ActorMixin = {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
--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_total"] = true,
|
||||
["n_amt"] = true,
|
||||
["n_total"] = 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,
|
||||
["totalabsorb"] = true,
|
||||
["absorbed"] = true,
|
||||
["overheal"] = true,
|
||||
["totaldenied"] = 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 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
|
||||
local spellTable = spellTables[i]
|
||||
if (spellTable) then
|
||||
for key, value in pairs(spellTable) do
|
||||
---@cast key string
|
||||
---@cast value number
|
||||
if (spellTable_FieldsToSum[key]) then
|
||||
targetTable[key] = (targetTable[key] or 0) + value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user