Skip to content
Closed
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
65 changes: 65 additions & 0 deletions spec/System/TestChargeConsumption_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
describe("TestChargeConsumption", function()
before_each(function()
newBuild()
end)

local function setupBarrage(inhibitor)
build.itemsTab:CreateDisplayItemFromRaw([[
New Item
Hardwood Spear
Quality: 0
]])
build.itemsTab:AddDisplayItem()
runCallback("OnFrame")

local socketGroup = "Barrage 20/0 1"
if inhibitor then
socketGroup = socketGroup .. "\nInhibitor 1/0 1"
end
build.skillsTab:PasteSocketGroup(socketGroup)
runCallback("OnFrame")
end

local function getBarrageRepeatCounts()
local baseRepeats = 0
local chargeRepeats = 0
for _, auxSkill in ipairs(build.calcsTab.mainEnv.auxSkillList) do
if auxSkill.activeEffect.grantedEffect.name == "Barrage" then
for _, buff in ipairs(auxSkill.buffList) do
if buff.name == "Barrage" then
for _, mod in ipairs(buff.modList) do
if mod.name == "BarrageRepeats" then
local usesRemovableFrenzyCharge = false
for _, tag in ipairs(mod) do
if tag.var == "RemovableFrenzyCharge" then
usesRemovableFrenzyCharge = true
break
end
end
if usesRemovableFrenzyCharge then
chargeRepeats = chargeRepeats + 1
else
baseRepeats = baseRepeats + 1
end
end
end
end
end
end
end
return baseRepeats, chargeRepeats
end

it("Inhibitor removes Barrage charge-consumption repeat benefits", function()
setupBarrage(false)
local baseRepeats, chargeRepeats = getBarrageRepeatCounts()
assert.are.equals(1, baseRepeats)
assert.are.equals(1, chargeRepeats)

newBuild()
setupBarrage(true)
baseRepeats, chargeRepeats = getBarrageRepeatCounts()
assert.are.equals(1, baseRepeats)
assert.are.equals(0, chargeRepeats)
end)
end)
20 changes: 19 additions & 1 deletion src/Modules/CalcActiveSkill.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ local bor = OR64 -- bit.bor
local band = AND64 -- bit.band
local bnot = NOT64 -- bit.bnot

local removableChargeMultiplier = {
RemovableEnduranceCharge = true,
RemovableFrenzyCharge = true,
RemovablePowerCharge = true,
RemovableTotalCharge = true,
}

local function usesRemovableChargeMultiplier(mod)
for _, tag in ipairs(mod) do
if removableChargeMultiplier[tag.var] and (tag.type == "Multiplier" or tag.type == "MultiplierThreshold") then
return true
end
end
return false
end

-- Merge level modifier with given mod list
local mergeLevelCache = { }
local function mergeLevelMod(modList, mod, value)
Expand Down Expand Up @@ -901,7 +917,9 @@ function calcs.buildActiveSkillModList(env, activeSkill)
break
end
end
if effectTag and effectTag.modCond and not skillModList:GetCondition(effectTag.modCond, activeSkill.skillCfg) then
if activeSkill.skillTypes[SkillType.CannotConsumeCharges] and usesRemovableChargeMultiplier(skillModList[i]) then
t_remove(skillModList, i)
elseif effectTag and effectTag.modCond and not skillModList:GetCondition(effectTag.modCond, activeSkill.skillCfg) then
t_remove(skillModList, i)
elseif effectType then
local buff
Expand Down