@@ -630,6 +630,8 @@ function ItemClass:ParseRaw(raw, rarity, highQuality)
630630 self .variantAlt4 = specToNumber (specVal )
631631 elseif specName == " Selected Alt Variant Five" then
632632 self .variantAlt5 = specToNumber (specVal )
633+ elseif specName == " Allow Duplicate Variants" then
634+ self .allowDuplicateVariants = specVal == " true"
633635 elseif specName == " Has Variants" or specName == " Selected Variants" then
634636 -- Need to skip this line for backwards compatibility
635637 -- with builds that used an old Watcher's Eye implementation
@@ -1462,6 +1464,9 @@ function ItemClass:BuildRaw()
14621464 t_insert (rawLines , " Has Alt Variant Five: true" )
14631465 t_insert (rawLines , " Selected Alt Variant Five: " .. self .variantAlt5 )
14641466 end
1467+ if self .allowDuplicateVariants then
1468+ t_insert (rawLines , " Allow Duplicate Variants: true" )
1469+ end
14651470 end
14661471 if self .quality then
14671472 t_insert (rawLines , " Quality: " .. self .quality )
@@ -1683,6 +1688,24 @@ function ItemClass:CheckModLineVariant(modLine)
16831688 or (self .hasAltVariant5 and modLine .variantList [self .variantAlt5 ])
16841689end
16851690
1691+ function ItemClass :GetModLineVariantCount (modLine )
1692+ if not self .allowDuplicateVariants or not modLine .variantList then
1693+ return self :CheckModLineVariant (modLine ) and 1 or 0
1694+ end
1695+
1696+ -- Mageblood can intentionally select the same variant more than once.
1697+ local variantList = modLine .variantList
1698+ local count = variantList [self .variant ] and 1 or 0
1699+ for i = 1 , 5 do
1700+ local suffix = i == 1 and " " or i
1701+ local variant = self [" variantAlt" .. suffix ]
1702+ if self [" hasAltVariant" .. suffix ] and variant and variantList [variant ] then
1703+ count = count + 1
1704+ end
1705+ end
1706+ return count
1707+ end
1708+
16861709-- Return the name of the slot this item is equipped in
16871710function ItemClass :GetPrimarySlot ()
16881711 if self .base .weapon or self .base .type == " Wand" or self .base .type == " Sceptre" or self .base .type == " Staff" then
@@ -2027,7 +2050,8 @@ function ItemClass:BuildModList()
20272050 end
20282051 end
20292052 local function processModLine (modLine )
2030- if self :CheckModLineVariant (modLine ) then
2053+ local variantCount = self :GetModLineVariantCount (modLine )
2054+ if variantCount > 0 then
20312055 -- special section for variant over-ride of pre-modifier item parameters
20322056 if modLine .line :find (" Requires Class" ) then
20332057 self .classRestriction = modLine .line :gsub (" {variant:([%d,]+)}" , " " ):match (" Requires Class (.+)" )
@@ -2054,8 +2078,9 @@ function ItemClass:BuildModList()
20542078 end
20552079 end
20562080 for _ , mod in ipairs (modLine .modList ) do
2057- mod = modLib .setSource (mod , self .modSource )
2058- baseList :AddMod (mod )
2081+ for _ = 1 , variantCount do
2082+ baseList :AddMod (modLib .setSource (mod , self .modSource ))
2083+ end
20592084 end
20602085 if modLine .modTags and # modLine .modTags > 0 then
20612086 self .hasModTags = true
0 commit comments