From 8e91632b00b470966b7f9bbaba265c1777adb384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0i=C5=A1ka?= Date: Sun, 20 Sep 2026 20:34:46 +0200 Subject: [PATCH] Fix Runeforged/Runemastered base variants never being added to uniques The unique DB loader skipped injecting the runeforging base variants whenever the item already declared base variants of its own, but it tested newItem.baseLines for that. Item parsing fills baseLines with the item's own base on every parse, so with the enclosing `if newItem.base` already guaranteeing a recognised base, the guard was always true and the injection never ran: 0 of 443 uniques came back with a baseList while 272 were eligible. Test newItem.baseList instead, which stays nil unless a "Base Variant:" line is actually present. The existing variant tests only fed raw text that already declared base variants, exercising the item machinery rather than the loader, so add coverage that goes through main.uniqueDB. Co-Authored-By: Claude Opus 5 --- spec/System/TestItemVariants_spec.lua | 40 +++++++++++++++++++++++++++ src/Modules/Main.lua | 6 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/spec/System/TestItemVariants_spec.lua b/spec/System/TestItemVariants_spec.lua index c41bc97f4c..7ddbc1c3fb 100644 --- a/spec/System/TestItemVariants_spec.lua +++ b/spec/System/TestItemVariants_spec.lua @@ -602,3 +602,43 @@ describe("Versioned item variants", function() end) end) end) + +describe("Runeforging base variants from the unique database", function() + local function uniqueList() + while main.uniqueDB.loading do + runCallback("OnFrame") + end + return main.uniqueDB.list + end + + it("injects the runeforging bases into a unique that declares none itself", function() + local item = uniqueList()["Wanderlust, Wrapped Sandals"] + assert.is_not_nil(item) + assert.same({ "Regular Base", "Runeforged", "Runemastered" }, item.baseList) + assert.equals(1, item.selectedBase) + assert.equals("Wrapped Sandals", item.baseName) + assert.same({ [1] = true }, item.baseLines["Wrapped Sandals"].baseVariantList) + assert.same({ [2] = true }, item.baseLines["Runeforged Wrapped Sandals"].baseVariantList) + assert.same({ [3] = true }, item.baseLines["Runemastered Wrapped Sandals"].baseVariantList) + end) + + it("keeps the injected bases selectable through a raw round trip", function() + local item = new("Item"):Item(uniqueList()["Wanderlust, Wrapped Sandals"].raw) + assert.same({ "Regular Base", "Runeforged", "Runemastered" }, item.baseList) + item.selectedBase = 3 + item:BuildAndParseRaw() + assert.equals("Runemastered Wrapped Sandals", item.baseName) + end) + + it("injects the runeforging bases into every eligible unique", function() + local missing = { } + for name, item in pairs(uniqueList()) do + local baseName = item.baseName + if baseName and not item.baseList + and (data.itemBases["Runeforged " .. baseName] or data.itemBases["Runemastered " .. baseName]) then + table.insert(missing, name) + end + end + assert.same({ }, missing) + end) +end) diff --git a/src/Modules/Main.lua b/src/Modules/Main.lua index 69c4eec866..fc4ee50c55 100644 --- a/src/Modules/Main.lua +++ b/src/Modules/Main.lua @@ -159,7 +159,9 @@ function main:Init() if newItem.base then local baseBase = newItem.baseName -- uniques with base variants are skipped as they can be handled manually - local hasBaseVariants = newItem.baseLines and not not next(newItem.baseLines) + -- baseLines always contains the item's own base, so the item only declares + -- base variants of its own when a "Base Variant:" line filled baseList + local hasBaseVariants = newItem.baseList and not not next(newItem.baseList) if newItem.rarity == "UNIQUE" and not hasBaseVariants then -- look for alternate runeforging bases local bases = { { variantName = "Regular Base", baseName = baseBase } } @@ -170,7 +172,7 @@ function main:Init() table.insert(bases, { variantName = "Runemastered", baseName = "Runemastered " .. baseBase }) end if #bases > 1 then - newItem.baseList = newItem.baseList ?? {} + newItem.baseList = { } local baseLines = {} -- Add variants for each base for _, base in ipairs(bases) do