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
201 changes: 201 additions & 0 deletions spec/System/TestItemParse_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,207 @@ Implicits: 1
assert.truthy(item.unreleased)
end)

it("Twice Corrupted", function()
local item = new("Item"):Item([[
Item Class: Body Armours
Rarity: Unique
Tabula Rasa
Simple Robe
--------
Sockets: W-W-W-W-W-W
--------
Item Level: 68
--------
Twice Corrupted
]])
assert.truthy(item.corrupted)
assert.truthy(item.twiceCorrupted)
assert.are.equals(0, #item.explicitModLines)

item = new("Item"):Item([[
Item Class: Rings
Rarity: Rare
Doom Loop
Two-Stone Ring
--------
Item Level: 84
--------
+12% to Fire and Cold Resistances (implicit)
--------
+40 to maximum Life
+30% to Fire Resistance
--------
Twice Corrupted
]])
assert.truthy(item.corrupted)
assert.truthy(item.twiceCorrupted)
assert.are.equals(2, #item.explicitModLines)

item = new("Item"):Item(item:BuildRaw())
assert.truthy(item.corrupted)
assert.truthy(item.twiceCorrupted)
assert.are.equals(2, #item.explicitModLines)

item = new("Item"):Item(raw("Corrupted"))
assert.truthy(item.corrupted)
assert.falsy(item.twiceCorrupted)
end)

it("unidentified tiered items", function()
local item = new("Item"):Item([[
Item Class: Rings
Rarity: Rare
Geodesic Ring
--------
Item Level: 86
--------
{ Implicit Modifier }
+1 Prefix Modifier allowed
-1 Suffix Modifier allowed
--------
Unidentified (Tier 5)
]])
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals(86, item.itemLevel)
assert.are.equals(2, #item.implicitModLines)
assert.are.equals(0, #item.explicitModLines)
item = new("Item"):Item(item:BuildRaw())
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals(0, #item.explicitModLines)

item = new("Item"):Item([[
Item Class: Boots
Rarity: Magic
Shagreen Boots
--------
Evasion Rating: 186
--------
Requirements:
Level: 62
Dex: 117
--------
Sockets: G-G
--------
Item Level: 75
--------
Unidentified (Tier 4)
]])
assert.are.equals("Shagreen Boots", item.baseName)
assert.are.equals(0, #item.explicitModLines)

-- Once identified the tier is no longer shown
item = new("Item"):Item([[
Item Class: Boots
Rarity: Magic
Shagreen Boots of the Tempest
--------
Evasion Rating: 186
--------
Requirements:
Level: 62
Dex: 117
--------
Sockets: G-G
--------
Item Level: 75
--------
+42% to Lightning Resistance
]])
assert.are.equals("Shagreen Boots", item.baseName)
assert.are.equals(1, #item.explicitModLines)
end)

it("Fated items", function()
-- Copied in 3.30.0.4: unidentified rares from Fate-empowered bosses show "Fated " before the base name
local item = new("Item"):Item([[
Item Class: Rings
Rarity: Rare
Fated Geodesic Ring
--------
Item Level: 86
--------
{ Implicit Modifier }
+1 Prefix Modifier allowed
-1 Suffix Modifier allowed
Implicit Modifiers Cannot Be Changed — Unscalable Value
25% increased Prefix Modifier magnitudes — Unscalable Value
--------
Unidentified (Tier 5)
]])
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals("Ring", item.type)
assert.are.equals("Fated Geodesic Ring", item.title)
assert.are.equals(86, item.itemLevel)
assert.are.equals(4, #item.implicitModLines)
assert.are.equals(0, #item.explicitModLines)
item = new("Item"):Item(item:BuildRaw())
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals("Fated Geodesic Ring", item.title)
assert.are.equals(4, #item.implicitModLines)
assert.are.equals(0, #item.explicitModLines)

-- With quality
for _, name in ipairs({ "Superior Fated Astral Plate", "Fated Superior Astral Plate" }) do
item = new("Item"):Item(([[
Item Class: Body Armours
Rarity: Rare
%s
--------
Quality: +12% (augmented)
Armour: 797 (augmented)
--------
Item Level: 84
--------
Unidentified (Tier 3)
]]):gsub("%%s", name))
assert.are.equals("Astral Plate", item.baseName)
assert.are.equals(12, item.quality)
item = new("Item"):Item(item:BuildRaw())
assert.are.equals("Astral Plate", item.baseName)
assert.are.equals(12, item.quality)
end

-- Base name on its own line below a rare name
item = new("Item"):Item([[
Item Class: Rings
Rarity: Rare
Vengeance Band
Fated Geodesic Ring
--------
Item Level: 80
--------
+40 to maximum Life
]])
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals("Vengeance Band", item.title)
assert.are.equals(1, #item.explicitModLines)

-- Magic and normal items keep the label as a name prefix
item = new("Item"):Item([[
Item Class: Rings
Rarity: Magic
Fated Geodesic Ring
--------
Item Level: 86
--------
Unidentified (Tier 2)
]])
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals("Fated ", item.namePrefix)
item = new("Item"):Item(item:BuildRaw())
assert.are.equals("Geodesic Ring", item.baseName)
assert.are.equals("Fated ", item.namePrefix)

-- A unique whose name starts with the same word is left alone
item = new("Item"):Item([[
Rarity: Unique
Fated End
Paua Ring
]])
assert.are.equals("Fated End", item.title)
assert.are.equals("Paua Ring", item.baseName)
end)

it("long flags", function()
local item = new("Item"):Item(raw("This item can be anointed by Cassia"))
assert.truthy(item.canBeAnointed)
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/CompareTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3651,7 +3651,7 @@ function CompareTabClass:DrawItemExpanded(item, x, startY, colWidth, otherModMap

-- Corrupted/Split/Mirrored
if item.corrupted then
emit(x, drawY, "LEFT", fontSize, "VAR", colorCodes.NEGATIVE .. "Corrupted")
emit(x, drawY, "LEFT", fontSize, "VAR", colorCodes.NEGATIVE .. (item.twiceCorrupted and "Twice Corrupted" or "Corrupted"))
drawY = drawY + lineHeight
end
if item.split then
Expand Down
19 changes: 16 additions & 3 deletions src/Classes/Item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ end
---@field variantGroupList table<number, boolean>?
---@field modId string?

-- Game text for unidentified items. Since 3.30 a tiered item shows its tier, e.g. "Unidentified (Tier 5)"
local function isUnidentifiedLine(line)
return line == "Unidentified" or line:match("^Unidentified %(Tier %d+%)$") ~= nil
end

-- Parse raw item data and extract item name, base type, quality, and modifiers
function ItemClass:ParseRaw(raw, rarity, highQuality)
self.raw = raw
Expand Down Expand Up @@ -475,7 +480,7 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
-- Determine if "Unidentified" item
local unidentified = false
for _, line in ipairs(self.rawLines) do
if line == "Unidentified" then
if isUnidentifiedLine(line) then
unidentified = true
break
end
Expand Down Expand Up @@ -559,6 +564,11 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
self.mirrored = true
elseif line == "Corrupted" then
self.corrupted = true
elseif line == "Twice Corrupted" then
self.corrupted = true
self.twiceCorrupted = true
elseif isUnidentifiedLine(line) then
-- Unidentified items have no modifiers to parse
elseif line == "Fractured Item" then
self.fractured = true
elseif line == "Synthesised Item" then
Expand Down Expand Up @@ -1005,7 +1015,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
self.name = self.name:gsub(" %(.+%)","")
end
if not baseName then
baseName = line:gsub("^Superior ", ""):gsub("^Synthesised ", ""):gsub("^Vestigial ", "")
-- "Fated" is the 3.30 label on unidentified rares dropped by Fate-empowered bosses
baseName = line:gsub("^Fated ", ""):gsub("^Superior ", ""):gsub("^Fated ", ""):gsub("^Synthesised ", ""):gsub("^Vestigial ", "")
end
if baseName == "Two-Toned Boots" then
baseName = "Two-Toned Boots (Armour/Energy Shield)"
Expand Down Expand Up @@ -2066,7 +2077,9 @@ function ItemClass:BuildRaw()
if self.fractured then
t_insert(rawLines, "Fractured Item")
end
if self.corrupted or self.scourge then
if self.twiceCorrupted then
t_insert(rawLines, "Twice Corrupted")
elseif self.corrupted or self.scourge then
t_insert(rawLines, "Corrupted")
end
if self.foilType then
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/ItemsTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4711,7 +4711,7 @@ function ItemsTabClass:AddItemTooltip(tooltip, item, slot, dbMode, maxWidth)
tooltip:AddLine(fontSizeBig, colorCodes.NEGATIVE.."Mirrored", "FONTIN SC")
end
if item.corrupted then
tooltip:AddLine(fontSizeBig, colorCodes.NEGATIVE.."Corrupted", "FONTIN SC")
tooltip:AddLine(fontSizeBig, colorCodes.NEGATIVE..(item.twiceCorrupted and "Twice Corrupted" or "Corrupted"), "FONTIN SC")
end
tooltip:AddSeparator(14)
end
Expand Down