Skip to content

Commit 0754ac7

Browse files
committed
Port remaining PoE1 changes
1 parent 6828bb3 commit 0754ac7

5 files changed

Lines changed: 343 additions & 62 deletions

File tree

spec/System/TestItemParse_spec.lua

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,193 @@ describe("TestItemParse", function()
449449

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

0 commit comments

Comments
 (0)