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
33 changes: 33 additions & 0 deletions spec/System/TestGeneratedUniques_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe("Generated uniques", function()
local function findGeneratedItem(name)
for _, itemText in ipairs(data.uniques.generated) do
if itemText:sub(1, #name + 1) == name .. "\n" then
return itemText
end
end
end

it("includes weapon-legal Catarina veiled mods on Cane of Kulemak", function()
local cane = findGeneratedItem("Cane of Kulemak")
assert.is_not_nil(cane)
assert.is_not_nil(cane:find("+2 to Level of Socketed Support Gems", 1, true))
assert.is_not_nil(cane:find("+(5-8)% to Quality of Socketed Support Gems", 1, true))
assert.is_not_nil(cane:find("chance to Explode", 1, true))
end)

it("excludes weapon-illegal Catarina veiled mods from Cane of Kulemak", function()
local cane = findGeneratedItem("Cane of Kulemak")
assert.is_not_nil(cane)
assert.is_nil(cane:find("maximum number of Spectres", 1, true))
assert.is_nil(cane:find("Minions are Aggressive", 1, true))
end)

it("does not add Catarina signature mods to Paradoxica or Replica Paradoxica", function()
for _, name in ipairs({ "Paradoxica", "Replica Paradoxica" }) do
local item = findGeneratedItem(name)
assert.is_not_nil(item)
assert.is_nil(item:find("to Quality of Socketed Support Gems", 1, true))
assert.is_nil(item:find("chance to Explode", 1, true))
end
end)
end)
15 changes: 10 additions & 5 deletions src/Data/Uniques/Special/Generated.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ local parseVeiledModName = function(string)
gsub("(%d)", " %1 "))
end

local veiledModIsActive = function(mod, baseType, specificType1, specificType2)
local veiledModIsActive = function(mod, baseType, specificType1, specificType2, poolKey)
local baseIndex = isValueInTable(mod.weightKey, baseType)
local typeIndex1 = isValueInTable(mod.weightKey, specificType1)
local typeIndex2 = isValueInTable(mod.weightKey, specificType2)
-- Master signature mods (e.g. Catarina's) carry their weight on a pool key such as "catarina_veiled_prefix"
-- and only list the slots they are excluded from, so the pool key only applies when no slot key matched
local poolIndex = poolKey and isValueInTable(mod.weightKey, poolKey)
return (typeIndex1 and mod.weightVal[typeIndex1] > 0) or (typeIndex2 and mod.weightVal[typeIndex2] > 0) or (not typeIndex1 and not typeIndex2 and baseIndex and mod.weightVal[baseIndex] > 0)
or (not typeIndex1 and not typeIndex2 and not baseIndex and poolIndex and mod.weightVal[poolIndex] > 0)
end

local getVeiledMods = function (veiledPool, baseType, specificType1, specificType2)
local veiledMods = { }
local poolKey = veiledPool == "catarina" and "catarina_veiled_prefix" or nil
for veiledModIndex, veiledMod in pairs(data.veiledMods) do
if veiledModIsActive(veiledMod, baseType, specificType1, specificType2) then
if veiledModIsActive(veiledMod, baseType, specificType1, specificType2, poolKey) then
local veiledName = parseVeiledModName(veiledModIndex)

veiledName = "("..veiledMod.type..") "..veiledName
Expand Down Expand Up @@ -112,9 +117,9 @@ local caneOfKulemak = {
"Has Alt Variant Two: true",
"Has Alt Variant Three: true",
"Selected Variant: 1",
"Selected Alt Variant: 2",
"Selected Alt Variant Two: 20",
"Selected Alt Variant Three: 21",
"Selected Alt Variant: 3",
"Selected Alt Variant Two: 25",
"Selected Alt Variant Three: 26",
}

for _, mod in pairs(caneOfKulemakMods) do
Expand Down