Skip to content
Merged
72 changes: 2 additions & 70 deletions spec/System/TestItemParse_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,35 +250,10 @@ describe("TestItemParse", function()
assert.are.equals("Templar", item.classRestriction)
end)

it("Influence", function()
local item = new("Item", raw("Shaper Item"))
assert.truthy(item.shaper)
item = new("Item", raw("Elder Item"))
assert.truthy(item.elder)
item = new("Item", raw("Warlord Item"))
assert.truthy(item.adjudicator)
item = new("Item", raw("Hunter Item"))
assert.truthy(item.basilisk)
item = new("Item", raw("Crusader Item"))
assert.truthy(item.crusader)
item = new("Item", raw("Redeemer Item"))
assert.truthy(item.eyrie)
item = new("Item", raw("Searing Exarch Item"))
assert.truthy(item.cleansing)
item = new("Item", raw("Eater of Worlds Item"))
assert.truthy(item.tangle)
end)

it("short flags", function()
local item = new("Item", raw("Split"))
assert.truthy(item.split)
item = new("Item", raw("Mirrored"))
assert.truthy(item.mirrored)
item = new("Item", raw("Corrupted"))
assert.truthy(item.corrupted)
item = new("Item", raw("Fractured Item"))
assert.truthy(item.fractured)
item = new("Item", raw("Synthesised Item"))
assert.truthy(item.synthesised)
item = new("Item", raw("Crafted: true"))
assert.truthy(item.crafted)
Expand Down Expand Up @@ -331,67 +306,24 @@ describe("TestItemParse", function()
assert.are.equals(11, item.baseModList[1].value) -- range 0.8 of (8-12) = 11
end)

it("crafted", function()
local item = new("Item", raw("{crafted}+8 to Strength"))
assert.truthy(item.explicitModLines[1].crafted)
item = new("Item", raw("+8 to Strength (crafted)"))
assert.truthy(item.explicitModLines[1].crafted)
end)

it("crucible", function()
local item = new("Item", raw("{crucible}+8 to Strength"))
assert.truthy(item.crucibleModLines[1].crucible)
item = new("Item", raw("+8 to Strength (crucible)"))
assert.truthy(item.crucibleModLines[1].crucible)
end)

it("custom", function()
local item = new("Item", raw("{custom}+8 to Strength"))
assert.truthy(item.explicitModLines[1].custom)
end)

it("eater", function()
local item = new("Item", raw("{eater}+8 to Strength"))
assert.truthy(item.explicitModLines[1].eater)
end)

it("enchant", function()
local item = new("Item", raw("+8 to Strength (enchant)"))
assert.are.equals(1, #item.enchantModLines)
-- enchant also sets crafted and implicit
assert.truthy(item.enchantModLines[1].crafted)
-- enchant also sets enchant and implicit
assert.truthy(item.enchantModLines[1].enchant)
assert.truthy(item.enchantModLines[1].implicit)
end)

it("exarch", function()
local item = new("Item", raw("{exarch}+8 to Strength"))
assert.truthy(item.explicitModLines[1].exarch)
end)

it("fractured", function()
local item = new("Item", raw("{fractured}+8 to Strength"))
assert.truthy(item.explicitModLines[1].fractured)
item = new("Item", raw("+8 to Strength (fractured)"))
assert.truthy(item.explicitModLines[1].fractured)
end)

it("implicit", function()
local item = new("Item", raw("+8 to Strength (implicit)"))
assert.truthy(item.implicitModLines[1].implicit)
end)

it("scourge", function()
local item = new("Item", raw("{scourge}+8 to Strength"))
assert.truthy(item.scourgeModLines[1].scourge)
item = new("Item", raw("+8 to Strength (scourge)"))
assert.truthy(item.scourgeModLines[1].scourge)
end)

it("synthesis", function()
local item = new("Item", raw("{synthesis}+8 to Strength"))
assert.truthy(item.explicitModLines[1].synthesis)
end)

it("multiple bases", function()
local item = new("Item", [[
Ashcaller
Expand Down
48 changes: 2 additions & 46 deletions src/Classes/ImportTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ local realmList = {
{ label = "Tencent", id = "PC", realmCode = "pc", hostName = "https://poe.game.qq.com/", profileURL = "account/view-profile/" },
}

local influenceInfo = itemLib.influenceInfo

local ImportTabClass = newClass("ImportTab", "ControlHost", "Control", function(self, build)
self.ControlHost()
self.Control()
Expand Down Expand Up @@ -806,7 +804,6 @@ function ImportTabClass:ImportItem(itemData, slotName)
item.rarity = rarityMap[itemData.frameType]
if #itemData.name > 0 then
item.title = sanitiseText(itemData.name)
item.baseName = sanitiseText(itemData.typeLine):gsub("Synthesised ","")
item.name = item.title .. ", " .. item.baseName
if item.baseName == "Two-Toned Boots" then
-- Hack for Two-Toned Boots
Expand Down Expand Up @@ -861,11 +858,6 @@ function ImportTabClass:ImportItem(itemData, slotName)

-- Import item data
item.uniqueID = itemData.id
if itemData.influences then
for _, curInfluenceInfo in ipairs(influenceInfo) do
item[curInfluenceInfo.key] = itemData.influences[curInfluenceInfo.display:lower()]
end
end
if itemData.ilvl > 0 then
item.itemLevel = itemData.ilvl
end
Expand Down Expand Up @@ -901,11 +893,8 @@ function ImportTabClass:ImportItem(itemData, slotName)
end
end
end
item.split = itemData.split
item.mirrored = itemData.mirrored
item.corrupted = itemData.corrupted
item.fractured = itemData.fractured
item.synthesised = itemData.synthesised
if itemData.sockets and itemData.sockets[1] then
item.sockets = { }
for i, socket in pairs(itemData.sockets) do
Expand All @@ -929,24 +918,14 @@ function ImportTabClass:ImportItem(itemData, slotName)
end
end
item.enchantModLines = { }
item.scourgeModLines = { }
item.classRequirementModLines = { }
item.implicitModLines = { }
item.explicitModLines = { }
item.crucibleModLines = { }
if itemData.enchantMods then
for _, line in ipairs(itemData.enchantMods) do
for line in line:gmatch("[^\n]+") do
local modList, extra = modLib.parseMod(line)
t_insert(item.enchantModLines, { line = line, extra = extra, mods = modList or { }, crafted = true })
end
end
end
if itemData.scourgeMods then
for _, line in ipairs(itemData.scourgeMods) do
for line in line:gmatch("[^\n]+") do
local modList, extra = modLib.parseMod(line)
t_insert(item.scourgeModLines, { line = line, extra = extra, mods = modList or { }, scourge = true })
t_insert(item.enchantModLines, { line = line, extra = extra, mods = modList or { }, enchant = true })
end
end
end
Expand All @@ -958,14 +937,6 @@ function ImportTabClass:ImportItem(itemData, slotName)
end
end
end
if itemData.fracturedMods then
for _, line in ipairs(itemData.fracturedMods) do
for line in line:gmatch("[^\n]+") do
local modList, extra = modLib.parseMod(line)
t_insert(item.explicitModLines, { line = line, extra = extra, mods = modList or { }, fractured = true })
end
end
end
if itemData.explicitMods then
for _, line in ipairs(itemData.explicitMods) do
for line in line:gmatch("[^\n]+") do
Expand All @@ -974,22 +945,7 @@ function ImportTabClass:ImportItem(itemData, slotName)
end
end
end
if itemData.crucibleMods then
for _, line in ipairs(itemData.crucibleMods) do
for line in line:gmatch("[^\n]+") do
local modList, extra = modLib.parseMod(line)
t_insert(item.crucibleModLines, { line = line, extra = extra, mods = modList or { }, crucible = true })
end
end
end
if itemData.craftedMods then
for _, line in ipairs(itemData.craftedMods) do
for line in line:gmatch("[^\n]+") do
local modList, extra = modLib.parseMod(line)
t_insert(item.explicitModLines, { line = line, extra = extra, mods = modList or { }, crafted = true })
end
end
end

-- Sometimes flavour text has actual mods that PoB cares about
-- Right now, the only known one is "This item can be anointed by Cassia"
if itemData.flavourText then
Expand Down
Loading