Skip to content

Commit

Permalink
Added spellContainer:GetOrCreateSpell() this is an english alias for …
Browse files Browse the repository at this point in the history
…"PegaHabilidade"
  • Loading branch information
Tercioo committed Jul 28, 2023
1 parent a261864 commit f41ecaf
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 232 deletions.
73 changes: 69 additions & 4 deletions classes/class_damage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2994,7 +2994,9 @@ end
---@param totalAmount valueamount
---@param topAmount valueamount
---@param instanceObject instance
function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount, topAmount, instanceObject)
---@param onEnterFunc function|nil
---@param onLeaveFunc function|nil
function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount, topAmount, instanceObject, onEnterFunc, onLeaveFunc)
if (extraAmount and extraAmount > 0 and Details.combat_log.evoker_calc_damage) then
local extraStatusbar = thisLine.extraStatusbar
local initialOffset = 0
Expand Down Expand Up @@ -3026,10 +3028,25 @@ function Details:ShowExtraStatusbar(thisLine, amount, extraAmount, totalAmount,
--extraStatusbar:SetFrameStrata("TOOLTIP")
extraStatusbar:SetFrameLevel(thisLine:GetFrameLevel() + 1)

extraStatusbar.OnEnterCallback = onEnterFunc
extraStatusbar.OnLeaveCallback = onLeaveFunc

extraStatusbar:Show()
end
end

--when the script detect the extrastatusbar need to be show, it will call this function
local handleShowExtraStatusbar = function(thisLine, self, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue)
if (self.spec == 1473 and self.augmentedSpellsContainer) then
--prepare the extra bar to show the damage prediction to augmented evoker
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance, damageClass.PredictedAugSpellsOnEnter, damageClass.PredictedAugSpellsOnLeave)
thisLine.extraStatusbar.augmentedSpellsContainer = self.augmentedSpellsContainer
thisLine.extraStatusbar.instance = instance
else
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance)
end
end

function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue) --[[exported]]
thisLine.extraStatusbar:Hide()

Expand Down Expand Up @@ -3061,7 +3078,7 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre
Details.FadeHandler.Fader(thisLine, "out")

if (self.total_extra and self.total_extra > 0) then
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance)
handleShowExtraStatusbar(thisLine, self, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue)
end

return self:RefreshBarra(thisLine, instance)
Expand All @@ -3078,7 +3095,7 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre
thisLine.last_value = percent --reseta o ultimo valor da barra

if (self.total_extra and self.total_extra > 0) then
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance)
handleShowExtraStatusbar(thisLine, self, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue)
end

return self:RefreshBarra(thisLine, instance)
Expand All @@ -3099,7 +3116,7 @@ function Details:RefreshLineValue(thisLine, instance, previousData, isForceRefre
return self:RefreshBarra(thisLine, instance)
else
if (self.total_extra and self.total_extra > 0) then
Details:ShowExtraStatusbar(thisLine, self.total, self.total_extra, totalValue, topValue, instance)
handleShowExtraStatusbar(thisLine, self, instance, previousData, isForceRefresh, percent, bUseAnimations, totalValue, topValue)
end
end
end
Expand Down Expand Up @@ -3363,6 +3380,51 @@ function Details:RefreshBarra(thisLine, instance, fromResize) --[[exported]]
self:SetBarLeftText(thisLine, instance, enemy, arenaEnemy, arenaAlly, UsingCustomLeftText)
end


function damageClass.PredictedAugSpellsOnEnter(self)
if (not Details.show_aug_predicted_spell_damage) then
return
end

---@type spellcontainer
local spellContainer = self.augmentedSpellsContainer

GameCooltip:Preset(2)
---@type instance
local instance = self.instance

local combatObject = instance:GetCombat()
for spellId, spellTable in spellContainer:ListSpells() do
local spellName, _, spellTexture = GetSpellInfo(spellId)
if (spellName) then
GameCooltip:AddLine(spellName, Details:Format(spellTable.total))
GameCooltip:AddIcon(spellTexture, 1, 1, 18, 18)

--the damage sources are added into the targets table for reciclying
---@type table<actorname, valueamount>
local sources = spellTable.targets
for sourceName, sourceAmount in pairs(sources) do
GameCooltip:AddLine(sourceName, Details:Format(sourceAmount), 1, "yellow", "yellow", 10)
local actorObject = combatObject:GetActor(1, sourceName)
if (actorObject) then
local actorIcon = Details:GetActorIcon(actorObject)
if (actorIcon) then
GameCooltip:AddIcon(actorIcon.texture, 1, 1, 18, 18, actorIcon.coords.left, actorIcon.coords.right, actorIcon.coords.top, actorIcon.coords.bottom)
else
GameCooltip:AddIcon([[Interface\COMMON\Indicator-Gray]], 1, 1, 18, 18)
end
end
end
end
end

GameCooltip:ShowCooltip(self, "tooltip")
end

function damageClass.PredictedAugSpellsOnLeave(self)
GameCooltip:Hide()
end

--------------------------------------------- // TOOLTIPS // ---------------------------------------------

---------TOOLTIPS BIFURCA��O
Expand Down Expand Up @@ -6948,6 +7010,9 @@ function Details.refresh:r_atributo_damage(actorObject)

--restore metatable for the spell container
Details.refresh:r_container_habilidades(actorObject.spells)
if (actorObject.augmentedSpellsContainer) then
Details.refresh:r_container_habilidades(actorObject.augmentedSpellsContainer)
end
end

function Details.clear:c_atributo_damage (este_jogador)
Expand Down
11 changes: 7 additions & 4 deletions classes/container_spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ local habilidade_misc = _detalhes.habilidade_misc
---@param containerType number @the container type to be created (1 damage 2 heal 3 resources 4 utility)
---@return spellcontainer
function spellContainerClass:NovoContainer(containerType)
---@type spellcontainer
local spellContainer = {
funcao_de_criacao = spellContainerClass:GetSpellTableFuncCreator(containerType),
tipo = containerType,
Expand All @@ -56,6 +55,10 @@ local habilidade_misc = _detalhes.habilidade_misc
return spellContainer
end

function spellContainerClass:CreateSpellContainer(containerType)
return self:NovoContainer(containerType)
end

---get the spellTable for the passed spellId
---@param spellId number
---@return table
Expand Down Expand Up @@ -105,8 +108,8 @@ local habilidade_misc = _detalhes.habilidade_misc
return false
end

function spellContainerClass:GetOrCreateSpell(spellId, bCanCreateSpellIfMissing, cleuToken)
return self:PegaHabilidade(spellId, bCanCreateSpellIfMissing, cleuToken)
function spellContainerClass:PegaHabilidade(spellId, bCanCreateSpellIfMissing, cleuToken)
return self:GetOrCreateSpell(spellId, bCanCreateSpellIfMissing, cleuToken)
end

---create a new spelltable for the passed spellId
Expand All @@ -115,7 +118,7 @@ local habilidade_misc = _detalhes.habilidade_misc
---@param bCanCreateSpellIfMissing boolean
---@param cleuToken string
---@return spelltable|nil
function spellContainerClass:PegaHabilidade(spellId, bCanCreateSpellIfMissing, cleuToken)
function spellContainerClass:GetOrCreateSpell(spellId, bCanCreateSpellIfMissing, cleuToken)
---@type spelltable
local spellTable = self._ActorTable [spellId]

Expand Down
Loading

0 comments on commit f41ecaf

Please sign in to comment.