Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Modules/Config/DefenseSection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local _Config = Config.private
local Stats = ECSLoader:ImportModule("Stats")
---@type i18n
local i18n = ECSLoader:ImportModule("i18n")
---@type DataUtils
local DataUtils = ECSLoader:ImportModule("DataUtils")

function _Config:LoadDefenseSection()
return {
Expand Down Expand Up @@ -140,6 +142,7 @@ function _Config:LoadDefenseSection()
name = function() return i18n("Block Chance") end,
desc = function() return i18n("Shows/Hides the block chance.") end,
width = 1.5,
hidden = function() return not IsSpellKnown(107) end,
disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end,
get = function () return ExtendedCharacterStats.profile.defense.blockChance.display; end,
set = function (_, value)
Expand All @@ -153,6 +156,7 @@ function _Config:LoadDefenseSection()
name = function() return i18n("Block Value") end,
desc = function() return i18n("Shows/Hides the block value.") end,
width = 1.5,
hidden = function() return not DataUtils:CanBlock() end,
disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end,
get = function () return ExtendedCharacterStats.profile.defense.blockValue.display; end,
set = function (_, value)
Expand All @@ -166,6 +170,7 @@ function _Config:LoadDefenseSection()
name = function() return i18n("Parry Chance") end,
desc = function() return i18n("Shows/Hides the parry chance.") end,
width = 1.5,
hidden = function() return not DataUtils:CanParry() end,
disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end,
get = function () return ExtendedCharacterStats.profile.defense.parry.display; end,
set = function (_, value)
Expand All @@ -179,6 +184,7 @@ function _Config:LoadDefenseSection()
name = function() return i18n("Dodge Chance") end,
desc = function() return i18n("Shows/Hides the dodge chance.") end,
width = 1.5,
hidden = function() return not DataUtils:CanDodge() end,
disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end,
get = function () return ExtendedCharacterStats.profile.defense.dodge.display; end,
set = function (_, value)
Expand Down
1 change: 1 addition & 0 deletions Modules/Config/MeleeSection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ function _Config:LoadMeleeSection()
type = "toggle",
order = 2,
name = function() return i18n("Off Hand") end,
hidden = function() return not CanDualWield() end,
desc = function() return i18n("Shows/Hides the attack speed of the off hand.") end,
width = 1.5,
disabled = function()
Expand Down
17 changes: 17 additions & 0 deletions Modules/Data/DataUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local DataUtils = ECSLoader:CreateModule("DataUtils")
---@type Data
local Data = ECSLoader:ImportModule("Data")

local IsSpellKnown = C_SpellBook.IsSpellKnown

--- Rounds every number down to the given decimal places
---@param num number
---@param decimalPlaces number
Expand Down Expand Up @@ -142,4 +144,19 @@ function DataUtils:GetSocketedGemsFromItemLink(itemLink)
return nil
end

---@return boolean
function DataUtils:CanParry()
return (IsSpellKnown(3127) or IsSpellKnown(18848) or IsSpellKnown(3124))
end

---@return boolean
function DataUtils:CanDodge()
return IsSpellKnown(81)
end

---@return boolean
function DataUtils:CanBlock()
return IsSpellKnown(107)
end

return DataUtils
29 changes: 26 additions & 3 deletions Modules/Stats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ local Config = ECSLoader:ImportModule("Config")
local Utils = ECSLoader:ImportModule("Utils")
---@type Data
local Data = ECSLoader:ImportModule("Data")
---@type DataUtils
local DataUtils = ECSLoader:ImportModule("DataUtils")

------------------------------------------------------------------
-- Defaults
Expand Down Expand Up @@ -231,7 +233,11 @@ _CreateStatInfos = function()
end

category = profile.melee.attackSpeed
_CreateStatInfo(category, category.mainHand, category.offHand)
_CreateStatInfo(
category,
category.mainHand,
CanDualWield() and category.offHand or nil
)
end

category = profile.ranged
Expand All @@ -248,8 +254,25 @@ _CreateStatInfos = function()
end

category = profile.defense
_CreateStatInfo(category, category.armor, category.meleeCritReduction, category.rangedCritReduction, category.spellCritReduction, category.avoidance, category.avoidanceBoss,
category.defenseRating, category.defense, category.blockChance, category.blockValue, category.parry, category.dodge, category.resilience)
_CreateStatInfo(
category,
category.armor,
category.meleeCritReduction,
category.rangedCritReduction,
category.spellCritReduction,
category.avoidance,
category.avoidanceBoss,
ECS.IsClassic and nil or category.defenseRating,
category.defense,
(ECS.IsClassic or not DataUtils:CanBlock()) and nil or category.blockRating,
DataUtils:CanBlock() and category.blockChance or nil,
DataUtils:CanBlock() and category.blockValue or nil,
(ECS.IsClassic or not DataUtils:CanParry()) and nil or category.parryRating,
DataUtils:CanParry() and category.parry or nil,
(ECS.IsClassic or not DataUtils:CanDodge()) and nil or category.dodgeRating,
DataUtils:CanDodge() and category.dodge or nil,
ECS.IsClassic and nil or category.resilienceRating
)

category = profile.regen
_CreateStatInfo(category, category.mp5Items, category.mp5Spirit, category.mp5Buffs, category.mp5Casting, category.mp5NotCasting)
Expand Down
Loading