Skip to content
Merged
115 changes: 115 additions & 0 deletions spec/System/TestAttacks_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,119 @@ describe("TestAttacks", function()
assert.are.equals(22, build.calcsTab.mainEnv.player.mainSkill.skillModList:Sum("INC", { flags = ModFlag.Attack }, "Damage"))

end)

-- Hide of the Vendigo: attacking as though using a Claw while the main hand is empty.
-- The attack stays unarmed, so it uses unarmed modifiers rather than claw modifiers.
describe("Hide of the Vendigo", function()
local function equipHide(extraLines)
build.itemsTab:CreateDisplayItemFromRaw([[
Rarity: UNIQUE
Test Subject
Exquisite Leather
Can Attack as though using a Claw while main hand is empty
]] .. (extraLines or ""))
build.itemsTab:AddDisplayItem()
runCallback("OnFrame")
end

-- Frost Blades requires a Claw, Dagger or One Handed Sword, so it can't be used unarmed on its own
local function useFrostBlades()
build.skillsTab:PasteSocketGroup("Frost Blades 20/0 1")
build.mainSocketGroup = 1
runCallback("OnFrame")
build.calcsTab:BuildOutput()
runCallback("OnFrame")
return build.calcsTab.mainEnv.player.mainSkill
end

it("lets you attack as though using a Claw while the main hand is empty", function()
equipHide()
local weaponData1 = build.calcsTab.mainEnv.player.weaponData1
assert.is_true(weaponData1.asThoughUsing ~= nil and weaponData1.asThoughUsing["Claw"] == true)
end)

it("does nothing while a main hand weapon is equipped", function()
equipHide()
build.itemsTab:CreateDisplayItemFromRaw([[
New Item
Corsair Sword
]])
build.itemsTab:AddDisplayItem()
runCallback("OnFrame")
assert.is_nil(build.calcsTab.mainEnv.player.weaponData1.asThoughUsing)
local mainSkill = useFrostBlades()
assert.is_falsy(mainSkill.skillFlags.disable)
assert.is_true(bit.band(mainSkill.weapon1Flags, ModFlag.Sword) > 0)
end)

it("makes Claw skills usable unarmed", function()
local mainSkill = useFrostBlades()
assert.is_true(mainSkill.skillFlags.disable)

newBuild()
equipHide()
mainSkill = useFrostBlades()
assert.is_falsy(mainSkill.skillFlags.disable)
assert.is_true(build.calcsTab.mainOutput.MainHand.AverageHit > 0)
-- The attack is still unarmed and does not count as using a Claw
assert.is_true(bit.band(mainSkill.weapon1Flags, ModFlag.Unarmed) > 0)
assert.are.equals(0, bit.band(mainSkill.weapon1Flags, ModFlag.Claw))
end)

it("does not bypass weapon restrictions of supports", function()
equipHide()
-- Close Combat only allows Axes and Swords
build.skillsTab:PasteSocketGroup("Frost Blades 20/0 1\nClose Combat 20/0 1")
build.mainSocketGroup = 1
runCallback("OnFrame")
build.calcsTab:BuildOutput()
runCallback("OnFrame")
assert.is_true(build.calcsTab.mainEnv.player.mainSkill.skillFlags.disable)
end)

it("applies unarmed modifiers but not claw modifiers to Claw skills", function()
equipHide()
useFrostBlades()
local baseHit = build.calcsTab.mainOutput.MainHand.AverageHit

build.configTab.input.customMods = "100% increased Claw Damage"
build.configTab:BuildModList()
runCallback("OnFrame")
build.calcsTab:BuildOutput()
runCallback("OnFrame")
assert.are.equals(baseHit, build.calcsTab.mainOutput.MainHand.AverageHit)

build.configTab.input.customMods = "185 to 285 Added Cold Damage with Unarmed Attacks"
build.configTab:BuildModList()
runCallback("OnFrame")
build.calcsTab:BuildOutput()
runCallback("OnFrame")
assert.is_true(build.calcsTab.mainOutput.MainHand.AverageHit > baseHit)
end)

it("only applies to the main hand with Hollow Palm Technique", function()
equipHide()
build.configTab.input.customMods = "Hollow Palm Technique"
build.configTab:BuildModList()
runCallback("OnFrame")
local player = build.calcsTab.mainEnv.player
-- Hollow Palm makes the off hand unarmed as well, but the Claw only applies to the main hand
assert.are.equals("None", player.weaponData2.type)
assert.is_true(player.weaponData1.asThoughUsing["Claw"])
assert.is_nil(player.weaponData2.asThoughUsing)
end)

it("gains attack speed if you've used a movement skill recently", function()
equipHide("20% increased Attack Speed if you've used an Attack Movement Skill Recently")
useFrostBlades()
local baseSpeed = build.calcsTab.mainOutput.Speed

build.configTab.input.conditionUsedMovementSkillRecently = true
build.configTab:BuildModList()
runCallback("OnFrame")
build.calcsTab:BuildOutput()
runCallback("OnFrame")
assert.are.near(baseSpeed * 1.2, build.calcsTab.mainOutput.Speed, 1e-9)
end)
end)
end)
159 changes: 159 additions & 0 deletions spec/System/TestClusterJewelGraphs_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,163 @@
spec:DeallocNode(nestedSocket)
assert.are.equal(1, countSubgraphs(spec))
end)

