Renamed variables, code cleanup

This commit is contained in:
Tercio Jose
2023-05-21 10:28:29 -03:00
parent a20a4737db
commit fa0d1e1d08
12 changed files with 975 additions and 1237 deletions
+15 -15
View File
@@ -552,22 +552,22 @@
-- update tooltip function --
if (self.id) then
local school = _detalhes.spell_school_cache [self.nome]
local school = _detalhes.spell_school_cache[self.nome]
if (school) then
local school_color = _detalhes.school_colors [school]
if (not school_color) then
school_color = _detalhes.school_colors ["unknown"]
local schoolColor = Details.spells_school[school]
if (not schoolColor) then
schoolColor = Details.spells_school[1]
end
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(school_color)
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
else
local color = _detalhes.school_colors ["unknown"]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(color)
local schoolColor = Details.spells_school[1]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
end
else
actor_class_color_r, actor_class_color_g, actor_class_color_b = self:GetBarColor()
end
self:RefreshBarra2 (row, instance, previous_table, is_forced, row_value, index, row_container)
self:RefreshBarra2(row, instance, previous_table, is_forced, row_value, index, row_container)
end
@@ -644,16 +644,16 @@
if (from_resize) then
if (self.id) then
local school = _detalhes.spell_school_cache [self.nome]
local school = _detalhes.spell_school_cache[self.nome]
if (school) then
local school_color = _detalhes.school_colors [school]
if (not school_color) then
school_color = _detalhes.school_colors ["unknown"]
local schoolColor = Details.spells_school[school]
if (not schoolColor) then
schoolColor = Details.spells_school[1]
end
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(school_color)
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
else
local color = _detalhes.school_colors ["unknown"]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(color)
local schoolColor = Details.spells_school[1]
actor_class_color_r, actor_class_color_g, actor_class_color_b = unpack(schoolColor.decimals)
end
else
actor_class_color_r, actor_class_color_g, actor_class_color_b = self:GetBarColor()
+4 -4
View File
@@ -1677,12 +1677,12 @@ end
end
local _, _, icon = GetSpellInfo(self.damage_spellid)
local school_color = Details.school_colors [self.spellschool]
if (not school_color) then
school_color = Details.school_colors ["unknown"]
local spellSchoolColor = Details.spells_school[self.spellschool] and Details.spells_school[self.spellschool].decimals
if (not spellSchoolColor) then
spellSchoolColor = Details.spells_school[1]
end
Details:SetBarColors(thisLine, instancia, unpack(school_color))
Details:SetBarColors(thisLine, instancia, unpack(spellSchoolColor))
thisLine.icone_classe:SetTexture(icon)
thisLine.icone_classe:SetTexCoord(0.078125, 0.921875, 0.078125, 0.921875)
+124 -206
View File
@@ -1,209 +1,127 @@
-- damage ability file
local _detalhes = _G.Details
local _
local addonName, Details222 = ...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--local pointers
local ipairs = ipairs
local pairs = pairs
local _UnitAura = UnitAura
local Details = _G.Details
local _
local addonName, Details222 = ...
local classDamageSpellTable = Details.habilidade_dano
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local habilidade_dano = _detalhes.habilidade_dano
local _recording_ability_with_buffs = false
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--internals
--_detalhes.habilidade_dano:NovaTabela(spellId)
function Details222.DamageSpells.CreateSpellTable(spellId, cleuToken)
return habilidade_dano:NovaTabela(spellId, nil, cleuToken)
end
--cleu token is used to check if the spell is a dot
function Details.CreateSpellTable(spellId, cleuToken)
return habilidade_dano:NovaTabela(spellId, nil, cleuToken)
end
function habilidade_dano:NovaTabela(id, link, token)
local _newDamageSpell = {
total = 0, --total damage
counter = 0, --counter
id = id, --spellid
successful_casted = 0, --successful casted times (only for enemies)
--min damage made by normal hits
n_min = 0,
--max damage made by normal hits
n_max = 0,
--amount normal hits
n_amt = 0,
--total damage of normal hits
n_total = 0,
--critical hits
c_min = 0,
c_max = 0,
c_amt = 0,
c_total = 0,
--glacing hits
g_amt = 0,
g_dmg = 0,
--resisted
r_amt = 0,
r_dmg = 0,
--blocked
b_amt = 0,
b_dmg = 0,
--obsorved
a_amt = 0,
a_dmg = 0,
targets = {},
extra = {}
}
if (token == "SPELL_PERIODIC_DAMAGE") then
_detalhes:SpellIsDot (id)
end
return _newDamageSpell
end
function habilidade_dano:AddMiss (serial, nome, flags, who_nome, missType)
self.counter = self.counter + 1
self [missType] = (self [missType] or 0) + 1
self.targets [nome] = self.targets [nome] or 0
end
function habilidade_dano:Add (serial, nome, flag, amount, who_nome, resisted, blocked, absorbed, critical, glacing, token, isoffhand, isreflected)
self.total = self.total + amount
--if is reflected add the spellId into the extra table
--this is too show which spells has been reflected
if (isreflected) then
self.extra [isreflected] = (self.extra [isreflected] or 0) + amount
end
self.targets [nome] = (self.targets [nome] or 0) + amount
self.counter = self.counter + 1
if (resisted and resisted > 0) then
self.r_dmg = self.r_dmg+amount --tabela.total o total de dano
self.r_amt = self.r_amt+1 --tabela.total o total de dano
end
if (blocked and blocked > 0) then
self.b_dmg = self.b_dmg+amount --amount o total de dano
self.b_amt = self.b_amt+1 --amount o total de dano
end
if (absorbed and absorbed > 0) then
self.a_dmg = self.a_dmg+amount --amount o total de dano
self.a_amt = self.a_amt+1 --amount o total de dano
end
if (glacing) then
self.g_dmg = self.g_dmg+amount --amount o total de dano
self.g_amt = self.g_amt+1 --amount o total de dano
elseif (critical) then
self.c_total = self.c_total+amount --amount o total de dano
self.c_amt = self.c_amt+1 --amount o total de dano
if (amount > self.c_max) then
self.c_max = amount
end
if (self.c_min > amount or self.c_min == 0) then
self.c_min = amount
end
else
self.n_total = self.n_total+amount
self.n_amt = self.n_amt+1
if (amount > self.n_max) then
self.n_max = amount
end
if (self.n_min > amount or self.n_min == 0) then
self.n_min = amount
end
end
if (_recording_ability_with_buffs) then
if (who_nome == _detalhes.playername) then --aqui ele vai detalhar tudo sobre a magia usada
local buffsNames = _detalhes.SoloTables.BuffsTableNameCache
local SpellBuffDetails = self.BuffTable
if (not SpellBuffDetails) then
self.BuffTable = {}
SpellBuffDetails = self.BuffTable
end
if (token == "SPELL_PERIODIC_DAMAGE") then
--precisa ver se ele tinha na hora que aplicou
local SoloDebuffPower = _detalhes.tabela_vigente.SoloDebuffPower
if (SoloDebuffPower) then
local ThisDebuff = SoloDebuffPower [self.id]
if (ThisDebuff) then
local ThisDebuffOnTarget = ThisDebuff [serial]
if (ThisDebuffOnTarget) then
for index, buff_name in ipairs(ThisDebuffOnTarget.buffs) do
local buff_info = SpellBuffDetails [buff_name] or {["counter"] = 0, ["total"] = 0, ["critico"] = 0, ["critico_dano"] = 0}
buff_info.counter = buff_info.counter+1
buff_info.total = buff_info.total+amount
if (critical ~= nil) then
buff_info.critico = buff_info.critico+1
buff_info.critico_dano = buff_info.critico_dano+amount
end
SpellBuffDetails [buff_name] = buff_info
end
end
end
end
else
for BuffName, _ in pairs(_detalhes.Buffs.BuffsTable) do
local name = _UnitAura ("player", BuffName)
if (name ~= nil) then
local buff_info = SpellBuffDetails [name] or {["counter"] = 0, ["total"] = 0, ["critico"] = 0, ["critico_dano"] = 0}
buff_info.counter = buff_info.counter+1
buff_info.total = buff_info.total+amount
if (critical ~= nil) then
buff_info.critico = buff_info.critico+1
buff_info.critico_dano = buff_info.critico_dano+amount
end
SpellBuffDetails [name] = buff_info
end
end
end
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--core
function _detalhes:UpdateDamageAbilityGears()
_recording_ability_with_buffs = _detalhes.RecordPlayerAbilityWithBuffs
end
--[[
if (isoffhand) then
self.off_amt = self.off_amt + 1
self.off_dmg = self.off_dmg + amount
else
self.main_amt = self.main_amt + 1
function Details222.DamageSpells.CreateSpellTable(spellId, cleuToken)
return classDamageSpellTable:NovaTabela(spellId, nil, cleuToken)
end
--]]
--cleu token is used to check if the spell is a dot
function Details.CreateSpellTable(spellId, cleuToken)
return classDamageSpellTable:NovaTabela(spellId, nil, cleuToken)
end
---create a spelltable to store the damage of a spell
---@param spellId number
---@param link nil
---@param token string
---@return spelltable
function classDamageSpellTable:NovaTabela(spellId, link, token)
---@type spelltable
local spellTable = {
total = 0, --total damage
counter = 0, --counter
id = spellId, --spellid
successful_casted = 0, --successful casted times (only for enemies)
--min damage made by normal hits
n_min = 0,
--max damage made by normal hits
n_max = 0,
--amount normal hits
n_amt = 0,
--total damage of normal hits
n_total = 0,
--critical hits
c_min = 0,
c_max = 0,
c_amt = 0,
c_total = 0,
--glacing hits
g_amt = 0,
g_dmg = 0,
--resisted
r_amt = 0,
r_dmg = 0,
--blocked
b_amt = 0,
b_dmg = 0,
--obsorved
a_amt = 0,
a_dmg = 0,
targets = {},
extra = {}
}
if (token == "SPELL_PERIODIC_DAMAGE") then
Details:SpellIsDot(spellId)
end
return spellTable
end
function classDamageSpellTable:AddMiss(serial, targetName, targetFlags, sourceName, missType)
self.counter = self.counter + 1
self[missType] = (self[missType] or 0) + 1
self.targets[targetName] = self.targets[targetName] or 0
end
function classDamageSpellTable:Add(targetSerial, targetName, targetFlags, amount, sourceName, resisted, blocked, absorbed, critical, glacing, token, bIsOffhand, bIsReflected)
self.total = self.total + amount
--when reflected add the spellId into the extra table to show which spells has reflected
if (bIsReflected) then
self.extra[bIsReflected] = (self.extra[bIsReflected] or 0) + amount
end
self.targets[targetName] = (self.targets[targetName] or 0) + amount
self.counter = self.counter + 1
if (resisted and resisted > 0) then
self.r_dmg = self.r_dmg + amount
self.r_amt = self.r_amt + 1
end
if (blocked and blocked > 0) then
self.b_dmg = self.b_dmg + amount
self.b_amt = self.b_amt + 1
end
if (absorbed and absorbed > 0) then
self.a_dmg = self.a_dmg + amount
self.a_amt = self.a_amt + 1
end
if (glacing) then
self.g_dmg = self.g_dmg + amount
self.g_amt = self.g_amt + 1
elseif (critical) then
self.c_total = self.c_total + amount
self.c_amt = self.c_amt + 1
if (amount > self.c_max) then
self.c_max = amount
end
if (self.c_min > amount or self.c_min == 0) then
self.c_min = amount
end
else
self.n_total = self.n_total + amount
self.n_amt = self.n_amt + 1
if (amount > self.n_max) then
self.n_max = amount
end
if (self.n_min > amount or self.n_min == 0) then
self.n_min = amount
end
end
end
+8 -9
View File
@@ -12,10 +12,10 @@ local addonName, Details222 = ...
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--constants
local container_damage = _detalhes.container_type.CONTAINER_DAMAGE_CLASS
local container_heal = _detalhes.container_type.CONTAINER_HEAL_CLASS
local container_energy = _detalhes.container_type.CONTAINER_ENERGY_CLASS
local container_misc = _detalhes.container_type.CONTAINER_MISC_CLASS
local classDamage = _detalhes.container_type.CONTAINER_DAMAGE_CLASS
local classHeal = _detalhes.container_type.CONTAINER_HEAL_CLASS
local classEnergy = _detalhes.container_type.CONTAINER_ENERGY_CLASS
local classUtility = _detalhes.container_type.CONTAINER_MISC_CLASS
local habilidade_dano = _detalhes.habilidade_dano
local habilidade_cura = _detalhes.habilidade_cura
local habilidade_e_energy = _detalhes.habilidade_e_energy
@@ -44,7 +44,6 @@ local addonName, Details222 = ...
return self._ActorTable[spellId]
end
---return a table containing keys as spellid and value as spelltable
---@return table<number, table>
function container_habilidades:GetRawSpellTable()
@@ -113,16 +112,16 @@ local addonName, Details222 = ...
end
function container_habilidades:FuncaoDeCriacao (tipo)
if (tipo == container_damage) then
if (tipo == classDamage) then
return habilidade_dano.NovaTabela
elseif (tipo == container_heal) then
elseif (tipo == classHeal) then
return habilidade_cura.NovaTabela
elseif (tipo == container_energy) then
elseif (tipo == classEnergy) then
return habilidade_e_energy.NovaTabela
elseif (tipo == container_misc) then
elseif (tipo == classUtility) then
return habilidade_misc.NovaTabela
end