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
38 changes: 38 additions & 0 deletions spec/System/TestImport_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,42 @@ Implicits: 0]])
end)
end

it("keeps Wickerman items separate through import and save/load", function()
-- Live OAuth structure and Lesser names; IDs and boundary-case rolls are synthetic.
local examples = {
{ "Ravenous Skull", "Head", "Every 3 seconds, Consume a Corpse within 5 metres to Recover 4% of Life" },
{ "Lesser Warden's Arm", "Upper Limb", "+43 to maximum Life" },
{ "Greater Sirus' Head", "Head", "+10 to Strength" },
{ "Lesser Blackened Lungs", "Torso", "12% increased Warcry Speed", "VisceraBody" },
{ "Lesser Pocked Leg", "Lower Limb", "20% increased Armour from Equipped Helmet and Gloves", "VisceraLeg" },
{ "Artificial Appendage", "Upper Limb", "25% increased Effect of Chill" },
{ "Artificial Appendage", "Upper Limb", "18% increased Area of Effect for Attacks" },
{ "Artificial Appendage", "Upper Limb", "Minions have 30% increased Critical Strike Chance" },
}
local equipped, items = { }, { }
for i, example in ipairs(examples) do
local slot = "Wickerman " .. example[2]
local item = { id = "synthetic-wickerman-" .. i, name = "", typeLine = example[1], baseType = example[1], frameType = 15, ilvl = 83,
inventoryId = example[4] or (example[2] == "Head" and "VisceraHead" or "VisceraArm"), implicitMods = { { description = example[3] } } }
table.insert(items, item)
equipped[slot] = item.id
end
local character = { level = 80, equipment = { }, wickerman = items }
build.importTab:ImportItemsAndSkills(character, true, false)
build.importTab:ImportItemsAndSkills(character, false, false) -- Replace only matching IDs.
loadBuildFromXML(build:SaveDB("code"))
assert.equals(#examples, #build.itemsTab.itemOrderList)
for i, example in ipairs(examples) do
local item = build.itemsTab.items[build.itemsTab.itemOrderList[i]]
assert.equals("synthetic-wickerman-" .. i, item.uniqueID)
assert.equals(example[1], item.baseName)
assert.equals("NORMAL", item.rarity)
assert.equals("Wickerman " .. example[2], item.type)
assert.equals(example[3], item.implicitModLines[1].line)
end
for slot, id in pairs(equipped) do
assert.equals(id, build.itemsTab.items[build.itemsTab.slots[slot].selItemId].uniqueID)
end
end)

end)
18 changes: 16 additions & 2 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,7 @@ end

--- @class CharacterItemsData : CharacterBasicData
--- @field equipment GGGItem[]
--- @field wickerman? GGGItem[]
--- @param charData CharacterItemsData
--- @param clearItems boolean
--- @param clearSkills boolean
Expand Down Expand Up @@ -1422,6 +1423,9 @@ function ImportTabClass:ImportItemsAndSkills(charData, clearItems, clearSkills,
end
self:AssignGuardianItemSet(guardianSet.id)
end
for _, itemData in ipairs(charData.wickerman or { }) do
self:ImportItem(itemData)
end
if skillOrder then
local groupOrder = { }
for index, socketGroup in ipairs(self.build.skillsTab.socketGroupList) do
Expand Down Expand Up @@ -1490,9 +1494,10 @@ function ImportTabClass:ImportItemsAndSkills(charData, clearItems, clearSkills,
return charData, colorCodes.POSITIVE .. "Items and skills successfully imported."
end

local rarityMap = { [0] = "NORMAL", "MAGIC", "RARE", "UNIQUE", [9] = "RELIC", [10] = "RELIC" }
local rarityMap = { [0] = "NORMAL", "MAGIC", "RARE", "UNIQUE", [9] = "RELIC", [10] = "RELIC", [15] = "NORMAL" }
local slotMap = { ["Weapon"] = "Weapon 1", ["Offhand"] = "Weapon 2", ["Weapon2"] = "Weapon 1 Swap", ["Offhand2"] = "Weapon 2 Swap", ["Helm"] = "Helmet", ["BodyArmour"] = "Body Armour", ["Gloves"] = "Gloves", ["Boots"] = "Boots",
["Amulet"] = "Amulet", ["Ring"] = "Ring 1", ["Ring2"] = "Ring 2", ["Ring3"] = "Ring 3", ["Belt"] = "Belt", ["BrequelGrafts"] = "Graft 1", ["BrequelGrafts2"] = "Graft 2", }
["Amulet"] = "Amulet", ["Ring"] = "Ring 1", ["Ring2"] = "Ring 2", ["Ring3"] = "Ring 3", ["Belt"] = "Belt", ["BrequelGrafts"] = "Graft 1", ["BrequelGrafts2"] = "Graft 2",
["VisceraHead"] = "Wickerman Head", ["VisceraBody"] = "Wickerman Torso", ["VisceraArm"] = "Wickerman Upper Limb", ["VisceraLeg"] = "Wickerman Lower Limb", }

function ImportTabClass:ImportItem(itemData, slotName, ignoreWeaponSwap, itemSetId)
if not slotName then
Expand Down Expand Up @@ -1542,7 +1547,16 @@ function ImportTabClass:ImportItem(itemData, slotName, ignoreWeaponSwap, itemSet
itemData.implicitMods = { }
itemData.explicitMods = { }
end
-- Lesser and Greater Wickerman names overlap ordinary names: prefer the exact base.
local exactBase = self.build.data.itemBases[item.name]
if exactBase and exactBase.type:match("^Wickerman ") then
item.baseName = item.name
item.type = exactBase.type
end
for baseName, baseData in pairs(self.build.data.itemBases) do
if item.baseName then
break
end
local s, e = item.name:find(baseName, 1, true)
if s then
item.baseName = baseName
Expand Down
Loading
Loading