Skip to content

Commit ad5e10a

Browse files
Add parsing support for the advanced copy/paste format (#1986)
Co-authored-by: Wires77 <Wires77@users.noreply.github.com>
1 parent c687e2d commit ad5e10a

4 files changed

Lines changed: 395 additions & 15 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,193 @@ describe("TestItemParse", function()
461461
assert.are.equals(6, item.jewelSocketCount)
462462
end)
463463
end)
464+
465+
describe("TestAdvancedItemParse #item", function()
466+
local function raw(s, base)
467+
base = base or "Arcane Raiment"
468+
return "Rarity: Rare\nName\n"..base.."\n"..s
469+
end
470+
471+
it("parses to craft", function()
472+
local item = new("Item", raw([[
473+
{ Prefix Modifier "Azure" (Tier: 7) - Mana }
474+
+31(25-34) to maximum Mana
475+
]], "Refined Bracers"))
476+
assert.are.equals("IncreasedMana3", item.prefixes[1].modId)
477+
assert.are.equals(0.667, item.prefixes[1].range)
478+
assert.are.equals("mana", item.explicitModLines[1].modTags[1])
479+
end)
480+
481+
it("parses correct range", function()
482+
local item = new("Item", raw([[
483+
{ Desecrated Prefix Modifier "Frigid" (Tier: 6) - Damage, Elemental, Cold, Attack }
484+
Adds 8(7-8) to 13(12-14) Cold damage to Attacks
485+
]], "Refined Bracers"))
486+
assert.are.equals("Adds 8 to 13 Cold damage to Attacks", item.explicitModLines[1].line)
487+
end)
488+
489+
-- GGG scales each mod line separately here, but PoB scales them both together, so this parsing is a bit wonky
490+
it("parses multi-line mod", function()
491+
local item = new("Item", raw([[
492+
{ Prefix Modifier "Bishop's" (Tier: 3) — Life, Defences }
493+
27(27-32)% increased Energy Shield
494+
+31(26-32) to maximum Life
495+
]], "Ancestral Tiara"))
496+
assert.are.equals("LocalIncreasedEnergyShieldAndLife4", item.prefixes[1].modId)
497+
assert.are.equals(0, item.prefixes[1].range)
498+
assert.are.equals(0.833, item.explicitModLines[2].range)
499+
end)
500+
501+
it("resets linePrefix", function()
502+
local item = new("Item", raw([[
503+
{ Prefix Modifier "Warlock's" (Tier: 4) — Mana, Damage, Caster }
504+
32(30-37)% increased Spell Damage
505+
+46(42-47) to maximum Mana
506+
--------
507+
+15 to maximum life
508+
]], "Voltaic Staff"))
509+
assert.are_not.equals("mana", item.explicitModLines[3].modTags[1])
510+
end)
511+
512+
it("resets linePostfix", function()
513+
local item = new("Item", raw([[
514+
{ Corruption Enhancement — Mana }
515+
24(20-30)% increased Mana Regeneration Rate
516+
--------
517+
+15 to maximum life
518+
]]))
519+
assert.falsy(item.explicitModLines[1].enchant)
520+
end)
521+
522+
it("parses vaaled catalyst", function()
523+
local item = new("Item", raw([[
524+
Quality (Attribute Modifiers): +19% (augmented)
525+
{ Unique Modifier — Attribute — 19% Increased }
526+
+120(80-100) to all Attributes
527+
(Attributes are Strength, Dexterity, and Intelligence)
528+
]], "Stellar Amulet"))
529+
assert.are.equals(142, item.baseModList[1].value)
530+
-- assert.falsy(item.explicitModLines[1].range) -- Not sure why this is returning 0.5
531+
assert.are.equals(12, item.catalyst)
532+
assert.are.equals(19, item.catalystQuality)
533+
end)
534+
535+
it("parses vaaled catalyst within range", function()
536+
local item = new("Item", raw([[
537+
Quality (Attribute Modifiers): +19% (augmented)
538+
{ Unique Modifier — Attribute — 19% Increased }
539+
+95(80-100) to all Attributes
540+
(Attributes are Strength, Dexterity, and Intelligence)
541+
]], "Stellar Amulet"))
542+
assert.are.equals(113, item.baseModList[1].value)
543+
assert.are.equals(0.75, item.explicitModLines[1].range)
544+
assert.are.equals(12, item.catalyst)
545+
assert.are.equals(19, item.catalystQuality)
546+
end)
547+
548+
it("doesn't scale unscalable", function()
549+
local item = new("Item", raw([[
550+
Quality (Life and Mana Modifiers): +20% (augmented)
551+
{ Unique Modifier — Life, Defences, Energy Shield, Minion, Gem }
552+
Socketed Golem Skills gain 20% of Maximum Life as Extra Maximum Energy Shield — Unscalable Value
553+
]]))
554+
assert.are.equals(20, item.baseModList[1].value.mod.value)
555+
end)
556+
557+
it("correctly matches conqueror mod", function()
558+
local item = new("Item", raw([[
559+
{ Suffix Modifier "of the Conquest" (Tier: 1) — Elemental, Cold }
560+
10(8-10)% chance to Avoid Cold Damage from Hits
561+
(No chance to avoid damage can be higher than 75%)
562+
Warlord Item
563+
]]))
564+
assert.are.equals(10, item.baseModList[1].value)
565+
-- assert.are.equals(1, item.explicitModLines[1].range) -- Not sure why this is returning 0.5
566+
end)
567+
568+
it("parses enchant correctly #enchant", function()
569+
local item = new("Item", raw([[
570+
{ Corrupted Enhancement }
571+
+8(6-10)% to Fire Resistance
572+
]]))
573+
assert.are.equals(8, item.enchantModLines[1].modList[1].value)
574+
end)
575+
576+
it("parses enchant with tags correctly #enchant", function()
577+
local item = new("Item", raw([[
578+
{ Corrupted Enhancement - Energy Shield }
579+
+8(6-10)% to Fire Resistance
580+
]]))
581+
assert.are.equals(8, item.enchantModLines[1].modList[1].value)
582+
assert.are.equals("energyshield", item.enchantModLines[1].modTags[1])
583+
end)
584+
585+
it("parses junk", function()
586+
local godTestItem = new("Item", [[
587+
Item Class: Sceptres
588+
Rarity: Unique
589+
Nebulis
590+
Synthesised Void Sceptre
591+
--------
592+
Sceptre
593+
Physical Damage: 50-76
594+
Critical Strike Chance: 7.30%
595+
Attacks per Second: 1.25
596+
Weapon Range: 1.1 metres
597+
Memory Strands: 58
598+
--------
599+
Requirements:
600+
Level: 68
601+
Str: 104
602+
Int: 122
603+
--------
604+
Sockets: B R
605+
--------
606+
Item Level: 87
607+
--------
608+
+30% to Fire Resistance (scourge)
609+
22% reduced Global Defences (scourge)
610+
(Armour, Evasion Rating and Energy Shield are the standard Defences) (scourge)
611+
--------
612+
8% increased Explicit Cold Modifier magnitudes (enchant)
613+
Has 1 White Socket (enchant)
614+
--------
615+
{ Searing Exarch Implicit Modifier (Lesser) }
616+
Tempest Shield has 15(15-17)% increased Buff Effect
617+
{ Implicit Modifier — Damage, Critical — 106% Increased }
618+
+15(15-17)% to Global Critical Strike Multiplier
619+
--------
620+
{ Prefix Modifier "Freezing" (Tier: 5) — Damage, Elemental, Cold, Caster — 8% Increased }
621+
Adds 17(16-20) to 35(30-36) Cold Damage to Spells
622+
{ Prefix Modifier "Beetle's" (Tier: 6) — Defences, Armour }
623+
9(6-13)% increased Armour
624+
7(6-7)% increased Stun and Block Recovery
625+
{ Master Crafted Prefix Modifier "Upgraded" — Life, Defences, Armour }
626+
21(18-21)% increased Armour
627+
+18(17-19) to maximum Life
628+
{ Unique Modifier }
629+
106(60-120)% increased Implicit Modifier magnitudes — Unscalable Value
630+
(Implicit Modifiers are those that come from an item's type, rather than its random properties)
631+
{ Master Crafted Suffix Modifier "of Craft" (Rank: 3) — Elemental, Cold, Resistance }
632+
+35(29-35)% to Cold Resistance
633+
{ Fractured Prefix Modifier "Thorny" (Tier: 2) — Damage, Physical }
634+
Reflects 3(1-4) Physical Damage to Melee Attackers
635+
{ Prefix Modifier "Veiled" }
636+
Veiled Prefix
637+
Searing Exarch Item
638+
--------
639+
{ Allocated Crucible Passive Skill (Tier: 2) }
640+
Adds 2 to 6 Physical Damage to Spells
641+
--------
642+
Synthesised Item
643+
--------
644+
Corrupted
645+
--------
646+
Scourged
647+
--------
648+
Hinekora's Lock
649+
--------
650+
Note: ~b/o 2 chaos
651+
]])
652+
end)
653+
end)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff a/spec/System/TestItemParse_spec.lua b/spec/System/TestItemParse_spec.lua (rejected hunks)
2+
@@ -525,6 +525,16 @@ describe("TestAdvancedItemParse #item", function()
3+
assert.are_not.equals("mana", item.explicitModLines[3].modTags[1])
4+
end)
5+
6+
+ it("resets linePostfix", function()
7+
+ local item = new("Item", raw([[
8+
+ { Corruption Enhancement — Mana }
9+
+ 24(20-30)% increased Mana Regeneration Rate
10+
+ --------
11+
+ +15 to maximum life
12+
+ ]]))
13+
+ assert.falsy(item.explicitModLines[1].enchant)
14+
+ end)
15+
+
16+
it("parses vaaled catalyst", function()
17+
local item = new("Item", raw([[
18+
Quality (Attribute Modifiers): +19% (augmented)
19+
@@ -571,6 +581,23 @@ describe("TestAdvancedItemParse #item", function()
20+
-- assert.are.equals(1, item.explicitModLines[1].range) -- Not sure why this is returning 0.5
21+
end)
22+
23+
+ it("parses enchant correctly #enchant", function()
24+
+ local item = new("Item", raw([[
25+
+ { Corrupted Enhancement }
26+
+ +8(6-10)% to Fire Resistance
27+
+ ]]))
28+
+ assert.are.equals(8, item.enchantModLines[1].modList[1].value)
29+
+ end)
30+
+
31+
+ it("parses enchant with tags correctly #enchant", function()
32+
+ local item = new("Item", raw([[
33+
+ { Corrupted Enhancement - Energy Shield }
34+
+ +8(6-10)% to Fire Resistance
35+
+ ]]))
36+
+ assert.are.equals(8, item.enchantModLines[1].modList[1].value)
37+
+ assert.are.equals("energyshield", item.enchantModLines[1].modTags[1])
38+
+ end)
39+
+
40+
it("parses junk", function()
41+
local godTestItem = new("Item", [[
42+
Item Class: Sceptres

0 commit comments

Comments
 (0)