describe("Putrid Seed", function()
local function seedRaw(...)
local raw = [[
Rarity: UNIQUE
Putrid Seed
Mycelium Core
Limited to: 1
]] .. "Implicits: " .. select("#", ...) .. "\n"
for _, name in ipairs({ ... }) do
raw = raw .. "1 Added Passive Skill is " .. name .. " (enchant)\n"
end
return raw .. [[
Grows four random Passive Skills when Anointed
Passive Skills grown are influenced by Oils used when Anointing
]]
end

-- Returns the Large Jewel Socket with the lowest id that has proxy passives, and its layout
local function getSeedSocket(spec)
local socketId
for id in pairs(spec.tree.blightcoreLayouts) do

Check warning on line 136 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (blightcore)
if not socketId or id < socketId then
socketId = id
end
end
return spec.nodes[socketId], spec.tree.blightcoreLayouts[socketId]

Check warning on line 141 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (blightcore)
end

-- Returns the layout node that grows the passive with the given enchant index
local function getGrownNode(spec, layout, index)
for _, node in ipairs(layout) do
if build.data.clusterJewels.blightcoreNotableIndex[node.id] == index then

Check warning on line 147 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (blightcore)
return spec.nodes[node.id]
end
end
end

local function socketSeed(spec, socket, item)
build.itemsTab:AddItem(item, true)
spec.jewels[socket.id] = item.id
build.itemsTab.sockets[socket.id].selItemId = item.id
spec:AllocNode(socket)
spec:BuildClusterJewelGraphs()
end

local function recalc()

Check warning on line 161 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (recalc)
build.buildFlag = true
runCallback("OnFrame")
end

it("parses its modifiers and can be anointed four times", function()
local item = new("Item"):Item(seedRaw("Constitution", "Heart of Oak"))
for _, modLine in ipairs(item.explicitModLines) do
assert.is_nil(modLine.extra, modLine.line)
end
assert.is_true(item.canBeAnointed)
assert.is_true(item.canHaveFourEnchants)
assert.are.same({ "constitution", "heart of oak" }, item.jewelData.blightcoreNotables)

Check warning on line 173 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (blightcore)
end)

it("only fits in Large Jewel Sockets", function()
local item = new("Item"):Item(seedRaw())
local itemsTab = build.itemsTab
local socket = getSeedSocket(build.spec)
assert.is_true(itemsTab:IsItemValidForSlot(item, "Jewel " .. socket.id))
for nodeId, node in pairs(build.spec.tree.sockets) do
if node.expansionJewel and node.expansionJewel.size < 2 or not node.expansionJewel and not node.charmSocket then
assert.is_falsy(itemsTab:IsItemValidForSlot(item, "Jewel " .. nodeId), node.name)
end
end
end)

it("anoints and reads back grown passives", function()
local itemsTab = build.itemsTab
itemsTab:SetDisplayItem(new("Item"):Item(seedRaw()))
local notable = build.spec.tree.notableMap["constitution"]
itemsTab.anointEnchantSlot = 1
local item = itemsTab:anointItem(notable)
assert.are.equal("1 Added Passive Skill is Constitution", item.enchantModLines[1].line)
assert.are.same({ "constitution" }, itemsTab:getAnoint(item))
assert.are.same({ "constitution" }, item.jewelData.blightcoreNotables)

Check warning on line 196 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (blightcore)
assert.are.equal(3, itemsTab:getMissingAnointCount(item))
end)

it("maps Large Jewel Sockets to their proxy passives", function()
local tree = build.spec.tree
assert.is_truthy(next(tree.blightcoreLayouts))
for socketId, layout in pairs(tree.blightcoreLayouts) do
assert.are.equal(2, tree.nodes[socketId].expansionJewel.size)
local indices = { }
for _, node in ipairs(layout) do
assert.is_true(node.isProxy)
assert.are.equal(layout[1].proxyKey, node.proxyKey)
local index = build.data.clusterJewels.blightcoreNotableIndex[node.id]
if index then
table.insert(indices, index)
end
end
table.sort(indices)
assert.are.same({ 1, 2, 3, 4 }, indices)
end
end)

it("grows the anointed notables from an allocated socket", function()
local spec = build.spec
local socket, layout = getSeedSocket(spec)
socketSeed(spec, socket, new("Item"):Item(seedRaw("Constitution", "Heart of Oak")))

local subGraph = spec.subGraphs[socket.id]
assert.is_truthy(subGraph)
assert.are.equal(#layout, #subGraph.nodes)
assert.is_truthy(subGraph.entranceNodes[1])
for _, entrance in ipairs(subGraph.entranceNodes) do
assert.is_truthy(isValueInArray(socket.linked, entrance))
end

assert.are.equal("Constitution", getGrownNode(spec, layout, 1).dn)
assert.are.equal("Heart of Oak", getGrownNode(spec, layout, 2).dn)
for _, treeNode in ipairs(layout) do
local node = spec.nodes[treeNode.id]
assert.is_true(node.isBlightcore)

Check warning on line 236 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (Blightcore)
assert.is_false(node.isProxy)
-- the tree's own proxy nodes are left untouched
assert.are_not.equal(treeNode, node)
assert.is_true(treeNode.isProxy)
end
-- passives without a matching anoint stay as they are on the tree
local unanointed = getGrownNode(spec, layout, 3)
assert.are.equal(spec.tree.nodes[unanointed.id].dn, unanointed.dn)
assert.are_not.equal("Constitution", unanointed.dn)
end)

it("removes grown passives when the socket is deallocated", function()
local spec = build.spec
local socket = getSeedSocket(spec)
socketSeed(spec, socket, new("Item"):Item(seedRaw("Constitution")))
assert.is_truthy(spec.subGraphs[socket.id])

spec:DeallocNode(socket)
assert.is_nil(spec.subGraphs[socket.id])
end)

it("grants the stats of allocated grown notables", function()
local spec = build.spec
local socket, layout = getSeedSocket(spec)
socketSeed(spec, socket, new("Item"):Item(seedRaw("Constitution")))
recalc()

Check warning on line 262 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (recalc)
local baseIncLife = build.calcsTab.mainEnv.modDB:Sum("INC", nil, "Life")

local grown = getGrownNode(spec, layout, 1)
spec:AllocNode(grown)
recalc()

Check warning on line 267 in spec/System/TestClusterJewelGraphs_spec.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (recalc)
-- the grown node survives rebuilding the tree
assert.are.equal("Constitution", spec.nodes[grown.id].dn)
assert.is_true(spec.nodes[grown.id].alloc)
assert.are.equal(baseIncLife + 10, build.calcsTab.mainEnv.modDB:Sum("INC", nil, "Life"))
end)
end)
end)
11 changes: 11 additions & 0 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,13 @@
enchantIndex = enchantIndex + 1
end
end
if self.base and self.base.subType == "Blightcore" then

