Skip to content
Merged
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
58 changes: 58 additions & 0 deletions spec/System/TestSkills_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,64 @@ describe("TestSkills", function()
assert.are.equals(9, finalCost) -- round(floor(9 * 1.5) / 1.5)
end)

it("converts positive flat Mana cost to partial Life cost", function()
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
build.configTab.input.customMods = "Skills Cost Life instead of 15% of Mana Cost\n+4 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")

assert.are.equals(2, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(11, build.calcsTab.mainOutput.ManaCost)
end)

it("converts positive flat Mana cost to full Life cost", function()
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
build.configTab.input.customMods = "Skill Mana Costs Converted to Life Costs\n+4 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")

assert.are.equals(13, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(0, build.calcsTab.mainOutput.ManaCost)
end)

it("does not convert negative flat Mana cost to partial Life cost", function()
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
build.configTab.input.customMods = "Skills Cost Life instead of 15% of Mana Cost\nNon-Channelling Skills have -7 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")

assert.are.equals(1, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(1, build.calcsTab.mainOutput.ManaCost)
end)

it("does not convert negative flat Mana cost to full Life cost", function()
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
build.configTab.input.customMods = "Skill Mana Costs Converted to Life Costs\nNon-Channelling Skills have -7 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")

assert.are.equals(9, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(0, build.calcsTab.mainOutput.ManaCost)
end)

it("moves only positive flat Mana cost when skills cost Life instead", function()
build.skillsTab:PasteSocketGroup("Ball Lightning 1/0 1\n")
runCallback("OnFrame")
local baseManaCost = build.calcsTab.mainOutput.ManaCost

build.configTab.input.customMods = "Skills Cost Life instead of Mana\n+4 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")
assert.are.equals(baseManaCost + 4, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(0, build.calcsTab.mainOutput.ManaCost)

build.configTab.input.customMods = "Skills Cost Life instead of Mana\nNon-Channelling Skills have -7 to Total Mana Cost"
build.configTab:BuildModList()
runCallback("OnFrame")
assert.are.equals(baseManaCost, build.calcsTab.mainOutput.LifeCost)
assert.are.equals(0, build.calcsTab.mainOutput.ManaCost)
end)

it("Test socket group pasting with corruption levels and count", function()
build.skillsTab:PasteSocketGroup("Wave of Frost 20/0 3 C+1\n Culmination I 1/0 1")
assert.are.equals(3, build.skillsTab.socketGroupList[1].gemList[1].count)
Expand Down
9 changes: 9 additions & 0 deletions src/Modules/CalcOffence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2100,13 +2100,22 @@ function calcs.offence(env, actor, activeSkill)
val.baseCost = val.baseCost + costs[manaType].baseCost
val.baseCostNoMult = val.baseCostNoMult + costs[manaType].baseCostNoMult
val.finalBaseCost = val.finalBaseCost + costs[manaType].finalBaseCost
if val.upfront then
local manaTotalCost = skillModList:Sum("BASE", skillCfg, manaType.."Cost")
val.totalCost = val.totalCost + m_max(0, manaTotalCost)
costs[manaType].totalCost = costs[manaType].totalCost - manaTotalCost
end
costs[manaType].baseCost = 0
costs[manaType].baseCostRaw = 0
costs[manaType].finalBaseCost = 0
costs[manaType].baseCostNoMult = 0
elseif additionalLifeCost > 0 or hybridLifeCost > 0 then
val.baseCost = costs[manaType].baseCost
val.finalBaseCost = round(finalBaseCostRaw + round(costs[manaType].finalBaseCost * hybridLifeCost) + m_floor(val.baseCost * mult) * additionalLifeCost)
if val.upfront and hybridLifeCost > 0 then
-- Positive flat Mana cost is converted and rounded separately from the base cost.
val.totalCost = val.totalCost + round(m_max(0, skillModList:Sum("BASE", skillCfg, manaType.."Cost")) * hybridLifeCost)
end
end
elseif val.type == "ES" then
local manaType = resource:gsub("ES", "Mana")
Expand Down
Loading