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.

412 lines
14 KiB

4 years ago
--[[ Declare all Details classes and container indexes ]]
do
---@type details
local Details = _G.Details
local addonName, Details222 = ...
4 years ago
local setmetatable = setmetatable
-------- time machine controla o tempo em combate dos jogadores
Details.timeMachine = {}
Details.timeMachine.__index = Details.timeMachine
setmetatable(Details.timeMachine, Details)
4 years ago
-------- classe da tabela que armazenar� todos os combates efetuados
Details.historico = {}
Details.historico.__index = Details.historico
setmetatable(Details.historico, Details)
4 years ago
---------------- classe da tabela onde ser�o armazenados cada combate efetuado
Details.combate = {}
Details.combate.__index = Details.combate
setmetatable(Details.combate, Details.historico)
4 years ago
------------------------ armazenas classes de jogadores ou outros derivados
Details.container_combatentes = {}
Details.container_combatentes.__index = Details.container_combatentes
setmetatable(Details.container_combatentes, Details.combate)
4 years ago
-------------------------------- dano das habilidades.
Details.atributo_damage = {}
Details.atributo_damage.__index = Details.atributo_damage
setmetatable(Details.atributo_damage, Details.container_combatentes)
4 years ago
-------------------------------- cura das habilidades.
Details.atributo_heal = {}
Details.atributo_heal.__index = Details.atributo_heal
setmetatable(Details.atributo_heal, Details.container_combatentes)
4 years ago
-------------------------------- e_energy ganha
Details.atributo_energy = {}
Details.atributo_energy.__index = Details.atributo_energy
setmetatable(Details.atributo_energy, Details.container_combatentes)
4 years ago
-------------------------------- outros atributos
Details.atributo_misc = {}
Details.atributo_misc.__index = Details.atributo_misc
setmetatable(Details.atributo_misc, Details.container_combatentes)
4 years ago
-------------------------------- atributos customizados
Details.atributo_custom = {}
Details.atributo_custom.__index = Details.atributo_custom
setmetatable(Details.atributo_custom, Details.container_combatentes)
4 years ago
-------------------------------- armazena as classes de habilidades usadas pelo combatente
Details.container_habilidades = {}
Details.container_habilidades.__index = Details.container_habilidades
setmetatable(Details.container_habilidades, Details.combate)
4 years ago
---------------------------------------- classe das habilidades que d�o cura
Details.habilidade_cura = {}
Details.habilidade_cura.__index = Details.habilidade_cura
setmetatable(Details.habilidade_cura, Details.container_habilidades)
4 years ago
---------------------------------------- classe das habilidades que d�o danos
Details.habilidade_dano = {}
Details.habilidade_dano.__index = Details.habilidade_dano
setmetatable(Details.habilidade_dano, Details.container_habilidades)
4 years ago
---------------------------------------- classe das habilidades que d�o e_energy
Details.habilidade_e_energy = {}
Details.habilidade_e_energy.__index = Details.habilidade_e_energy
setmetatable(Details.habilidade_e_energy, Details.container_habilidades)
4 years ago
---------------------------------------- classe das habilidades variadas
Details.habilidade_misc = {}
Details.habilidade_misc.__index = Details.habilidade_misc
setmetatable(Details.habilidade_misc, Details.container_habilidades)
4 years ago
---------------------------------------- classe dos alvos das habilidads
Details.alvo_da_habilidade = {}
Details.alvo_da_habilidade.__index = Details.alvo_da_habilidade
setmetatable(Details.alvo_da_habilidade, Details.container_combatentes)
---return the class object for the given displayId (attributeId)
---@param displayId attributeid
---@return table
function Details:GetDisplayClassByDisplayId(displayId)
if (displayId == DETAILS_ATTRIBUTE_DAMAGE) then
return Details.atributo_damage
elseif (displayId == DETAILS_ATTRIBUTE_HEAL) then
return Details.atributo_heal
elseif (displayId == DETAILS_ATTRIBUTE_ENERGY) then
return Details.atributo_energy
elseif (displayId == DETAILS_ATTRIBUTE_MISC) then
return Details.atributo_misc
elseif (displayId == DETAILS_ATTRIBUTE_CUSTOM) then
return Details.atributo_custom
end
return {}
end
4 years ago
--[[ Armazena os diferentes tipos de containers ]] --[[ Container Types ]]
Details.container_type = {
4 years ago
CONTAINER_PLAYERNPC = 1,
CONTAINER_DAMAGE_CLASS = 2,
CONTAINER_HEAL_CLASS = 3,
CONTAINER_HEALTARGET_CLASS = 4,
CONTAINER_FRIENDLYFIRE = 5,
CONTAINER_DAMAGETARGET_CLASS = 6,
CONTAINER_ENERGY_CLASS = 7,
CONTAINER_ENERGYTARGET_CLASS = 8,
CONTAINER_MISC_CLASS = 9,
CONTAINER_MISCTARGET_CLASS = 10,
CONTAINER_ENEMYDEBUFFTARGET_CLASS = 11
}
local UnitName = UnitName
local GetRealmName = GetRealmName
3 years ago
local initialSpecListOverride = {
[1455] = 251, --dk
[1456] = 577, --demon hunter
[1447] = 102, --druid
[1465] = 1467, --evoker
[1448] = 253, --hunter
[1449] = 63, --mage
[1450] = 269, --monk
[1451] = 70, --paladin
[1452] = 258, --priest
[1453] = 260, --rogue
[1444] = 262, --shaman
[1454] = 266, --warlock
[1446] = 71, --warrior
}
---@param self actor
---@param specId number
3 years ago
function Details:SetSpecId(specId)
self.spec = initialSpecListOverride[specId] or specId
end
---@param self details|actor
---@param actor actor?
function Details:Name(actor)
4 years ago
return self.nome or actor and actor.nome
end
---Retrieves the name of the actor.
---If the name is not available in the current object (self), it checks the provided actor object.
---@param actor (optional) The actor object to retrieve the name from.
---@return The name of the actor.
function Details:GetName(actor)
4 years ago
return self.nome or actor and actor.nome
end
---Retrieves the name of the actor without the realm information.
---If the name is not available in the current object (self), it checks the provided actor object.
---@param actor (optional) The actor object to retrieve the name from.
---@return The name of the actor without the realm information.
function Details:GetNameNoRealm(actor)
4 years ago
local name = self.nome or actor and actor.nome
return Details:GetOnlyName(name)
end
---Retrieves the display name of the actor.
---If the display name is not available in the current object (self), it checks the provided actor object.
---@param actor actor The actor object to retrieve the display name from.
---@return string displayName display name of the actor.
function Details:GetDisplayName(actor)
4 years ago
return self.displayName or actor and actor.displayName
end
3 years ago
---Sets the display name of the actor.
---If the new display name is not provided, it sets the display name of the current object (self) to the provided actor object.
---@param actor actor The actor object to set the display name for.
---@param newDisplayName string The new display name to set.
3 years ago
function Details:SetDisplayName(actor, newDisplayName)
if (not newDisplayName) then
local thisActor = self
---@cast thisActor actor
local displayName = tostring(actor)
thisActor.displayName = displayName
3 years ago
else
actor.displayName = newDisplayName
end
end
function Details:GetOnlyName(string)
4 years ago
if (string) then
3 years ago
return string:gsub(("%-.*"), "")
4 years ago
end
3 years ago
return self.nome:gsub(("%-.*"), "")
4 years ago
end
function Details:RemoveOwnerName(string)
4 years ago
if (string) then
3 years ago
return string:gsub((" <.*"), "")
4 years ago
end
3 years ago
return self.nome:gsub((" <.*"), "")
4 years ago
end
function Details:GetCLName(id)
local name, realm = UnitName(id)
4 years ago
if (name) then
if (realm and realm ~= "") then
name = name .. "-" .. realm
end
return name
end
end
local _, _, _, toc = GetBuildInfo() --check game version to know which version of GetFullName to use
---return the class file name of the unit passed
local getFromCache = Details222.ClassCache.GetClassFromCache
local Ambiguate = Ambiguate
local UnitClass = UnitClass
function Details:GetUnitClass(unitId)
local class, classFileName = getFromCache(unitId)
if (not classFileName) then
unitId = Ambiguate(unitId, "none")
classFileName = select(2, UnitClass(unitId))
end
return classFileName
end
function Details:Ambiguate(unitName)
--if (toc >= 100200) then
unitName = Ambiguate(unitName, "none")
--end
return unitName
end
---return the class name, class file name and class id of the unit passed
function Details:GetUnitClassFull(unitId)
unitId = Ambiguate(unitId, "none")
local locClassName, classFileName, classId = UnitClass(unitId)
return locClassName, classFileName, classId
end
local UnitFullName = UnitFullName
--Details:GetCurrentCombat():GetActor(DETAILS_ATTRIBUTE_DAMAGE, Details:GetFullName("player")):GetSpell(1)
---create a CLEU compatible name of the unit passed
---return string is in the format "playerName-realmName"
---the string will also be ambiguated using the ambiguateString passed
---@param unitId any
---@param ambiguateString any
function Details:GetFullName(unitId, ambiguateString) --not in use, get replace by Details.GetCLName a few lines below
--UnitFullName is guarantee to return the realm name of the unit queried
local playerName, realmName = UnitFullName(unitId)
if (playerName) then
if (not realmName) then
realmName = GetRealmName()
end
realmName = realmName:gsub("[%s-]", "")
playerName = playerName .. "-" .. realmName
if (ambiguateString) then
playerName = Ambiguate(playerName, ambiguateString)
end
return playerName
end
end
function Details:GetUnitNameForAPI(unitId)
return Details:GetFullName(unitId, "none")
end
--if (toc < 100200) then
Details.GetFullName = Details.GetCLName
--end
function Details:Class(actor)
4 years ago
return self.classe or actor and actor.classe
end
function Details:GetActorClass(actor)
4 years ago
return self.classe or actor and actor.classe
end
function Details:GetGUID(actor)
4 years ago
return self.serial or actor and actor.serial
end
function Details:GetFlag(actor)
4 years ago
return self.flag_original or actor and actor.flag_original
end
function Details:GetSpells()
return self.spells._ActorTable
end
function Details:GetActorSpells()
4 years ago
return self.spells._ActorTable
end
function Details:GetSpell(spellid)
4 years ago
return self.spells._ActorTable [spellid]
end
---return an array of pet names
---@return table
function Details:GetPets()
return self.pets
end
---return an array of pet names
---@return table
function Details:Pets()
4 years ago
return self.pets
end
function Details:GetSpec(actor)
return self.spec or actor and actor.spec
end
function Details:Spec(actor)
return self.spec or actor and actor.spec
end
---add the class color to the string passed
---@param thisString string
---@param class string
---@return string
function Details:AddColorString(thisString, class)
--check if the class colors exists
local classColors = _G["RAID_CLASS_COLORS"]
if (classColors) then
local color = classColors[class]
--check if the player name is valid
if (type(thisString) == "string" and color) then
thisString = "|c" .. color.colorStr .. thisString .. "|r"
return thisString
end
end
--if failed, return the string without modifications
return thisString
end
---add the role icon to the string passed
---@param thisString string
---@param role string
---@param size number|nil default is 14
---@return string
function Details:AddRoleIcon(thisString, role, size)
--check if is a valid role
local roleIcon = Details.role_texcoord [role]
if (type(thisString) == "string" and roleIcon and role ~= "NONE") then
--add the role icon
size = size or 14
thisString = "|TInterface\\LFGFRAME\\UI-LFG-ICON-ROLES:" .. size .. ":" .. size .. ":0:0:256:256:" .. roleIcon .. "|t " .. thisString
return thisString
end
--if failed, return the string without modifications
return thisString
end
---add the spec icon or class icon to the string passed
---@param thisString string
---@param class string|nil
---@param spec number|nil
---@param iconSize number|nil default is 16
---@param useAlphaIcons boolean|nil default is false
---@return string
function Details:AddClassOrSpecIcon(thisString, class, spec, iconSize, useAlphaIcons)
iconSize = iconSize or 16
if (spec) then
local specString = ""
local L, R, T, B = unpack(Details.class_specs_coords[spec])
if (L) then
if (useAlphaIcons) then
specString = "|TInterface\\AddOns\\Details\\images\\spec_icons_normal_alpha:" .. iconSize .. ":" .. iconSize .. ":0:0:512:512:" .. (L * 512) .. ":" .. (R * 512) .. ":" .. (T * 512) .. ":" .. (B * 512) .. "|t"
else
specString = "|TInterface\\AddOns\\Details\\images\\spec_icons_normal:" .. iconSize .. ":" .. iconSize .. ":0:0:512:512:" .. (L * 512) .. ":" .. (R * 512) .. ":" .. (T * 512) .. ":" .. (B * 512) .. "|t"
end
return specString .. " " .. thisString
end
end
if (class) then
local classString = ""
local L, R, T, B = unpack(Details.class_coords[class])
if (L) then
local imageSize = 128
if (useAlphaIcons) then
classString = "|TInterface\\AddOns\\Details\\images\\classes_small_alpha:" .. iconSize .. ":" .. iconSize .. ":0:0:" .. imageSize .. ":" .. imageSize .. ":" .. (L * imageSize) .. ":" .. (R * imageSize) .. ":" .. (T * imageSize) .. ":" .. (B * imageSize) .. "|t"
else
classString = "|TInterface\\AddOns\\Details\\images\\classes_small:" .. iconSize .. ":" .. iconSize .. ":0:0:" .. imageSize .. ":" .. imageSize .. ":" .. (L * imageSize) .. ":" .. (R * imageSize) .. ":" .. (T * imageSize) .. ":" .. (B * imageSize) .. "|t"
end
return classString .. " " .. thisString
end
end
return thisString
end
3 years ago
--inherits to all actors without placing it on _detalhes namespace.
Details.container_combatentes.guid = Details.GetGUID
Details.container_combatentes.name = Details.GetName
Details.container_combatentes.class = Details.GetActorClass
Details.container_combatentes.flag = Details.GetFlag
4 years ago
end