Check warning on line 1651 in src/Classes/Item.lua

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (Blightcore)
-- Anointing a Putrid Seed grows four passives
self.canBeAnointed = true
self.canHaveTwoEnchants = true
self.canHaveThreeEnchants = true
self.canHaveFourEnchants = true
end
self:BuildModList()
if deferJewelRadiusIndexAssignment then
self.jewelRadiusIndex = self.jewelData.radiusIndex
Expand Down Expand Up @@ -2492,6 +2499,10 @@
for _, value in ipairs(modList:List(nil, "JewelData")) do
jewelData[value.key] = value.value
end
if self.base.subType == "Blightcore" then
-- In order of the jewel's granted passive stats
jewelData.blightcoreNotables = modList:List(nil, "BlightcoreNotable")
end
if modList:List(nil, "ImpossibleEscapeKeystones") then
jewelData.impossibleEscapeKeystones = { }
for _, value in ipairs(modList:List(nil, "ImpossibleEscapeKeystones")) do
Expand Down
19 changes: 17 additions & 2 deletions src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ holding Shift will put it in the second.]])
self.displayItem.canHaveFourEnchants and
#self.displayItem.enchantModLines > 2
end
self.controls.displayItemCorrupt = new("ButtonControl"):ButtonControl({"TOPLEFT",self.controls.displayItemAnoint4,"TOPRIGHT",true}, {8, 10, 100, 20}, "Corrupt...", function()
self.controls.displayItemCorrupt = new("ButtonControl"):ButtonControl({"TOPLEFT",self.controls.displayItemAnoint4,"TOPRIGHT",true}, {8, 0, 100, 20}, "Corrupt...", function()
self:CorruptDisplayItem()
end)
self.controls.displayItemCorrupt.shown = function()
Expand Down Expand Up @@ -2631,6 +2631,9 @@ function ItemsTabClass:IsItemValidForSlot(item, slotName, itemSet)
return true
end
return false
elseif item.base.subType == "Blightcore" then
-- Putrid Seed can only grow passives from Large Jewel Sockets
return node.expansionJewel and node.expansionJewel.size == 2
elseif item.clusterJewel and not node.expansionJewel then
-- Don't allow cluster jewels in inner sockets
return false
Expand Down Expand Up @@ -3042,6 +3045,12 @@ function ItemsTabClass:getAnoint(item)
if anoint then
local nodeName = line:sub(anoint + string.len("Allocates "))
t_insert(result, nodeName)
elseif item.base.subType == "Blightcore" then
-- Putrid Seed anoints grow passives instead
local nodeName = line:lower():match("^1 added passive skill is (.+)$")
if nodeName then
t_insert(result, nodeName)
end
end
end
end
Expand Down Expand Up @@ -3073,7 +3082,13 @@ function ItemsTabClass:anointItem(node)
t_remove(item.enchantModLines, self.anointEnchantSlot)
end
if node then
t_insert(item.enchantModLines, self.anointEnchantSlot, { crafted = true, line = "Allocates " .. node.dn })
local line
if item.base.subType == "Blightcore" then
line = "1 Added Passive Skill is " .. node.dn
else
line = "Allocates " .. node.dn
end
t_insert(item.enchantModLines, self.anointEnchantSlot, { crafted = true, line = line })
end
item:BuildAndParseRaw()
return item
Expand Down
Loading
Loading