Module:Item/recipes: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
m (Repositioned rule for recipes using Temperance. It belongs in the "single item class" grouping.)
(Refactored for better readability and performance. Added automatic recipe conditions that check drop level. Fixed automatic recipes using The Obscured.)
Line 143: Line 143:
end
end


h.conditions.normal = h.conditions.factory.arg{arg='rarity_id', value='normal'}
function h.conditions.factory.drop_level_not_greater_than(args)
h.conditions.unique = h.conditions.factory.arg{arg='rarity_id', value='unique'}
    return function (tpl_args)
        if tpl_args.drop_level == nil then
            return true
        end
        return tpl_args.drop_level <= args.level
    end
end


function h.conditions.item_class_has_corrupted_implicits(tpl_args)
function h.conditions.item_class_has_corrupted_implicits(tpl_args)
Line 212: Line 218:
local c = {}
local c = {}


-- Default for all entries, but can be disabled by specific ones.
c.named_conditions = {
c.automatic_recipe_defaults = {
    is_normal = h.conditions.factory.arg{arg='rarity_id', value='normal'},
     is_drop_restricted = h.conditions.factory.arg{arg='is_drop_restricted', value=false},
    is_unique = h.conditions.factory.arg{arg='rarity_id', value='unique'},
     is_corrupted = h.conditions.factory.arg{arg='is_corrupted', value=false},
     is_not_drop_restricted = h.conditions.factory.arg{arg='is_drop_restricted', value=false},
     is_replica = h.conditions.factory.arg{arg='is_replica', value=false},
     is_not_corrupted = h.conditions.factory.arg{arg='is_corrupted', value=false},
     is_not_replica = h.conditions.factory.arg{arg='is_replica', value=false},
    drop_level_ngt_divcard_default_max_ilvl = h.conditions.factory.drop_level_not_greater_than{level=cfg.divination_card_exchange_default_max_ilvl},
    item_class_has_corrupted_implicits = h.conditions.item_class_has_corrupted_implicits,
    item_class_has_influences = h.conditions.item_class_has_influences,
    item_class_has_synthesised_implicits = h.conditions.item_class_has_synthesised_implicits,
    item_class_has_fractured_modifiers = h.conditions.item_class_has_fractured_modifiers,
}
}
-- Order matters!
-- Order matters!
Line 223: Line 235:
--[[
--[[
     {
     {
         defaults = {
         conditions = {
            arg_key = function (tpl_args) end,
        },
        condition = {
             function (tpl_args) end,
             function (tpl_args) end,
         },
         },
         text = '',
         text = '',
         groups = {
         parts = {
             {
             {
                 name = '',
                 name = '',
Line 244: Line 253:
     --
     --
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='name', values={i18n['Forge of the Phoenix Map'], i18n['Lair of the Hydra Map'], i18n['Maze of the Minotaur Map'], i18n['Pit of the Chimera Map']}},
             h.conditions.factory.arg{arg='name', values={i18n['Forge of the Phoenix Map'], i18n['Lair of the Hydra Map'], i18n['Maze of the Minotaur Map'], i18n['Pit of the Chimera Map']}},
         },
         },
Line 251: Line 262:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.shaper_guardian_map))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.shaper_guardian_map))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Guardian's Challenge
                 -- Guardian's Challenge
Line 260: Line 271:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
             h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
            h.conditions.factory.drop_level_not_greater_than{level=83},
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.item_level_x, 83, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])))
             return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.item_level_x, 83, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Lingering Remnants
                 -- Lingering Remnants
Line 279: Line 289:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
             h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
         },
         },
Line 289: Line 297:
             return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.map_with_x_percent_delirium, string.format(i18n.fmt.tier_x, 16, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])), 100))
             return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.map_with_x_percent_delirium, string.format(i18n.fmt.tier_x, 16, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])), 100))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Price of Prescience
                 -- The Price of Prescience
Line 298: Line 306:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
             is_drop_restricted = false,
             is_not_replica = true,
        },
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='base_item', value=i18n['Synthesised Map']},
             h.conditions.factory.arg{arg='base_item', value=i18n['Synthesised Map']},
         },
         },
Line 309: Line 314:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n['Synthesised Map']))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n['Synthesised Map']))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Justified Ambition
                 -- Justified Ambition
Line 321: Line 326:
     --
     --
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Amulets/Amulet9'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Amulets/Amulet9'},
         },
         },
Line 331: Line 334:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.agate_amulet))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.agate_amulet))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Lysah's Respite
                 -- Lysah's Respite
Line 340: Line 343:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring15'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring15'},
         },
         },
Line 347: Line 352:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.unset_ring))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.unset_ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Penitent
                 -- The Penitent
Line 356: Line 361:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring4'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring4'},
         },
         },
Line 363: Line 370:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gold_ring))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gold_ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Glimmer of Hope
                 -- Glimmer of Hope
Line 372: Line 379:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring8'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring8'},
         },
         },
Line 382: Line 387:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.prismatic_ring))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.prismatic_ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Hope
                 -- Hope
Line 391: Line 396:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='metadata_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
             h.conditions.factory.arg{arg='metadata_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
         },
         },
Line 398: Line 405:
             return string.format(i18n.fmt.random_variant, m_util.html.poe_color('rare', i18n.two_stone_ring))
             return string.format(i18n.fmt.random_variant, m_util.html.poe_color('rare', i18n.two_stone_ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Lantador's Lost Love
                 -- Lantador's Lost Love
Line 407: Line 414:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
             h.conditions.factory.arg{arg='base_item_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
         },
         },
Line 414: Line 423:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.two_stone_ring))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.two_stone_ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Heterochromia
                 -- Heterochromia
Line 423: Line 432:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Weapons/OneHandWeapons/OneHandMaces/Sceptre11'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Weapons/OneHandWeapons/OneHandMaces/Sceptre11'},
         },
         },
Line 430: Line 441:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.crystal_sceptre))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.crystal_sceptre))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Light and Truth
                 -- Light and Truth
Line 439: Line 450:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Flasks/FlaskUtility5'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Flasks/FlaskUtility5'},
         },
         },
Line 446: Line 459:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.granite_flask))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.granite_flask))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Earth Drinker
                 -- Earth Drinker
Line 455: Line 468:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Armours/Helmets/HelmetStrDex10'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Armours/Helmets/HelmetStrDex10'},
         },
         },
Line 462: Line 477:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.nightmare_bascinet))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.nightmare_bascinet))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Gladiator
                 -- The Gladiator
Line 471: Line 486:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt1'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt1'},
         },
         },
Line 478: Line 495:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.rustic_sash))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.rustic_sash))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Standoff
                 -- The Standoff
Line 487: Line 504:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt3'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt3'},
         },
         },
Line 494: Line 513:
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n['Leather Belt']))
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n['Leather Belt']))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Forgotten Treasure
                 -- The Forgotten Treasure
Line 503: Line 522:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
         },
         },
Line 513: Line 531:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.timeless_jewel))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.timeless_jewel))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Peaceful Moments
                 -- Peaceful Moments
Line 522: Line 540:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,  
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
             h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
         },
         },
Line 532: Line 549:
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.timeless_jewel))
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.timeless_jewel))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Eternal War
                 -- The Eternal War
Line 544: Line 561:
     --  
     --  
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
             is_corrupted = false,
             is_not_replica = true,
        },
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='name', value=i18n.precursors_emblem},
             h.conditions.factory.arg{arg='name', value=i18n.precursors_emblem},
         },
         },
Line 555: Line 569:
             return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.precursors_emblem)))
             return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.precursors_emblem)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Remembrance
                 -- Remembrance
Line 564: Line 578:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
             is_corrupted = false,
             is_not_replica = true,
        },
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='name', value=i18n.grand_spectrum},
             h.conditions.factory.arg{arg='name', value=i18n.grand_spectrum},
         },
         },
Line 575: Line 586:
             return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.grand_spectrum)))
             return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.grand_spectrum)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Divine Justice
                 -- Divine Justice
Line 587: Line 598:
     --  
     --  
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             function (tpl_args)
             function (tpl_args)
                 -- Items that have "Atziri" in their name
                 -- Items that have "Atziri" in their name
Line 610: Line 620:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.atziri)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.atziri)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Admirer
                 -- The Admirer
Line 619: Line 629:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.doedre, 1, true)
                 return string.find(tpl_args.name, i18n.doedre, 1, true)
Line 628: Line 640:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.doedre)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.doedre)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Doedre's Madness
                 -- Doedre's Madness
Line 637: Line 649:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.shavronne, 1, true)
                 return string.find(tpl_args.name, i18n.shavronne, 1, true)
Line 646: Line 660:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.shavronne)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.shavronne)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Aesthete
                 -- The Aesthete
Line 655: Line 669:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
             is_corrupted = false,
             is_not_replica = true,
        },
        condition = {
            h.conditions.unique,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.rigwald, 1, true)
                 return string.find(tpl_args.name, i18n.rigwald, 1, true)
Line 668: Line 679:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.rigwald)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.rigwald)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Wolf
                 -- The Wolf
Line 677: Line 688:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.lioneye, 1, true)
                 return string.find(tpl_args.name, i18n.lioneye, 1, true)
Line 686: Line 699:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.lioneye)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.lioneye)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Lion
                 -- The Lion
Line 695: Line 708:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.farrul, 1, true)
                 return string.find(tpl_args.name, i18n.farrul, 1, true)
Line 707: Line 719:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.farrul)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.farrul)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Council of Cats
                 -- Council of Cats
Line 716: Line 728:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             function (tpl_args)
             function (tpl_args)
                 return string.find(tpl_args.name, i18n.farrul, 1, true) or string.find(tpl_args.name, i18n.fenumus, 1, true) or string.find(tpl_args.name, i18n.saqawal, 1, true) or string.find(tpl_args.name, i18n.craiceann, 1, true)
                 return string.find(tpl_args.name, i18n.farrul, 1, true) or string.find(tpl_args.name, i18n.fenumus, 1, true) or string.find(tpl_args.name, i18n.saqawal, 1, true) or string.find(tpl_args.name, i18n.craiceann, 1, true)
Line 728: Line 739:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Bestiary'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Bestiary'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Boon of the First Ones
                 -- Boon of the First Ones
Line 740: Line 751:
     --
     --
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/BreachBossChaos'},
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/BreachBossChaos'},
         },
         },
Line 750: Line 760:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.chayula)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.chayula)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Dreamer
                 -- The Dreamer
Line 759: Line 769:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/'},
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/'},
         },
         },
Line 769: Line 778:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Breach'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Breach'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Breach
                 -- The Breach
Line 778: Line 787:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/MavenBoss/TheMaven'},
             h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/MavenBoss/TheMaven'},
         },
         },
Line 788: Line 796:
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.maven)))
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.maven)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Leviathan
                 -- The Leviathan
Line 800: Line 808:
     --
     --
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
             is_corrupted = false,
             is_not_replica = true,
        },
        condition = {
            h.conditions.unique,
             h.conditions.factory.acquisition_tag{tag = 'fishing'},
             h.conditions.factory.acquisition_tag{tag = 'fishing'},
         },
         },
Line 811: Line 816:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.fishing)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.fishing)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Baited Expectations
                 -- Baited Expectations
Line 820: Line 825:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
             is_replica = false,
             is_not_corrupted = true,
        },
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='is_replica', value=true},
             h.conditions.factory.arg{arg='is_replica', value=true},
         },
         },
Line 831: Line 833:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.replica)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.replica)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Forward Gaze
                 -- The Forward Gaze
Line 840: Line 842:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
         },
         },
Line 847: Line 851:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Valkyrie
                 -- The Valkyrie
Line 856: Line 860:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
         },
         },
Line 866: Line 868:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Undaunted
                 -- The Undaunted
Line 875: Line 877:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Beyond'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Beyond'].name},
         },
         },
Line 882: Line 886:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Beyond'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Beyond'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Calling
                 -- The Calling
Line 891: Line 895:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Delve'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Delve'].name},
         },
         },
Line 898: Line 904:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Delve'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Delve'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Alone in the Darkness
                 -- Alone in the Darkness
Line 907: Line 913:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Metamorph'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Metamorph'].name},
         },
         },
Line 917: Line 922:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Metamorph'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Metamorph'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Haunting Shadows
                 -- Haunting Shadows
Line 926: Line 931:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.normal,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Abyss'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Abyss'].name},
         },
         },
Line 936: Line 940:
             return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Abyss'].name))
             return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Abyss'].name))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Abyssal Incubator
                 -- Abyssal Incubator
Line 945: Line 949:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
             h.conditions.unique,
             -- Must have Synthesis tag, but not league-specific tag
            -- Must have Synthesis tag, but not league-specific tag
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Synthesis'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Synthesis'].name},
             h.conditions.factory.acquisition_tag{tag = 'league-specific', negate = true},
             h.conditions.factory.acquisition_tag{tag = 'league-specific', negate = true},
Line 957: Line 960:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Synthesis'].name)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Synthesis'].name)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Chasing Risk
                 -- Chasing Risk
Line 969: Line 972:
     --
     --
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             function(tpl_args)
             function(tpl_args)
Line 986: Line 988:
             return string.format(i18n.fmt.random, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
             return string.format(i18n.fmt.random, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Primordial
                 -- The Primordial
Line 995: Line 997:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             function(tpl_args)
             function(tpl_args)
Line 1,012: Line 1,013:
             return string.format(i18n.fmt.random_one_or_two_implicit_corrupted, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
             return string.format(i18n.fmt.random_one_or_two_implicit_corrupted, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- A Stone Perfected
                 -- A Stone Perfected
Line 1,021: Line 1,022:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_talisman'},
             h.conditions.factory.flag_is_set{flag = 'is_talisman'},
             h.conditions.factory.arg{arg='talisman_tier', value=1},
             h.conditions.factory.arg{arg='talisman_tier', value=1},
Line 1,033: Line 1,030:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.tier_1_talisman))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.tier_1_talisman))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Call to the First Ones
                 -- Call to the First Ones
Line 1,042: Line 1,039:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_not_replica = true,
            is_corrupted = false,
        },
        condition = {
             h.conditions.factory.flag_is_set{flag = 'is_talisman'},
             h.conditions.factory.flag_is_set{flag = 'is_talisman'},
         },
         },
Line 1,052: Line 1,046:
             return string.format(i18n.fmt.random, i18n.talisman)
             return string.format(i18n.fmt.random, i18n.talisman)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Primal Incubator
                 -- Primal Incubator
Line 1,061: Line 1,055:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='tags', value='atziri1'},
             h.conditions.factory.arg{arg='tags', value='atziri1'},
Line 1,069: Line 1,064:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sacrifice_fragment))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sacrifice_fragment))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Her Mask
                 -- Her Mask
Line 1,078: Line 1,073:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='tags', value='atziri2'},
             h.conditions.factory.arg{arg='tags', value='atziri2'},
Line 1,089: Line 1,082:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.mortal_fragment))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.mortal_fragment))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Sambodhi's Vow
                 -- Sambodhi's Vow
Line 1,098: Line 1,091:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             function (tpl_args)
             function (tpl_args)
Line 1,111: Line 1,102:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.uber_elder_fragment))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.uber_elder_fragment))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Eldritch Decay
                 -- The Eldritch Decay
Line 1,120: Line 1,111:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             function (tpl_args)
             function (tpl_args)
Line 1,148: Line 1,137:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.fragment))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.fragment))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Fragmented Incubator
                 -- Fragmented Incubator
Line 1,157: Line 1,146:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
             h.conditions.factory.arg{arg='class_id', value='Breachstone'},
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='MapFragment'},
             h.conditions.factory.arg{arg='tags', value='breachstone'},
             h.conditions.factory.arg{arg='tags', value='breachstone'},
         },
         },
Line 1,168: Line 1,155:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.breachstone))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.breachstone))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Obscured
                 -- The Obscured
Line 1,177: Line 1,164:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.arg{arg='essence_level', value=7},
             h.conditions.factory.arg{arg='essence_level', value=7},
Line 1,188: Line 1,173:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.deafening_essence), 3)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.deafening_essence), 3)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Cacophony
                 -- The Cacophony
Line 1,197: Line 1,182:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.arg{arg='essence_level', value=6},
             h.conditions.factory.arg{arg='essence_level', value=6},
Line 1,208: Line 1,191:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.shrieking_essence), 9)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.shrieking_essence), 9)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Harmony of Souls
                 -- Harmony of Souls
Line 1,217: Line 1,200:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
         },
         },
Line 1,227: Line 1,208:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Three Voices
                 -- Three Voices
Line 1,236: Line 1,217:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
             h.conditions.factory.flag_is_set{flag = 'is_essence'},
         },
         },
Line 1,246: Line 1,225:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Infused Incubator
                 -- Infused Incubator
Line 1,255: Line 1,234:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Ultimatum'].name},
             h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Ultimatum'].name},
         },
         },
Line 1,265: Line 1,242:
             return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Ultimatum'].name))
             return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Ultimatum'].name))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Challenging Incubator (previously Morphing Incubator)
                 -- Challenging Incubator (previously Morphing Incubator)
Line 1,274: Line 1,251:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
             h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
         },
         },
Line 1,284: Line 1,259:
             return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.delirium_orb))
             return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.delirium_orb))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Disdain
                 -- Disdain
Line 1,293: Line 1,268:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
             h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
         },
         },
Line 1,303: Line 1,276:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.delirium_orb), 10)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.delirium_orb), 10)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Dementophobia
                 -- Dementophobia
Line 1,312: Line 1,285:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_blight_item'},
             h.conditions.factory.flag_is_set{flag = 'is_blight_item'},
             function (tpl_args)
             function (tpl_args)
Line 1,325: Line 1,296:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.oil), 10)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.oil), 10)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Tireless Extractor
                 -- The Tireless Extractor
Line 1,334: Line 1,305:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             function (tpl_args)
             function (tpl_args)
Line 1,347: Line 1,316:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.vial), 10)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.vial), 10)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Rabbit's Foot
                 -- The Rabbit's Foot
Line 1,356: Line 1,325:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=5},
             h.conditions.factory.arg{arg='map_tier', value=5},
Line 1,364: Line 1,335:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 5)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 5)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Cartographer's Delight
                 -- Cartographer's Delight
Line 1,373: Line 1,344:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=6},
             h.conditions.factory.arg{arg='map_tier', value=6},
Line 1,381: Line 1,354:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 6)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 6)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Rain Tempter
                 -- Rain Tempter
Line 1,390: Line 1,363:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=12},
             h.conditions.factory.arg{arg='map_tier', value=12},
Line 1,398: Line 1,373:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 12)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 12)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Arena Champion
                 -- The Arena Champion
Line 1,407: Line 1,382:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=14},
             h.conditions.factory.arg{arg='map_tier', value=14},
Line 1,415: Line 1,392:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 14)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 14)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Surveyor
                 -- The Surveyor
Line 1,424: Line 1,401:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=15},
             h.conditions.factory.arg{arg='map_tier', value=15},
Line 1,432: Line 1,411:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 15)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 15)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Lost Worlds
                 -- Lost Worlds
Line 1,441: Line 1,420:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=15},
             h.conditions.factory.arg{arg='map_tier', value=15},
Line 1,452: Line 1,429:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 15)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 15)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Trial
                 -- The Trial
Line 1,461: Line 1,438:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=15},
             h.conditions.factory.arg{arg='map_tier', value=15},
Line 1,472: Line 1,447:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map_with_y_modifiers, 15, 8)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map_with_y_modifiers, 15, 8)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Easy Stroll
                 -- The Easy Stroll
Line 1,481: Line 1,456:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             function (tpl_args)
             function (tpl_args)
Line 1,494: Line 1,467:
             return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.the_price_of_protection, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_to_y_map, 14, 16))))
             return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.the_price_of_protection, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_to_y_map, 14, 16))))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Price of Protection
                 -- The Price of Protection
Line 1,503: Line 1,476:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=16},
             h.conditions.factory.arg{arg='map_tier', value=16},
Line 1,511: Line 1,486:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='MapMonsterPhysicalReflection3MapWorlds'}, string.format(i18n.fmt.tier_x_map, 16))))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='MapMonsterPhysicalReflection3MapWorlds'}, string.format(i18n.fmt.tier_x_map, 16))))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Azure Rage
                 -- Azure Rage
Line 1,520: Line 1,495:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=16},
             h.conditions.factory.arg{arg='map_tier', value=16},
Line 1,531: Line 1,504:
             return string.format(i18n.fmt.random_unidentified_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 16)))
             return string.format(i18n.fmt.random_unidentified_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 16)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Left to Fate
                 -- Left to Fate
Line 1,540: Line 1,513:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='map_tier', value=13},
             h.conditions.factory.arg{arg='map_tier', value=13},
Line 1,551: Line 1,522:
             return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.triskaidekaphobia, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 13))))
             return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.triskaidekaphobia, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 13))))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Triskaidekaphobia
                 -- Triskaidekaphobia
Line 1,560: Line 1,531:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.aura.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.aura.tag},
Line 1,572: Line 1,541:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.aura.tag)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.aura.tag)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Wilted Rose
                 -- The Wilted Rose
Line 1,581: Line 1,550:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
Line 1,593: Line 1,560:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.golem.tag)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.golem.tag)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Rite of Elements
                 -- The Rite of Elements
Line 1,602: Line 1,569:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
Line 1,616: Line 1,579:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_y_gem_z_quality, 21, m_game.constants.item.gem_tags.golem.tag, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_y_gem_z_quality, 21, m_game.constants.item.gem_tags.golem.tag, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Terrible Secret of Space
                 -- Terrible Secret of Space
Line 1,625: Line 1,588:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.trap.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.trap.tag},
Line 1,637: Line 1,598:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.trap.tag, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.trap.tag, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Deathly Designs
                 -- Deathly Designs
Line 1,646: Line 1,607:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.chaos.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.chaos.tag},
Line 1,658: Line 1,617:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.chaos.tag, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.chaos.tag, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Bitter Blossom
                 -- The Bitter Blossom
Line 1,667: Line 1,626:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.minion.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.minion.tag},
Line 1,675: Line 1,636:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.minion.tag, 20)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.minion.tag, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Summoner
                 -- The Summoner
Line 1,684: Line 1,645:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.spell.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.spell.tag},
Line 1,696: Line 1,655:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.spell.tag)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.spell.tag)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 --The Cataclysm
                 --The Cataclysm
Line 1,705: Line 1,664:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.vaal.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.vaal.tag},
Line 1,717: Line 1,672:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.vaal.tag, 20)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.vaal.tag, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Volatile Power
                 -- Volatile Power
Line 1,726: Line 1,681:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
Line 1,739: Line 1,690:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem, 21)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem, 21)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Blessing of Moosh
                 -- The Blessing of Moosh
Line 1,748: Line 1,699:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
Line 1,761: Line 1,708:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Hook
                 -- The Hook
Line 1,770: Line 1,717:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
Line 1,783: Line 1,726:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 20)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Doryani's Epiphany
                 -- Doryani's Epiphany
Line 1,792: Line 1,735:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
             h.conditions.factory.flag_is_set{flag = 'is_derived'},
Line 1,805: Line 1,744:
             return m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 19, 19))
             return m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 19, 19))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Dying Anguish
                 -- Dying Anguish
Line 1,814: Line 1,753:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
Line 1,822: Line 1,763:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem, m_game.constants.item.gem_tags.exceptional.tag)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem, m_game.constants.item.gem_tags.exceptional.tag)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Gemcutter's Mercy
                 -- Gemcutter's Mercy
Line 1,831: Line 1,772:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
             h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
Line 1,839: Line 1,782:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_quality, m_game.constants.item.gem_tags.exceptional.tag)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_quality, m_game.constants.item.gem_tags.exceptional.tag)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Home
                 -- Home
Line 1,848: Line 1,791:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='max_level', value=20},
             h.conditions.factory.arg{arg='max_level', value=20},
Line 1,856: Line 1,801:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 20, i18n.support)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 20, i18n.support)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Gift of the Gemling Queen
                 -- Gift of the Gemling Queen
Line 1,865: Line 1,810:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
         },
         },
Line 1,875: Line 1,818:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, i18n.support, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, i18n.support, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Dialla's Subjugation
                 -- Dialla's Subjugation
Line 1,884: Line 1,827:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
             h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
Line 1,897: Line 1,836:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 20)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Cheater
                 -- The Cheater
Line 1,906: Line 1,845:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
            is_corrupted = false,
        },
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
             h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
             h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
Line 1,919: Line 1,854:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 23)))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 23)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Desecrated Virtue
                 -- Desecrated Virtue
Line 1,928: Line 1,863:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.arg{arg='tags', value='bestiary_scarab'},
             h.conditions.factory.arg{arg='tags', value='bestiary_scarab'},
Line 1,936: Line 1,873:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.bestiary_scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.bestiary_scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Man With Bear
                 -- Man With Bear
Line 1,945: Line 1,882:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.arg{arg='tags', value='maps_scarab'},
             h.conditions.factory.arg{arg='tags', value='maps_scarab'},
Line 1,953: Line 1,892:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.cartography_scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.cartography_scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Deal
                 -- The Deal
Line 1,962: Line 1,901:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.arg{arg='tags', value='divination_scarab'},
             h.conditions.factory.arg{arg='tags', value='divination_scarab'},
Line 1,970: Line 1,911:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.divination_scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.divination_scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Card Sharp
                 -- The Card Sharp
Line 1,979: Line 1,920:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.arg{arg='tags', value='uber_scarab'},
             h.conditions.factory.arg{arg='tags', value='uber_scarab'},
Line 1,987: Line 1,930:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.horned_scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.horned_scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Rebirth and Renewal
                 -- Rebirth and Renewal
Line 1,996: Line 1,939:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.arg{arg='tags', value='delve_scarab'},
             h.conditions.factory.arg{arg='tags', value='delve_scarab'},
Line 2,004: Line 1,949:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sulphite_scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sulphite_scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Buried Treasure
                 -- Buried Treasure
Line 2,013: Line 1,958:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
         },
         },
Line 2,020: Line 1,967:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('normal', i18n.scarab), 4)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('normal', i18n.scarab), 4)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- More is Never Enough
                 -- More is Never Enough
Line 2,029: Line 1,976:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
         },
         },
Line 2,039: Line 1,985:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Cameria's Cut
                 -- Cameria's Cut
Line 2,048: Line 1,994:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
             h.conditions.factory.flag_is_set{flag = 'is_scarab'},
         },
         },
Line 2,058: Line 2,003:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Skittering Incubator
                 -- Skittering Incubator
Line 2,067: Line 2,012:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='tags', value='breachstone_splinter'},
             h.conditions.factory.arg{arg='tags', value='breachstone_splinter'},
Line 2,078: Line 2,021:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.breachstone_splinter), 5)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.breachstone_splinter), 5)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Puzzle
                 -- The Puzzle
Line 2,087: Line 2,030:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='tags', value='quality_currency'},
             h.conditions.factory.arg{arg='tags', value='quality_currency'},
Line 2,095: Line 2,040:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.quality_currency), 20)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.quality_currency), 20)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Master Artisan
                 -- The Master Artisan
Line 2,104: Line 2,049:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_fossil'},
             h.conditions.factory.flag_is_set{flag = 'is_fossil'},
         },
         },
Line 2,114: Line 2,057:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.fossil), 5)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.fossil), 5)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Tinkerer's Table
                 -- The Tinkerer's Table
Line 2,123: Line 2,066:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.flag_is_set{flag = 'is_fossil'},
             h.conditions.factory.flag_is_set{flag = 'is_fossil'},
         },
         },
Line 2,133: Line 2,074:
             return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.fossil))
             return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.fossil))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Fossilised Incubator
                 -- Fossilised Incubator
Line 2,142: Line 2,083:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
             function (tpl_args)
             function (tpl_args)
Line 2,155: Line 2,094:
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.scouting_report), 20)
             return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.scouting_report), 20)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Side Quest
                 -- The Side Quest
Line 2,164: Line 2,103:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='UniqueFragment'},
             h.conditions.factory.arg{arg='class_id', value='UniqueFragment'},
             h.conditions.factory.acquisition_tag{tag = 'Harbinger'},
             h.conditions.factory.acquisition_tag{tag = 'Harbinger'},
Line 2,175: Line 2,113:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.harbinger_fragment))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.harbinger_fragment))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Messenger
                 -- The Messenger
Line 2,187: Line 2,125:
     --
     --
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,194: Line 2,134:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.body_armour))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Body
                 -- The Body
Line 2,203: Line 2,143:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Shield'},
             h.conditions.factory.arg{arg='class_id', value='Shield'},
         },
         },
Line 2,213: Line 2,151:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.shield))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.shield))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Mercenary
                 -- The Mercenary
Line 2,222: Line 2,160:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', value='Shield'},
             h.conditions.factory.arg{arg='class_id', value='Shield'},
         },
         },
Line 2,229: Line 2,170:
             return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('normal', i18n.shield))
             return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('normal', i18n.shield))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Astral Protection
                 -- Astral Protection
Line 2,238: Line 2,179:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Helmet'},
             h.conditions.factory.arg{arg='class_id', value='Helmet'},
         },
         },
Line 2,245: Line 2,188:
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('magic', i18n.helmet))
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('magic', i18n.helmet))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Further Invention
                 -- Further Invention
Line 2,254: Line 2,197:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', value='Helmet'},
             h.conditions.factory.arg{arg='class_id', value='Helmet'},
         },
         },
Line 2,261: Line 2,207:
             return string.format(i18n.fmt.random_two_veiled, m_util.html.poe_color('rare', i18n.helmet))
             return string.format(i18n.fmt.random_two_veiled, m_util.html.poe_color('rare', i18n.helmet))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Journalist
                 -- The Journalist
Line 2,270: Line 2,216:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Claw'},
             h.conditions.factory.arg{arg='class_id', value='Claw'},
         },
         },
Line 2,280: Line 2,224:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.claw))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.claw))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Wolverine
                 -- The Wolverine
Line 2,289: Line 2,233:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Dagger', 'Rune Dagger'}},
             h.conditions.factory.arg{arg='class_id', values={'Dagger', 'Rune Dagger'}},
         },
         },
Line 2,296: Line 2,242:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.dagger))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.dagger))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Assassin's Favour
                 -- Assassin's Favour
Line 2,305: Line 2,251:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', value='Sceptre'},
             h.conditions.factory.arg{arg='class_id', value='Sceptre'},
         },
         },
Line 2,312: Line 2,261:
             return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('magic', string.format('%s %s', i18n.sceptre, h.modifier_link{id='LocalIncreasedAttackSpeed8'})))
             return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('magic', string.format('%s %s', i18n.sceptre, h.modifier_link{id='LocalIncreasedAttackSpeed8'})))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Lord of Celebration
                 -- The Lord of Celebration
Line 2,321: Line 2,270:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Bow'},
             h.conditions.factory.arg{arg='class_id', value='Bow'},
         },
         },
Line 2,328: Line 2,279:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.bow))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.bow))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Hunter's Resolve
                 -- Hunter's Resolve
Line 2,337: Line 2,288:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
         },
         },
Line 2,344: Line 2,297:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewel))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewel))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Garish Power
                 -- The Garish Power
Line 2,353: Line 2,306:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
         },
         },
Line 2,363: Line 2,314:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.jewel))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.jewel))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Eye of the Dragon
                 -- The Eye of the Dragon
Line 2,372: Line 2,323:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
         },
         },
Line 2,379: Line 2,332:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='PercentIncreasedLifeJewel'}, i18n.jewel)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='PercentIncreasedLifeJewel'}, i18n.jewel)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Shard of Fate
                 -- Shard of Fate
Line 2,388: Line 2,341:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
         },
         },
Line 2,395: Line 2,350:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewel, h.modifier_link{id='CriticalStrikeMultiplierJewel'})))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewel, h.modifier_link{id='CriticalStrikeMultiplierJewel'})))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Mountain
                 -- The Mountain
Line 2,404: Line 2,359:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
             h.conditions.factory.arg{arg='class_id', value='Jewel'},
         },
         },
Line 2,414: Line 2,367:
             return string.format(i18n.fmt.random_corrupted_implicit, m_util.html.poe_color('rare', i18n.jewel), h.modifier_link{id='V2CorruptedBloodImmunityCorrupted'})
             return string.format(i18n.fmt.random_corrupted_implicit, m_util.html.poe_color('rare', i18n.jewel), h.modifier_link{id='V2CorruptedBloodImmunityCorrupted'})
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Lachrymal Necrosis
                 -- Lachrymal Necrosis
Line 2,423: Line 2,376:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', value='Amulet'},
             h.conditions.factory.arg{arg='class_id', value='Amulet'},
         },
         },
Line 2,430: Line 2,386:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='IncreasedEnergyShieldPercent7'}, i18n.amulet)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='IncreasedEnergyShieldPercent7'}, i18n.amulet)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Sigil
                 -- The Sigil
Line 2,439: Line 2,395:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Amulet'},
             h.conditions.factory.arg{arg='class_id', value='Amulet'},
         },
         },
Line 2,449: Line 2,404:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.amulet))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.amulet))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Warden
                 -- The Warden
Line 2,458: Line 2,413:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Ring'},
             h.conditions.factory.arg{arg='class_id', value='Ring'},
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=83},
                return tpl_args.drop_level <= 83
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('magic', string.format('%s %s', i18n.ring, h.modifier_link{id='ChaosResist6'})))
             return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('magic', string.format('%s %s', i18n.ring, h.modifier_link{id='ChaosResist6'})))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Lord in Black
                 -- The Lord in Black
Line 2,477: Line 2,432:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Ring'},
             h.conditions.factory.arg{arg='class_id', value='Ring'},
         },
         },
Line 2,484: Line 2,441:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.ring))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Opulent
                 -- The Opulent
Line 2,493: Line 2,450:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Ring'},
             h.conditions.factory.arg{arg='class_id', value='Ring'},
         },
         },
Line 2,500: Line 2,459:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.ring))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Hubris
                 -- Hubris
Line 2,509: Line 2,468:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Ring'},
             h.conditions.factory.arg{arg='class_id', value='Ring'},
         },
         },
Line 2,519: Line 2,476:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.ring))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.ring))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Blind Venture
                 -- Blind Venture
Line 2,528: Line 2,485:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Belt'},
             h.conditions.factory.arg{arg='class_id', value='Belt'},
         },
         },
Line 2,535: Line 2,494:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.belt))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.belt))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Wretched
                 -- The Wretched
Line 2,544: Line 2,503:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Belt'},
             h.conditions.factory.arg{arg='class_id', value='Belt'},
         },
         },
Line 2,551: Line 2,512:
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.belt))
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.belt))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Dungeon Master
                 -- The Dungeon Master
Line 2,560: Line 2,521:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
         },
         },
Line 2,570: Line 2,529:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.map))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.map))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Encroaching Darkness
                 -- The Encroaching Darkness
Line 2,579: Line 2,538:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
         },
         },
Line 2,586: Line 2,547:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.map))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.map))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Otherworldly Incubator
                 -- Otherworldly Incubator
Line 2,595: Line 2,556:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Wand'},
             h.conditions.factory.arg{arg='class_id', value='Wand'},
         },
         },
Line 2,605: Line 2,564:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.wand))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.wand))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Traitor
                 -- The Traitor
Line 2,614: Line 2,573:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
             h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
         },
         },
Line 2,621: Line 2,582:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.staff))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.staff))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Tower
                 -- The Tower
Line 2,630: Line 2,591:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
             h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
             h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
             h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=66},
                return tpl_args.drop_level <= 66
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_x_link_item_level_y, 5, 66, m_util.html.poe_color('normal', i18n.staff))
             return string.format(i18n.fmt.random_x_link_item_level_y, 5, 66, m_util.html.poe_color('normal', i18n.staff))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Flora's Gift
                 -- The Flora's Gift
Line 2,650: Line 2,611:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Staff'},
             h.conditions.factory.arg{arg='class_id', value='Staff'},
             h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
             h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=55},
                return tpl_args.drop_level <= 55
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_x_link_item_level_y, 6, 55, m_util.html.poe_color('normal', i18n.staff))
             return string.format(i18n.fmt.random_x_link_item_level_y, 6, 55, m_util.html.poe_color('normal', i18n.staff))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Dark Mage
                 -- The Dark Mage
Line 2,670: Line 2,631:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,677: Line 2,640:
             return string.format(i18n.fmt.random_x_link_item_level_y, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
             return string.format(i18n.fmt.random_x_link_item_level_y, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Dapper Prodigy
                 -- The Dapper Prodigy
Line 2,686: Line 2,649:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,693: Line 2,658:
             return string.format(i18n.fmt.random_x_link_item_level_y_random_influenced, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
             return string.format(i18n.fmt.random_x_link_item_level_y_random_influenced, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Draped in Dreams
                 -- Draped in Dreams
Line 2,702: Line 2,667:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,709: Line 2,677:
             return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
             return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Chains that Bind
                 -- The Chains that Bind
Line 2,718: Line 2,686:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,  
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},  
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},  
         },
         },
Line 2,725: Line 2,695:
             return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
             return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Geomancer's Incubator
                 -- Geomancer's Incubator
Line 2,734: Line 2,704:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,741: Line 2,713:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.body_armour))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Destined to Crumble
                 -- Destined to Crumble
Line 2,750: Line 2,722:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
             h.conditions.factory.arg{arg='class_id', value='Body Armour'},
         },
         },
Line 2,757: Line 2,731:
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.body_armour))
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.body_armour))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Duality
                 -- Duality
Line 2,766: Line 2,740:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
         },
         },
Line 2,773: Line 2,749:
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.map))
             return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.map))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Boundless Realms
                 -- Boundless Realms
Line 2,782: Line 2,758:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_normal = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='Map'},
             h.conditions.factory.arg{arg='class_id', value='Map'},
         },
         },
Line 2,792: Line 2,766:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.map))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.map))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Explorer
                 -- The Explorer
Line 2,801: Line 2,775:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', value='Gloves'},
             h.conditions.factory.arg{arg='class_id', value='Gloves'},
         },
         },
Line 2,808: Line 2,784:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gloves))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gloves))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Mitts
                 -- Mitts
Line 2,817: Line 2,793:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Boots'},
             h.conditions.factory.arg{arg='class_id', value='Boots'},
         },
         },
Line 2,827: Line 2,801:
             return string.format(i18n.fmt.random_two_implicit_corrupted, string.format(i18n.fmt.item_level_x, 100, m_util.html.poe_color('unique', i18n.boots)))
             return string.format(i18n.fmt.random_two_implicit_corrupted, string.format(i18n.fmt.item_level_x, 100, m_util.html.poe_color('unique', i18n.boots)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Shepherd's Sandals
                 -- The Shepherd's Sandals
Line 2,836: Line 2,810:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
             h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
         },
         },
Line 2,846: Line 2,818:
             return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
             return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Gambler
                 -- The Gambler
Line 2,857: Line 2,829:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
             h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
             h.conditions.factory.not_arg{arg='tags', value='boss_drop_card'},
             h.conditions.factory.not_arg{arg='tags', value='boss_drop_card'},
Line 2,868: Line 2,838:
             return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
             return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Stacked Deck
                 -- Stacked Deck
Line 2,877: Line 2,847:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='HeistBlueprint'},
             h.conditions.factory.arg{arg='class_id', value='HeistBlueprint'},
         },
         },
Line 2,887: Line 2,855:
             return string.format(i18n.fmt.random, string.format(i18n.fmt.fully_revealed_x_area_level_y, m_util.html.poe_color('normal', i18n.blueprint), 83))
             return string.format(i18n.fmt.random, string.format(i18n.fmt.fully_revealed_x_area_level_y, m_util.html.poe_color('normal', i18n.blueprint), 83))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Something Dark
                 -- Something Dark
Line 2,896: Line 2,864:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='class_id', value='IncubatorStackable'},
             h.conditions.factory.arg{arg='class_id', value='IncubatorStackable'},
         },
         },
Line 2,906: Line 2,872:
             return string.format(i18n.fmt.random_x_amount, string.format(i18n.fmt.item_level_x, 84, m_util.html.poe_color('currency', i18n.incubator)), 10)
             return string.format(i18n.fmt.random_x_amount, string.format(i18n.fmt.item_level_x, 84, m_util.html.poe_color('currency', i18n.incubator)), 10)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Parasitic Passengers
                 -- Parasitic Passengers
Line 2,915: Line 2,881:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_unique = true,
        },
            is_not_replica = true,
        condition = {
            is_not_corrupted = true,
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', value='Relic'},
             h.conditions.factory.arg{arg='class_id', value='Relic'},
         },
         },
Line 2,925: Line 2,890:
             return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('unique', i18n.relic))
             return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('unique', i18n.relic))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Temperance
                 -- Temperance
Line 2,937: Line 2,902:
     --
     --
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'One Hand Axe', 'Two Hand Axe'}},
             h.conditions.factory.arg{arg='class_id', values={'One Hand Axe', 'Two Hand Axe'}},
         },
         },
Line 2,944: Line 2,911:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.axe))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.axe))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Battle Born
                 -- The Battle Born
Line 2,953: Line 2,920:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='max_level', value=20},
             h.conditions.factory.arg{arg='max_level', value=20},
Line 2,961: Line 2,930:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_gem, 20)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_gem, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Fox
                 -- The Fox
Line 2,970: Line 2,939:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
         },
         },
Line 2,977: Line 2,948:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.gem_x_quality, 20)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.gem_x_quality, 20)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Gemcutter's Promise
                 -- Gemcutter's Promise
Line 2,986: Line 2,957:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
         },
         },
Line 2,993: Line 2,966:
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', i18n.fmt.gem_quality))
             return string.format(i18n.fmt.random, m_util.html.poe_color('gem', i18n.fmt.gem_quality))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Gemcutter's Incubator
                 -- Gemcutter's Incubator
Line 3,002: Line 2,975:
     },
     },
     --[[{
     --[[{
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
         },
         },
Line 3,009: Line 2,984:
             return string.format(i18n.fmt.random_x_quality, m_util.html.poe_color('unique', i18n.armour), 30)
             return string.format(i18n.fmt.random_x_quality, m_util.html.poe_color('unique', i18n.armour), 30)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Sambodhi's Wisdom
                 -- Sambodhi's Wisdom
Line 3,018: Line 2,993:
     },--]]
     },--]]
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
             h.conditions.factory.arg{arg='tags', value='int_armour'},
             h.conditions.factory.arg{arg='tags', value='int_armour'},
Line 3,026: Line 3,004:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedEnergyShieldPercentAndStunRecovery6'}, i18n.armour)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedEnergyShieldPercentAndStunRecovery6'}, i18n.armour)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Inoculated
                 -- The Inoculated
Line 3,035: Line 3,013:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
         },
         },
Line 3,042: Line 3,023:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.life, i18n.armour)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.life, i18n.armour)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Carrion Crow
                 -- The Carrion Crow
Line 3,051: Line 3,032:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
         },
         },
Line 3,058: Line 3,041:
             return string.format(i18n.fmt.random_shaper_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
             return string.format(i18n.fmt.random_shaper_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Perfection
                 -- Perfection
Line 3,067: Line 3,050:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
         },
         },
Line 3,074: Line 3,059:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewellery))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewellery))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Cache
                 -- The Cache
Line 3,083: Line 3,068:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
            h.conditions.factory.drop_level_not_greater_than{level=86},
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 86, m_util.html.poe_color('rare', i18n.jewellery))
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 86, m_util.html.poe_color('rare', i18n.jewellery))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Awakened
                 -- The Awakened
Line 3,099: Line 3,087:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=79},
                return tpl_args.drop_level <= 79
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_item_level_x, 79, m_util.html.poe_color('rare', i18n.jewellery))
             return string.format(i18n.fmt.random_item_level_x, 79, m_util.html.poe_color('rare', i18n.jewellery))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Lover
                 -- The Lover
Line 3,118: Line 3,106:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
             h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=85},
                return tpl_args.drop_level <= 85
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_item_level_x, 85, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='ReduceGlobalFlatManaCostStrIntMasterVendor'}, i18n.jewellery)))
             return string.format(i18n.fmt.random_item_level_x, 85, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='ReduceGlobalFlatManaCostStrIntMasterVendor'}, i18n.jewellery)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Blessing of God
                 -- Blessing of God
Line 3,137: Line 3,125:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
             h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
             function (tpl_args)
             h.conditions.factory.drop_level_not_greater_than{level=76},
                return tpl_args.drop_level <= 76
            end,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_item_level_x, 76, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='AddedLightningDamage9'}, i18n.jewellery)))
             return string.format(i18n.fmt.random_item_level_x, 76, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='AddedLightningDamage9'}, i18n.jewellery)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Struck by Lightning
                 -- Struck by Lightning
Line 3,156: Line 3,144:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
         },
         },
Line 3,163: Line 3,153:
             return string.format(i18n.fmt.random_shaper_hunter_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewellery, h.modifier_link{id='GrantsCatAspectCrafted'})))
             return string.format(i18n.fmt.random_shaper_hunter_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewellery, h.modifier_link{id='GrantsCatAspectCrafted'})))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- A Familiar Call
                 -- A Familiar Call
Line 3,172: Line 3,162:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
         },
         },
Line 3,179: Line 3,171:
             return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
             return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Imperfect Memories
                 -- Imperfect Memories
Line 3,188: Line 3,180:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Two Hand Sword', 'Two Hand Axe', 'Two Hand Mace', 'Staff', 'Bow', 'Warstaff'}},
             h.conditions.factory.arg{arg='class_id', values={'Two Hand Sword', 'Two Hand Axe', 'Two Hand Mace', 'Staff', 'Bow', 'Warstaff'}},
         },
         },
Line 3,195: Line 3,189:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.two_hand_weapon)))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.two_hand_weapon)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Merciless Armament
                 -- Merciless Armament
Line 3,204: Line 3,198:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
         },
         },
Line 3,211: Line 3,207:
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('rare', i18n.one_hand_weapon))
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('rare', i18n.one_hand_weapon))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Prometheus' Armoury
                 -- Prometheus' Armoury
Line 3,220: Line 3,216:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
         },
         },
Line 3,227: Line 3,225:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.one_hand_weapon)))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.one_hand_weapon)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Jester
                 -- The Jester
Line 3,236: Line 3,234:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values={'Sceptre', 'Wand', 'Rune Dagger'}},
             h.conditions.factory.arg{arg='class_id', values={'Sceptre', 'Wand', 'Rune Dagger'}},
         },
         },
Line 3,243: Line 3,243:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='SpellDamageOnWeapon8_'}, i18n.one_hand_weapon)))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='SpellDamageOnWeapon8_'}, i18n.one_hand_weapon)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Road to Power
                 -- The Road to Power
Line 3,252: Line 3,252:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'Two Hand Sword'}},
             h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'Two Hand Sword'}},
         },
         },
Line 3,262: Line 3,260:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.sword))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.sword))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Gentleman
                 -- The Gentleman
Line 3,271: Line 3,269:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
         },
         },
Line 3,278: Line 3,278:
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic',string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.weapon)))
             return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic',string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.weapon)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Tyrant
                 -- The Tyrant
Line 3,287: Line 3,287:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
         },
         },
Line 3,294: Line 3,297:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.weapon, h.modifier_link{id='StrIntMasterItemGenerationCanHaveMultipleCraftedMods'})))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.weapon, h.modifier_link{id='StrIntMasterItemGenerationCanHaveMultipleCraftedMods'})))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Web
                 -- The Web
Line 3,303: Line 3,306:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
         },
         },
Line 3,313: Line 3,314:
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.weapon))
             return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.weapon))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Atziri's Arsenal
                 -- Atziri's Arsenal
Line 3,322: Line 3,323:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.flasks.keys},
             h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.flasks.keys},
         },
         },
Line 3,329: Line 3,333:
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='FlaskChanceRechargeOnCrit5'}, i18n.flask)))
             return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='FlaskChanceRechargeOnCrit5'}, i18n.flask)))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Surgeon
                 -- The Surgeon
Line 3,338: Line 3,342:
     },
     },
     --[[{
     --[[{
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
            h.conditions.normal,
             h.conditions.factory.arg{arg='tags', value='two_hand_weapon'},
             h.conditions.factory.arg{arg='tags', value='two_hand_weapon'},
             h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
             h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
            h.conditions.factory.drop_level_not_greater_than{level=86},
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_x_quality, string.format(i18n.fmt.item_level_x, 86, m_util.html.poe_color('rare', i18n.experimented_two_hand_weapon)), 30)
             return string.format(i18n.fmt.random_x_quality, string.format(i18n.fmt.item_level_x, 86, m_util.html.poe_color('rare', i18n.experimented_two_hand_weapon)), 30)
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Soul Quenched
                 -- Soul Quenched
Line 3,358: Line 3,361:
     },--]]
     },--]]
     {
     {
         defaults = {
         conditions = {
             is_drop_restricted = false,
             is_normal = true,
        },
            is_not_corrupted = true,
        condition = {
             item_class_has_influences = true,
            h.conditions.normal,
             h.conditions.item_class_has_influences,
             h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
             h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
         },
         },
Line 3,369: Line 3,370:
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.experimented_base_type))
             return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.experimented_base_type))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Auspicious Ambitions
                 -- Auspicious Ambitions
Line 3,378: Line 3,379:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
             item_class_has_corrupted_implicits = true,
            h.conditions.unique,
             item_class_has_influences = true,
             h.conditions.item_class_has_corrupted_implicits,
             h.conditions.item_class_has_influences,
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
         },
         },
Line 3,390: Line 3,389:
             return string.format(i18n.fmt.random_two_implicit_corrupted_two_influenced_item_level_x, 97, m_util.html.poe_color('unique', i18n.league_specific_item))
             return string.format(i18n.fmt.random_two_implicit_corrupted_two_influenced_item_level_x, 97, m_util.html.poe_color('unique', i18n.league_specific_item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Fateful Meeting
                 -- Fateful Meeting
Line 3,399: Line 3,398:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,  
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
         },
         },
Line 3,409: Line 3,406:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Time-Lost Relic
                 -- Time-Lost Relic
Line 3,418: Line 3,415:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
            h.conditions.unique,  
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
             h.conditions.factory.acquisition_tag{tag = 'league-specific'},
         },
         },
Line 3,428: Line 3,423:
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Time-Lost Incubator
                 -- Time-Lost Incubator
Line 3,440: Line 3,435:
     --
     --
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
             h.conditions.item_class_has_fractured_modifiers,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             item_class_has_fractured_modifiers = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_fractured_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
             return string.format(i18n.fmt.random_fractured_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- A Dusty Memory
                 -- A Dusty Memory
Line 3,456: Line 3,453:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
             h.conditions.item_class_has_influences,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             item_class_has_influences = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_elder_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
             return string.format(i18n.fmt.random_elder_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Hale Heart
                 -- The Hale Heart
Line 3,472: Line 3,471:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
             h.conditions.item_class_has_influences,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             item_class_has_influences = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_influenced, m_util.html.poe_color('unique', i18n.item))
             return string.format(i18n.fmt.random_influenced, m_util.html.poe_color('unique', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Prejudice
                 -- Prejudice
Line 3,488: Line 3,489:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
             h.conditions.item_class_has_influences,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             item_class_has_influences = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.item))
             return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Costly Curio
                 -- Costly Curio
Line 3,504: Line 3,507:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
             h.conditions.item_class_has_influences,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
             item_class_has_influences = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_influenced_x_elevated, m_util.html.poe_color('magic', i18n.item))
             return string.format(i18n.fmt.random_influenced_x_elevated, m_util.html.poe_color('magic', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- The Aspirant
                 -- The Aspirant
Line 3,520: Line 3,526:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.normal,
             is_normal = true,
             h.conditions.item_class_has_synthesised_implicits,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
             item_class_has_synthesised_implicits = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('normal', i18n.item))
             return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('normal', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Magnum Opus
                 -- Magnum Opus
Line 3,536: Line 3,544:
     },
     },
     {
     {
         defaults = {
         conditions = {
             is_corrupted = false,
             is_unique = true,
        },
            is_not_drop_restricted = true,
        condition = {
             item_class_has_corrupted_implicits = true,
            h.conditions.unique,
             h.conditions.item_class_has_corrupted_implicits,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.item))
             return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Arrogance of the Vaal
                 -- Arrogance of the Vaal
Line 3,555: Line 3,561:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Jack in the Box
                 -- Jack in the Box
Line 3,570: Line 3,578:
     },
     },
     {
     {
         condition = {
         conditions = {
             h.conditions.unique,
             is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
         },
         },
         text = function ()
         text = function ()
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
             return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
         end,
         end,
         groups = {
         parts = {
             {
             {
                 -- Singular Incubator
                 -- Singular Incubator
Line 3,598: Line 3,608:
         page = {},
         page = {},
     }
     }
     local sets = {}
     local recipes = {}
      
      
     -- ------------------------------------------------------------------------
     -- ------------------------------------------------------------------------
     -- Manual data
     -- Manual data
     -- ------------------------------------------------------------------------
     -- ------------------------------------------------------------------------
     local setid = #sets + 1
     local recipe_num = #recipes + 1
     local set
     local recipe
     repeat
     repeat
         local prefix = string.format('recipe%s_', setid)
         local prefix = string.format('recipe%s_', recipe_num)
         local groupid = 1
         local part_num = 1
         local group
         local part
         set = {
         recipe = {
             groups = {},
             parts = {},
             result_amount = tonumber(tpl_args[prefix .. 'result_amount']) or 1,
             result_amount = tonumber(tpl_args[prefix .. 'result_amount']) or 1,
             text = m_util.cast.text(tpl_args[prefix .. 'description']),
             text = m_util.cast.text(tpl_args[prefix .. 'description']),
Line 3,616: Line 3,626:
         }
         }
         repeat  
         repeat  
             local group_prefix = string.format('%spart%s_', prefix, groupid)
             local part_prefix = string.format('%spart%s_', prefix, part_num)
             group = {
             part = {
                 item_name = tpl_args[group_prefix .. 'item_name'],
                 item_name = tpl_args[part_prefix .. 'item_name'],
                 item_id = tpl_args[group_prefix .. 'item_id'],  
                 item_id = tpl_args[part_prefix .. 'item_id'],  
                 item_page = tpl_args[group_prefix .. 'item_page'],  
                 item_page = tpl_args[part_prefix .. 'item_page'],  
                 amount = tonumber(tpl_args[group_prefix .. 'amount']),
                 amount = tonumber(tpl_args[part_prefix .. 'amount']),
                 notes = m_util.cast.text(tpl_args[group_prefix .. 'notes']),
                 notes = m_util.cast.text(tpl_args[part_prefix .. 'notes']),
             }
             }
              
              
             if group.item_name ~= nil or group.item_id ~= nil or group.item_page ~= nil then
             if part.item_name ~= nil or part.item_id ~= nil or part.item_page ~= nil then
                 if group.amount == nil then
                 if part.amount == nil then
                     error(string.format(i18n.errors.missing_amount, group_prefix .. 'amount'))
                     error(string.format(i18n.errors.missing_amount, part_prefix .. 'amount'))
                 else
                 else
                     for key, array in pairs(query_data) do
                     for key, array in pairs(query_data) do
                         local value = group['item_' .. key]
                         local value = part['item_' .. key]
                         if value then
                         if value then
                             if array[value] then
                             if array[value] then
                                 table.insert(array[value], {setid, groupid})
                                 table.insert(array[value], {recipe_num, part_num})
                             else
                             else
                                 array[value] = {{setid, groupid}, }
                                 array[value] = {{recipe_num, part_num}, }
                             end
                             end
                         end
                         end
                     end
                     end
                     set.groups[#set.groups+1] = group
                     recipe.parts[#recipe.parts+1] = part
                 end
                 end
             end
             end
              
              
             groupid = groupid + 1
             part_num = part_num + 1
         until group.item_name == nil and group.item_id == nil and group.item_page == nil
         until part.item_name == nil and part.item_id == nil and part.item_page == nil
          
          
         -- set was empty, can terminate safely
         -- recipe was empty, can terminate safely
         if #set.groups == 0 then
         if #recipe.parts == 0 then
             set = nil
             recipe = nil
         else
         else
             setid = setid + 1
             recipe_num = recipe_num + 1
             sets[#sets+1] = set
             recipes[#recipes+1] = recipe
         end
         end
     until set == nil
     until recipe == nil


     -- ------------------------------------------------------------------------
     -- ------------------------------------------------------------------------
Line 3,662: Line 3,672:
     --  maps
     --  maps
     --
     --
     local automatic_index = #sets + 1
     local automatic_index = #recipes + 1
     -- TODO: 3.9.0 Unsure how this works yet, so disabled for now
     -- TODO: 3.9.0 Unsure how this works yet, so disabled for now
     --[[if tpl_args.atlas_connections and tpl_args.rarity_id == 'normal' then
     --[[if tpl_args.atlas_connections and tpl_args.rarity_id == 'normal' then
Line 3,674: Line 3,684:
         )
         )
         for _, row in ipairs(results) do
         for _, row in ipairs(results) do
             sets[#sets+1] = {
             recipes[#recipes+1] = {
                 text = i18n.misc.upgraded_from_map,
                 text = i18n.misc.upgraded_from_map,
                 result_amount = 1,
                 result_amount = 1,
                 groups = {
                 parts = {
                     {
                     {
                         item_name = row['items.name'],
                         item_name = row['items.name'],
Line 3,703: Line 3,713:
         )
         )
         for _, row in ipairs(results) do
         for _, row in ipairs(results) do
             sets[#sets+1] = {
             recipes[#recipes+1] = {
                 text = nil,
                 text = nil,
                 result_amount = 1,
                 result_amount = 1,
                 groups = {
                 parts = {
                     {
                     {
                         item_name = row['items.name'],
                         item_name = row['items.name'],
Line 3,760: Line 3,770:
             if row['essences.category'] == tpl_args.essence_category then
             if row['essences.category'] == tpl_args.essence_category then
                 -- 3 to 1 recipe
                 -- 3 to 1 recipe
                 sets[#sets+1] = {
                 recipes[#recipes+1] = {
                     automatic = true,
                     automatic = true,
                     result_amount = 1,
                     result_amount = 1,
                     text = nil,
                     text = nil,
                     groups = {
                     parts = {
                         {
                         {
                             item_id = row['items.metadata_id'],
                             item_id = row['items.metadata_id'],
Line 3,774: Line 3,784:
                 }
                 }
                 -- corruption +1
                 -- corruption +1
                 sets[#sets+1] = {
                 recipes[#recipes+1] = {
                     automatic = true,
                     automatic = true,
                     result_amount = 1,
                     result_amount = 1,
                     text = i18n.essence_plus_one_level,
                     text = i18n.essence_plus_one_level,
                     groups = {
                     parts = {
                         {
                         {
                             item_id = row['items.metadata_id'],
                             item_id = row['items.metadata_id'],
Line 3,795: Line 3,805:
             elseif tonumber(row['essences.type']) == tpl_args.essence_type - 1 then
             elseif tonumber(row['essences.type']) == tpl_args.essence_type - 1 then
                 -- corruption type change
                 -- corruption type change
                 sets[#sets+1] = {
                 recipes[#recipes+1] = {
                     automatic = true,
                     automatic = true,
                     result_amount = 1,
                     result_amount = 1,
                     text = i18n.essence_type_change,
                     text = i18n.essence_type_change,
                     groups = {
                     parts = {
                         {
                         {
                             item_id = row['items.metadata_id'],
                             item_id = row['items.metadata_id'],
Line 3,820: Line 3,830:
     -- data based on mapping
     -- data based on mapping
     if tpl_args.drop_enabled and not tpl_args.disable_automatic_recipes then
     if tpl_args.drop_enabled and not tpl_args.disable_automatic_recipes then
        -- Test and cache results of all named conditions
        for k, condition in pairs(c.named_conditions) do
            if type(condition) == 'function' then
                c.named_conditions[k] = condition(tpl_args)
            end
        end
         for _, data in ipairs(c.automatic_recipes) do
         for _, data in ipairs(c.automatic_recipes) do
             data.defaults = data.defaults or {}
             local valid = true -- Can this recipe produce the item?
             local continue = true
 
             for key, value in pairs(c.automatic_recipe_defaults) do
             -- Check cached results for named conditions
                 local func
             for k, condition in pairs(c.named_conditions) do
                local v = data.defaults[key]
                 if data.conditions[k] then
                if v == false then
                     valid = condition
                    -- check is disabled specifically, continue
                     if not valid then
                elseif v == nil then
                     func = value
                elseif type(v) == 'function' then
                    func = v
                else
                    error(string.format('Invalid value for defaults at data %s', mw.dumpObject(data)))
                end
                if func then
                    continue = func(tpl_args) and continue
                     if not continue then
                         break
                         break
                     end  
                     end
                 end
                 end
             end
             end
             for _, condition in ipairs(data.condition) do
 
                 continue = condition(tpl_args) and continue
            -- Test anonymous conditions
                 if not continue then
             for _, condition in ipairs(data.conditions) do
                 valid = condition(tpl_args) and valid
                 if not valid then
                     break
                     break
                 end
                 end
             end
             end
           
 
             if continue then
             if valid then
                 sets[#sets+1] = {
                 recipes[#recipes+1] = {
                     automatic = true,
                     automatic = true,
                     result_amount = 1,
                     result_amount = 1,
                     text = data.text(),
                     text = data.text(),
                     groups = data.groups,
                     parts = data.parts,
                 }
                 }
                 for groupid, row in ipairs(data.groups) do
                 for part_num, row in ipairs(data.parts) do
                     if query_data['id'][row.item_id] then
                     if query_data['id'][row.item_id] then
                         table.insert(query_data['id'][row.item_id], {#sets, groupid})
                         table.insert(query_data['id'][row.item_id], {#recipes, part_num})
                     else
                     else
                         query_data['id'][row.item_id] = {{#sets, groupid}, }
                         query_data['id'][row.item_id] = {{#recipes, part_num}, }
                     end
                     end
                 end
                 end
Line 3,867: Line 3,876:
     end
     end
      
      
     if #sets == 0 then
     if #recipes == 0 then
         return
         return
     end
     end
Line 3,906: Line 3,915:
     for _, row in ipairs(results) do
     for _, row in ipairs(results) do
         if row[query_fields.id] and string.find(row[query_fields.id], 'Metadata/Items/DivinationCards/', 1, true) then
         if row[query_fields.id] and string.find(row[query_fields.id], 'Metadata/Items/DivinationCards/', 1, true) then
             local group = {
             local part = {
                 item_id = 'Metadata/Items/DivinationCards/DivinationCardTheVoid',
                 item_id = 'Metadata/Items/DivinationCards/DivinationCardTheVoid',
                 amount = 1,
                 amount = 1,
Line 3,914: Line 3,923:
                 {'items._pageName',  'items.name', 'items.metadata_id'},
                 {'items._pageName',  'items.name', 'items.metadata_id'},
                 {
                 {
                     where=string.format('%s = "%s"', query_fields.id, group.item_id),
                     where=string.format('%s = "%s"', query_fields.id, part.item_id),
                 }
                 }
             )
             )
             if #result > 0 then
             if #result > 0 then
                 sets[#sets+1] = {
                 recipes[#recipes+1] = {
                     automatic = true,
                     automatic = true,
                     result_amount = 1,
                     result_amount = 1,
                     text = i18n.the_void,
                     text = i18n.the_void,
                     groups = {group},
                     parts = {part},
                 }
                 }
                 if query_data['id'][group.item_id] then
                 if query_data['id'][part.item_id] then
                     table.insert(query_data['id'][group.item_id], {#sets, 1})
                     table.insert(query_data['id'][part.item_id], {#recipes, 1})
                 else
                 else
                     query_data['id'][group.item_id] = {{#sets, 1}, }
                     query_data['id'][part.item_id] = {{#recipes, 1}, }
                 end
                 end
                 table.insert(results, result[1])
                 table.insert(results, result[1])
Line 3,937: Line 3,946:
     for _, row in ipairs(results) do
     for _, row in ipairs(results) do
         for key, thing_array in pairs(query_data) do
         for key, thing_array in pairs(query_data) do
             local set_groups = thing_array[row[query_fields[key]]]
             local recipe_parts = thing_array[row[query_fields[key]]]
             if set_groups then
             if recipe_parts then
                 for _, set_group in ipairs(set_groups) do
                 for _, recipe_part in ipairs(recipe_parts) do
                     local entry = sets[set_group[1]].groups[set_group[2]]
                     local entry = recipes[recipe_part[1]].parts[recipe_part[2]]
                     for entry_key, data_key in pairs(query_fields) do
                     for entry_key, data_key in pairs(query_fields) do
                         -- metadata_id may be nil, since we don't know them for unique items
                         -- metadata_id may be nil, since we don't know them for unique items
Line 3,958: Line 3,967:
         -- query data was pruned of existing keys earlier, so only broken keys remain
         -- query data was pruned of existing keys earlier, so only broken keys remain
         for key, array in pairs(query_data) do
         for key, array in pairs(query_data) do
             for thing, set_groups in pairs(array) do
             for thing, recipe_parts in pairs(array) do
                 for _, set_group in ipairs(set_groups) do
                 for _, recipe_part in ipairs(recipe_parts) do
                     tpl_args._flags.invalid_recipe_parts = true
                     tpl_args._flags.invalid_recipe_parts = true
                     tpl_args._errors[#tpl_args._errors+1] = m_util.string.format(i18n.errors.invalid_recipe_parts, string.format('recipe%s_part%s_item_%s', set_group[1], set_group[2], key), thing)
                     tpl_args._errors[#tpl_args._errors+1] = m_util.string.format(i18n.errors.invalid_recipe_parts, string.format('recipe%s_part%s_item_%s', recipe_part[1], recipe_part[2], key), thing)
                 end
                 end
             end
             end
Line 3,970: Line 3,979:
     -- Check for duplicates
     -- Check for duplicates
     --
     --
     local delete_sets = {}
     local delete_recipes = {}
     for i=automatic_index, #sets do
     for i=automatic_index, #recipes do
         for j=1, automatic_index-1 do
         for j=1, automatic_index-1 do
             if #sets[i].groups == #sets[j].groups then
             if #recipes[i].parts == #recipes[j].parts then
                 local match = true
                 local match = true
                 for row_id, row in ipairs(sets[i].groups) do
                 for row_id, row in ipairs(recipes[i].parts) do
                     -- Only the fields from the database query are matched since we can be sure they're correct. Other fields may be subject to user error.
                     -- Only the fields from the database query are matched since we can be sure they're correct. Other fields may be subject to user error.
                     for _, key in ipairs({'item_id', 'item_name', 'item_page'})  do
                     for _, key in ipairs({'item_id', 'item_name', 'item_page'})  do
                         match = match and (row[key] == sets[j].groups[row_id][key])
                         match = match and (row[key] == recipes[j].parts[row_id][key])
                     end
                     end
                 end
                 end
Line 3,984: Line 3,993:
                     tpl_args._flags.duplicate_recipes = true
                     tpl_args._flags.duplicate_recipes = true
                     tpl_args._errors[#tpl_args._errors+1] = string.format(i18n.errors.duplicate_recipes, j)
                     tpl_args._errors[#tpl_args._errors+1] = string.format(i18n.errors.duplicate_recipes, j)
                     delete_sets[#delete_sets+1] = j  
                     delete_recipes[#delete_recipes+1] = j  
                 end
                 end
             end
             end
Line 3,990: Line 3,999:
     end
     end
      
      
     for offset, index in ipairs(delete_sets) do
     for offset, index in ipairs(delete_recipes) do
         table.remove(sets, index-(offset-1))
         table.remove(recipes, index-(offset-1))
     end
     end
     --
     --
     -- Set data
     -- Set data
     --  
     --  
     tpl_args.recipes = sets
     tpl_args.recipes = recipes
      
      
     -- set recipes data
     -- Set recipes data
     for i, set in ipairs(sets) do
     for i, recipe in ipairs(recipes) do
         table.insert(tpl_args._store_data, {
         table.insert(tpl_args._store_data, {
             _table = 'acquisition_recipes',
             _table = 'acquisition_recipes',
             recipe_id = i,
             recipe_id = i,
             result_amount = set.result_amount,
             result_amount = recipe.result_amount,
             description = set.text,
             description = recipe.text,
             automatic = set.automatic,
             automatic = recipe.automatic,
         })
         })
         for j, group in ipairs(set.groups) do
         for j, part in ipairs(recipe.parts) do
             table.insert(tpl_args._store_data, {
             table.insert(tpl_args._store_data, {
                 _table = 'acquisition_recipe_parts',
                 _table = 'acquisition_recipe_parts',
                 part_id = j,
                 part_id = j,
                 recipe_id = i,
                 recipe_id = i,
                 item_name = group.item_name,
                 item_name = part.item_name,
                 item_id = group.item_id,
                 item_id = part.item_id,
                 item_page = group.item_page,
                 item_page = part.item_page,
                 amount = group.amount,
                 amount = part.amount,
                 notes = group.notes,
                 notes = part.notes,
             })
             })
         end
         end
Line 4,026: Line 4,036:
--
--


function p.debug_validate_auto_upgraded_from(frame)
function p.debug_validate_auto_upgraded_from()
     local q = {}
     local q = {}
     local chk = {}
     local chk = {}
     for _, data in ipairs(c.automatic_recipes) do
     for _, data in ipairs(c.automatic_recipes) do
         for _, group in ipairs(data.groups) do
         for _, part in ipairs(data.parts) do
             q[#q+1] = group.item_id
             q[#q+1] = part.item_id
             chk[group.item_id] = {
             chk[part.item_id] = {
                 amount=group.amount,
                 amount=part.amount,
                 text=data.text(),
                 text=data.text(),
             }
             }
Line 4,055: Line 4,065:
     end
     end
      
      
     tbl = mw.html.create('table')
     local tbl = mw.html.create('table')
     tbl:attr('class', 'wikitable sortable')
     tbl:attr('class', 'wikitable sortable')
     for _, row in ipairs(results) do
     for _, row in ipairs(results) do

Revision as of 21:07, 25 August 2024

Module documentation[view] [edit] [history] [purge]


Lua logo

This module depends on the following other modules:

This submodule of Module:Item contains configuration and functions for item recipes.


-------------------------------------------------------------------------------
-- 
-- Recipes for Module:Item2
-- 
-------------------------------------------------------------------------------

local m_util = require('Module:Util')
local m_cargo = require('Module:Cargo')

local m_game = mw.loadData('Module:Game')

-- Lazy loading
local f_modifier_link -- require('Module:Modifier link').modifier_link

-- Should we use the sandbox version of our submodules?
local use_sandbox = m_util.misc.maybe_sandbox('Item2')

-- The cfg table contains all localisable strings and configuration, to make it
-- easier to port this module to another wiki.
local cfg = use_sandbox and mw.loadData('Module:Item2/config/sandbox') or mw.loadData('Module:Item2/config')

local i18n = cfg.i18n.recipes

-- ----------------------------------------------------------------------------
-- Helper functions 
-- ----------------------------------------------------------------------------

local h = {}

-- Lazy loading for Module:Modifier link
function h.modifier_link(args)
    if not f_modifier_link then
        f_modifier_link = require('Module:Modifier link').main
    end
    return f_modifier_link(args)
end

h.conditions = {}
h.conditions.factory = {}

function h.conditions.factory.arg(args)
    -- Required:
    --  arg: The argument to check against
    --  One must be specified
    --   value: check whether the argument equals this value
    --   values: check whether the argument is in this list of values
    --   values_assoc: check whether the argument is in this associative table
    --
    -- Optional:
    --  negate: negates the check against the value, i.e. whether the value is not equal or not in the list/table.
    args = args or {}
    
    -- Inner type of function depending on whether to check a single value, a list of values or an associative list of values
    local inner
    if args.value ~= nil then
        inner = function (tpl)
            return tpl == args.value
        end
    elseif args.values ~= nil then
        inner = function (tpl)
            for _, value in ipairs(args.values) do
                if tpl == value then
                    return true
                end
            end
            return false
        end
    elseif args.values_assoc ~= nil then
        inner = function(tpl) 
            return args.values_assoc[tpl] ~= nil
        end
    else
        error(string.format('Missing inner comparision function. Args: %s', mw.dumpObject(args)))
    end
    
    -- Outer type of function depending on whether to check a single value or against a table
    return function (tpl_args)
        local tpl_value = tpl_args[args.arg]
        local rtr
        if type(tpl_value) == 'table' then
            rtr = false
            for key, value in pairs(tpl_value) do
                if type(key) == 'number' then
                    rtr = rtr or inner(value)
                else
                    rtr = rtr or inner(key)
                end
            end
        else
            rtr = inner(tpl_value)
        end
        if args.negate then
            rtr = not rtr
        end
        return rtr
     end
end

function h.conditions.factory.not_arg(args)
    args = args or {}
    args.negate = true
    return h.conditions.factory.arg(args)
end

function h.conditions.factory.flag_is_set(args)
    return function (tpl_args)
        return tpl_args._flags[args.flag] == true
    end
end

function h.conditions.factory.acquisition_tag(args)
    return function (tpl_args)
        local negate = args.negate or false
        for _, tag in ipairs(tpl_args.acquisition_tags or {}) do
            if tag == args.tag then
                return not negate
            end
        end
        return negate
    end
end

function h.conditions.factory.drop_monsters(args)
    return function (tpl_args)
        for _, monster in ipairs(tpl_args.drop_monsters or {}) do
            if string.find(monster, args.monster, 1, true) then
                return true
            end
        end
        return false
    end
end

function h.conditions.factory.drop_rarity(args)
    return function (tpl_args)
        for _, rarity in ipairs(tpl_args.drop_rarities_ids or {}) do
            if rarity == args.rarity then
                return true
            end
        end
        return false
    end
end

function h.conditions.factory.drop_level_not_greater_than(args)
    return function (tpl_args)
        if tpl_args.drop_level == nil then
            return true
        end
        return tpl_args.drop_level <= args.level
    end
end

function h.conditions.item_class_has_corrupted_implicits(tpl_args)
    local groups = {
        cfg.class_groups.weapons.keys,
        cfg.class_groups.armor.keys,
        cfg.class_groups.jewellery.keys,
        {['Quiver'] = true, ['Jewel'] = true, ['AbyssJewel'] = true},
    }
    for _, g in ipairs(groups) do
        if h.conditions.factory.arg{arg='class_id', values_assoc=g}(tpl_args) then
            return true
        end
    end
    return false
end

function h.conditions.item_class_has_influences(tpl_args)
    local groups = {
        cfg.class_groups.weapons.keys,
        cfg.class_groups.armor.keys,
        cfg.class_groups.jewellery.keys,
        {['Quiver'] = true},
    }
    for _, g in ipairs(groups) do
        if h.conditions.factory.arg{arg='class_id', values_assoc=g}(tpl_args) and h.conditions.factory.not_arg{arg='class_id', value='FishingRod'}(tpl_args) then
            return true
        end
    end
    return false
end

function h.conditions.item_class_has_synthesised_implicits(tpl_args)
    local groups = {
        cfg.class_groups.weapons.keys,
        cfg.class_groups.armor.keys,
        cfg.class_groups.jewellery.keys,
        {['Quiver'] = true, ['Jewel'] = true, ['AbyssJewel'] = true},
    }
    for _, g in ipairs(groups) do
        if h.conditions.factory.arg{arg='class_id', values_assoc=g}(tpl_args) and h.conditions.factory.not_arg{arg='class_id', value='FishingRod'}(tpl_args) then
            return true
        end
    end
    return false
end

function h.conditions.item_class_has_fractured_modifiers(tpl_args)
    local groups = {
        cfg.class_groups.weapons.keys,
        cfg.class_groups.armor.keys,
        cfg.class_groups.jewellery.keys,
        {['Quiver'] = true, ['Jewel'] = true, ['Map'] = true},
    }
    for _, g in ipairs(groups) do
        if h.conditions.factory.arg{arg='class_id', values_assoc=g}(tpl_args) and h.conditions.factory.not_arg{arg='class_id', value='FishingRod'}(tpl_args) then
            return true
        end
    end
    return false
end

-- ----------------------------------------------------------------------------
-- Additional configuration
-- ----------------------------------------------------------------------------

local c = {}

c.named_conditions = {
    is_normal = h.conditions.factory.arg{arg='rarity_id', value='normal'},
    is_unique = h.conditions.factory.arg{arg='rarity_id', value='unique'},
    is_not_drop_restricted = h.conditions.factory.arg{arg='is_drop_restricted', value=false},
    is_not_corrupted = h.conditions.factory.arg{arg='is_corrupted', value=false},
    is_not_replica = h.conditions.factory.arg{arg='is_replica', value=false},
    drop_level_ngt_divcard_default_max_ilvl = h.conditions.factory.drop_level_not_greater_than{level=cfg.divination_card_exchange_default_max_ilvl},
    item_class_has_corrupted_implicits = h.conditions.item_class_has_corrupted_implicits,
    item_class_has_influences = h.conditions.item_class_has_influences,
    item_class_has_synthesised_implicits = h.conditions.item_class_has_synthesised_implicits,
    item_class_has_fractured_modifiers = h.conditions.item_class_has_fractured_modifiers,
}
-- Order matters!
-- Put most specific outcome at the top and the least specific at the bottom.
c.automatic_recipes = {
--[[
    {
        conditions = {
            function (tpl_args) end,
        },
        text = '',
        parts = {
            {
                name = '',
                item_id = '',
                amount = 0,
                notes = '',
            },
        },
    },
]]
    --
    -- Automatic recipes for specific maps - reduces maintenance when a new map series is introduced
    --
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='name', values={i18n['Forge of the Phoenix Map'], i18n['Lair of the Hydra Map'], i18n['Maze of the Minotaur Map'], i18n['Pit of the Chimera Map']}},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.shaper_guardian_map))
        end,
        parts = {
            {
                -- Guardian's Challenge
                item_id = 'Metadata/Items/DivinationCards/DivinationCardGuardiansChallenge',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
            h.conditions.factory.drop_level_not_greater_than{level=83},
        },
        text = function ()
            return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.item_level_x, 83, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])))
        end,
        parts = {
            {
                -- Lingering Remnants
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLingeringRemnants',
                amount = 16,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='name', value=i18n['Vaal Temple Map']},
        },
        text = function ()
            return string.format(i18n.fmt.corrupted_x, string.format(i18n.fmt.map_with_x_percent_delirium, string.format(i18n.fmt.tier_x, 16, m_util.html.poe_color('rare', i18n['Vaal Temple Map'])), 100))
        end,
        parts = {
            {
                -- The Price of Prescience
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThePriceOfPrescience',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            h.conditions.factory.arg{arg='base_item', value=i18n['Synthesised Map']},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n['Synthesised Map']))
        end,
        parts = {
            {
                -- Justified Ambition
                item_id = 'Metadata/Items/DivinationCards/DivinationCardJustifiedAmbition',
                amount = 5,
            },
        },
    },
    --
    -- Item base specific
    --
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Amulets/Amulet9'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.agate_amulet))
        end,
        parts = {
            {
                -- Lysah's Respite
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLysahsRespite',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring15'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.unset_ring))
        end,
        parts = {
            {
                -- The Penitent
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThePenitent',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring4'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gold_ring))
        end,
        parts = {
            {
                -- Glimmer of Hope
                item_id = 'Metadata/Items/DivinationCards/DivinationCardGlimmerOfHope',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Rings/Ring8'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.prismatic_ring))
        end,
        parts = {
            {
                -- Hope
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHope',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='metadata_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_variant, m_util.html.poe_color('rare', i18n.two_stone_ring))
        end,
        parts = {
            {
                -- Lantador's Lost Love
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLantadorsLostLove',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', values={'Metadata/Items/Rings/Ring12', 'Metadata/Items/Rings/Ring13', 'Metadata/Items/Rings/Ring14'}},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.two_stone_ring))
        end,
        parts = {
            {
                -- Heterochromia
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHeterochromia',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Weapons/OneHandWeapons/OneHandMaces/Sceptre11'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.crystal_sceptre))
        end,
        parts = {
            {
                -- Light and Truth
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLightAndTruth',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Flasks/FlaskUtility5'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.granite_flask))
        end,
        parts = {
            {
                -- Earth Drinker
                item_id = 'Metadata/Items/DivinationCards/DivinationCardEarthDrinker',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Armours/Helmets/HelmetStrDex10'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.nightmare_bascinet))
        end,
        parts = {
            {
                -- The Gladiator
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheGladiator',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt1'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.rustic_sash))
        end,
        parts = {
            {
                -- The Standoff
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheStandoff',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Belts/Belt3'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n['Leather Belt']))
        end,
        parts = {
            {
                -- The Forgotten Treasure
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheForgottenTreasure',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.timeless_jewel))
        end,
        parts = {
            {
                -- Peaceful Moments
                item_id = 'Metadata/Items/DivinationCards/DivinationCardPeacefulMoments',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='base_item_id', value='Metadata/Items/Jewels/JewelTimeless'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.timeless_jewel))
        end,
        parts = {
            {
                -- The Eternal War
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheEternalWar',
                amount = 4,
            },
        },
    },
    -- 
    -- Item name (item variants)
    -- 
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            h.conditions.factory.arg{arg='name', value=i18n.precursors_emblem},
        },
        text = function ()
            return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.precursors_emblem)))
        end,
        parts = {
            {
                -- Remembrance
                item_id = 'Metadata/Items/DivinationCards/DivinationCardRemembrance',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            h.conditions.factory.arg{arg='name', value=i18n.grand_spectrum},
        },
        text = function ()
            return string.format(i18n.fmt.random_variant, string.format(i18n.fmt.corrupted_x, m_util.html.poe_color('unique', i18n.grand_spectrum)))
        end,
        parts = {
            {
                -- Divine Justice
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDivineJustice',
                amount = 1,
            },
        },
    },
    -- 
    -- Item name like (themed items)
    -- 
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            function (tpl_args)
                -- Items that have "Atziri" in their name
                if string.find(tpl_args.name, i18n.atziri, 1, true) then
                    return true
                end
                -- Items that drop from Atziri
                for _, monster in ipairs(tpl_args.drop_monsters or {}) do
                    if string.find(monster, 'Metadata/Monsters/Atziri/Atziri', 1, true) then
                        return true
                    end
                end
                return false
            end,
            h.conditions.factory.not_arg{arg='class_id', value='UniqueFragment'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.atziri)))
        end,
        parts = {
            {
                -- The Admirer
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheAdmirer',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.doedre, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.doedre)))
        end,
        parts = {
            {
                -- Doedre's Madness
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDoedresMadness',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.shavronne, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.shavronne)))
        end,
        parts = {
            {
                -- The Aesthete
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheAesthete',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.rigwald, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.rigwald)))
        end,
        parts = {
            {
                -- The Wolf
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWolf',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.lioneye, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.lioneye)))
        end,
        parts = {
            {
                -- The Lion
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheLion',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.farrul, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.farrul)))
        end,
        parts = {
            {
                -- Council of Cats
                item_id = 'Metadata/Items/DivinationCards/DivinationCardCouncilOfCats',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            function (tpl_args)
                return string.find(tpl_args.name, i18n.farrul, 1, true) or string.find(tpl_args.name, i18n.fenumus, 1, true) or string.find(tpl_args.name, i18n.saqawal, 1, true) or string.find(tpl_args.name, i18n.craiceann, 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Bestiary'].name)))
        end,
        parts = {
            {
                -- Boon of the First Ones
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBoonOfTheFirstOnes',
                amount = 6,
            },
        },
    },
    -- 
    -- Monster-specific items
    --
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/BreachBossChaos'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.chayula)))
        end,
        parts = {
            {
                -- The Dreamer
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheDreamer',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/BreachBosses/'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Breach'].name)))
        end,
        parts = {
            {
                -- The Breach
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheBreach',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.drop_monsters{monster = 'Metadata/Monsters/MavenBoss/TheMaven'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.maven)))
        end,
        parts = {
            {
                -- The Leviathan
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheLeviathan',
                amount = 7,
            },
        },
    },
    -- 
    -- Themed/league items (acquisition tags)
    --
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            h.conditions.factory.acquisition_tag{tag = 'fishing'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.fishing)))
        end,
        parts = {
            {
                -- Baited Expectations
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBaitedExpectations',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='is_replica', value=true},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, i18n.replica)))
        end,
        parts = {
            {
                -- The Forward Gaze
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheForwardGaze',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
        end,
        parts = {
            {
                -- The Valkyrie
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheValkyrie',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Nemesis'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Nemesis'].name)))
        end,
        parts = {
            {
                -- The Undaunted
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheUndaunted',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Beyond'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Beyond'].name)))
        end,
        parts = {
            {
                -- The Calling
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCalling',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Delve'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Delve'].name)))
        end,
        parts = {
            {
                -- Alone in the Darkness
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAloneInTheDarkness',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Metamorph'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Metamorph'].name)))
        end,
        parts = {
            {
                -- Haunting Shadows
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHauntingShadows',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Abyss'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Abyss'].name))
        end,
        parts = {
            {
                -- Abyssal Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationAbyssStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            -- Must have Synthesis tag, but not league-specific tag
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Synthesis'].name},
            h.conditions.factory.acquisition_tag{tag = 'league-specific', negate = true},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', string.format(i18n.fmt.x_item, m_game.constants.leagues['Synthesis'].name)))
        end,
        parts = {
            {
                -- Chasing Risk
                item_id = 'Metadata/Items/DivinationCards/DivinationCardChasingRisk',
                amount = 4,
            },
        },
    },
    --
    -- Subset of item class
    --
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
            function(tpl_args)
                -- Get Primordial modifier from stats
                if tpl_args._stats.primordial_jewel_count then
                    return true
                end
                return false
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
        end,
        parts = {
            {
                -- The Primordial
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThePrimordial',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
            function(tpl_args)
                -- Get Primordial modifier from stats
                if tpl_args._stats.primordial_jewel_count then
                    return true
                end
                return false
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random_one_or_two_implicit_corrupted, string.format('%s %s', m_util.html.poe_color('mod', i18n.primordial), m_util.html.poe_color('unique', i18n.jewel)))
        end,
        parts = {
            {
                -- A Stone Perfected
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAStonePerfected',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.flag_is_set{flag = 'is_talisman'},
            h.conditions.factory.arg{arg='talisman_tier', value=1},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.tier_1_talisman))
        end,
        parts = {
            {
                -- Call to the First Ones
                item_id = 'Metadata/Items/DivinationCards/DivinationCardCallToTheFirstOnes',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_not_replica = true,
            h.conditions.factory.flag_is_set{flag = 'is_talisman'},
        },
        text = function ()
            return string.format(i18n.fmt.random, i18n.talisman)
        end,
        parts = {
            {
                -- Primal Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationTalismansStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='MapFragment'},
            h.conditions.factory.arg{arg='tags', value='atziri1'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sacrifice_fragment))
        end,
        parts = {
            {
                -- Her Mask
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHerMask',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='MapFragment'},
            h.conditions.factory.arg{arg='tags', value='atziri2'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.mortal_fragment))
        end,
        parts = {
            {
                -- Sambodhi's Vow
                item_id = 'Metadata/Items/DivinationCards/DivinationCardSambodhisVow',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='MapFragment'},
            function (tpl_args)
                return tpl_args.metadata_id and string.find(tpl_args.metadata_id, 'UberElderFragment', 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.uber_elder_fragment))
        end,
        parts = {
            {
                -- The Eldritch Decay
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheEldritchDecay',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='MapFragment'},
            function (tpl_args)
                if tpl_args.metadata_id then
                    local patterns = {
                        'CurrencyShaperFragment',
                        'CurrencyElderFragment',
                        'CurrencySirusFragment',
                        'CurrencyVaalFragment1_',
                        'CurrencyVaalFragment2_',
                        'CurrencyOfferingToTheGoddess$',
                    }
                    for _, p in ipairs(patterns) do
                        if string.find(tpl_args.metadata_id, p) then
                            return true
                        end
                    end
                end
                return false
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.fragment))
        end,
        parts = {
            {
                -- Fragmented Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationFragmentsStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Breachstone'},
            h.conditions.factory.arg{arg='tags', value='breachstone'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.breachstone))
        end,
        parts = {
            {
                -- The Obscured
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheObscured',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_essence'},
            h.conditions.factory.arg{arg='essence_level', value=7},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.deafening_essence), 3)
        end,
        parts = {
            {
                -- The Cacophony
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCacophony',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_essence'},
            h.conditions.factory.arg{arg='essence_level', value=6},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.shrieking_essence), 9)
        end,
        parts = {
            {
                -- Harmony of Souls
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHarmonyOfSouls',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_essence'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
        end,
        parts = {
            {
                -- Three Voices
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThreeVoices',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_essence'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.essence), 3)
        end,
        parts = {
            {
                -- Infused Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationEssenceHighStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.acquisition_tag{tag = m_game.constants.leagues['Ultimatum'].name},
        },
        text = function ()
            return string.format(i18n.fmt.random, string.format(i18n.fmt.x_item, m_game.constants.leagues['Ultimatum'].name))
        end,
        parts = {
            {
                -- Challenging Incubator (previously Morphing Incubator)
                item_id = 'Metadata/Items/Currency/CurrencyIncubationMetamorphStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.delirium_orb))
        end,
        parts = {
            {
                -- Disdain
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDisdain',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_delirium_orb'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.delirium_orb), 10)
        end,
        parts = {
            {
                -- Dementophobia
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDementophobia',
                amount = 11,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_blight_item'},
            function (tpl_args)
                return tpl_args.blight_item_tier >= 1
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.oil), 10)
        end,
        parts = {
            {
                -- The Tireless Extractor
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTirelessExtractor',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
            function (tpl_args)
                return tpl_args.metadata_id and string.find(tpl_args.metadata_id, 'Metadata/Items/Currency/CurrencyIncursionVial', 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.vial), 10)
        end,
        parts = {
            {
                -- The Rabbit's Foot
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheRabbitsFoot',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=5},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 5)))
        end,
        parts = {
            {
                -- Cartographer's Delight
                item_id = 'Metadata/Items/DivinationCards/DivinationCardCartographersDelight',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=6},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 6)))
        end,
        parts = {
            {
                -- Rain Tempter
                item_id = 'Metadata/Items/DivinationCards/DivinationCardRainTempter',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=12},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 12)))
        end,
        parts = {
            {
                -- The Arena Champion
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheArenaChampion',
                amount = 10,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=14},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 14)))
        end,
        parts = {
            {
                -- The Surveyor
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheSurveyor',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=15},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', string.format(i18n.fmt.tier_x_map, 15)))
        end,
        parts = {
            {
                -- Lost Worlds
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLostWorlds',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=15},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 15)))
        end,
        parts = {
            {
                -- The Trial
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTrial',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=15},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map_with_y_modifiers, 15, 8)))
        end,
        parts = {
            {
                -- The Easy Stroll
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheEasyStroll',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            function (tpl_args)
                return tpl_args.map_tier >= 14 and tpl_args.map_tier <= 16
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.the_price_of_protection, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_to_y_map, 14, 16))))
        end,
        parts = {
            {
                -- The Price of Protection
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThePriceOfProtection',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=16},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='MapMonsterPhysicalReflection3MapWorlds'}, string.format(i18n.fmt.tier_x_map, 16))))
        end,
        parts = {
            {
                -- Azure Rage
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAzureRage',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=16},
        },
        text = function ()
            return string.format(i18n.fmt.random_unidentified_corrupted, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 16)))
        end,
        parts = {
            {
                -- Left to Fate
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLeftToFate',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
            h.conditions.factory.arg{arg='map_tier', value=13},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, string.format(i18n.fmt.triskaidekaphobia, m_util.html.poe_color('rare', string.format(i18n.fmt.tier_x_map, 13))))
        end,
        parts = {
            {
                -- Triskaidekaphobia
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTriskaidekaphobia',
                amount = 13,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.aura.tag},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.aura.tag)))
        end,
        parts = {
            {
                -- The Wilted Rose
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWiltedRose',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.golem.tag)))
        end,
        parts = {
            {
                -- The Rite of Elements
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheRiteOfElements',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.golem.tag},
            h.conditions.factory.flag_is_set{flag = 'is_derived'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_y_gem_z_quality, 21, m_game.constants.item.gem_tags.golem.tag, 23)))
        end,
        parts = {
            {
                -- Terrible Secret of Space
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTerribleSecretOfSpace',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.trap.tag},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.trap.tag, 23)))
        end,
        parts = {
            {
                -- Deathly Designs
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDeathlyDesigns',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.chaos.tag},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 21, m_game.constants.item.gem_tags.chaos.tag, 23)))
        end,
        parts = {
            {
                -- The Bitter Blossom
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheBitterBlossom',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.minion.tag},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.minion.tag, 20)))
        end,
        parts = {
            {
                -- The Summoner
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheSummoner',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.spell.tag},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 21, m_game.constants.item.gem_tags.spell.tag)))
        end,
        parts = {
            {
                --The Cataclysm
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCataclysm',
                amount = 13,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.vaal.tag},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, m_game.constants.item.gem_tags.vaal.tag, 20)))
        end,
        parts = {
            {
                -- Volatile Power
                item_id = 'Metadata/Items/DivinationCards/DivinationCardVolatilePower',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.flag_is_set{flag = 'is_derived'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem, 21)))
        end,
        parts = {
            {
                -- The Blessing of Moosh
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheBlessingOfMoosh',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.flag_is_set{flag = 'is_derived'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 23)))
        end,
        parts = {
            {
                -- The Hook
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheHook',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.flag_is_set{flag = 'is_derived'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 21, 20)))
        end,
        parts = {
            {
                -- Doryani's Epiphany
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDoryanisEpiphany',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Active Skill Gem'},
            h.conditions.factory.flag_is_set{flag = 'is_derived'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_trans_gem_y_quality, 19, 19))
        end,
        parts = {
            {
                -- Dying Anguish
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDyingAnguish',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem, m_game.constants.item.gem_tags.exceptional.tag)))
        end,
        parts = {
            {
                -- Gemcutter's Mercy
                item_id = 'Metadata/Items/DivinationCards/DivinationCardGemcuttersMercy',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
            h.conditions.factory.arg{arg='gem_tags', value=m_game.constants.item.gem_tags.exceptional.tag},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_quality, m_game.constants.item.gem_tags.exceptional.tag)))
        end,
        parts = {
            {
                -- Home
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHome',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem, 20, i18n.support)))
        end,
        parts = {
            {
                -- Gift of the Gemling Queen
                item_id = 'Metadata/Items/DivinationCards/DivinationCardGiftOfTheGemlingQueen',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.x_gem_y_quality, i18n.support, 23)))
        end,
        parts = {
            {
                -- Dialla's Subjugation
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDiallasSubjugation',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
            h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
            h.conditions.factory.arg{arg='max_level', value=5},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 20)))
        end,
        parts = {
            {
                -- The Cheater
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCheater',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            h.conditions.factory.arg{arg='class_id', value='Support Skill Gem'},
            h.conditions.factory.arg{arg='is_awakened_support_gem', value=true},
            h.conditions.factory.arg{arg='max_level', value=5},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_y_gem_z_quality, 6, i18n.awakened_support, 23)))
        end,
        parts = {
            {
                -- Desecrated Virtue
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDesecratedVirtue',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
            h.conditions.factory.arg{arg='tags', value='bestiary_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.bestiary_scarab))
        end,
        parts = {
            {
                -- Man With Bear
                item_id = 'Metadata/Items/DivinationCards/DivinationCardManWithBear',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
            h.conditions.factory.arg{arg='tags', value='maps_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.cartography_scarab))
        end,
        parts = {
            {
                -- The Deal
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheDeal',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
            h.conditions.factory.arg{arg='tags', value='divination_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.divination_scarab))
        end,
        parts = {
            {
                -- The Card Sharp
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCardSharp',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
            h.conditions.factory.arg{arg='tags', value='uber_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.horned_scarab))
        end,
        parts = {
            {
                -- Rebirth and Renewal
                item_id = 'Metadata/Items/DivinationCards/DivinationCardRebirthAndRenewal',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
            h.conditions.factory.arg{arg='tags', value='delve_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.sulphite_scarab))
        end,
        parts = {
            {
                -- Buried Treasure
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBuriedTreasure',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('normal', i18n.scarab), 4)
        end,
        parts = {
            {
                -- More is Never Enough
                item_id = 'Metadata/Items/DivinationCards/DivinationCardMoreIsNeverEnough',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
        end,
        parts = {
            {
                -- Cameria's Cut
                item_id = 'Metadata/Items/DivinationCards/DivinationCardCameriasCut',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_scarab'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.scarab))
        end,
        parts = {
            {
                -- Skittering Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationScarabsStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
            h.conditions.factory.arg{arg='tags', value='breachstone_splinter'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.breachstone_splinter), 5)
        end,
        parts = {
            {
                -- The Puzzle
                item_id = 'Metadata/Items/DivinationCards/DivinationCardThePuzzle',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
            h.conditions.factory.arg{arg='tags', value='quality_currency'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.quality_currency), 20)
        end,
        parts = {
            {
                -- The Master Artisan
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheMasterArtisan',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_fossil'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.fossil), 5)
        end,
        parts = {
            {
                -- The Tinkerer's Table
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTinkerersTable',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.flag_is_set{flag = 'is_fossil'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('currency', i18n.fossil))
        end,
        parts = {
            {
                -- Fossilised Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationFossilsStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='StackableCurrency'},
            function (tpl_args)
                return tpl_args.metadata_id and string.find(tpl_args.metadata_id, 'ScoutingReport', 1, true)
            end,
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, m_util.html.poe_color('currency', i18n.scouting_report), 20)
        end,
        parts = {
            {
                -- The Side Quest
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheSideQuest',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='UniqueFragment'},
            h.conditions.factory.acquisition_tag{tag = 'Harbinger'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.harbinger_fragment))
        end,
        parts = {
            {
                -- The Messenger
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheMessenger',
                amount = 4,
            },
        },
    },
    --
    -- Single item class
    --
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.body_armour))
        end,
        parts = {
            {
                -- The Body
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheBody',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Shield'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.shield))
        end,
        parts = {
            {
                -- The Mercenary
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheMercenary',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Shield'},
        },
        text = function ()
            return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('normal', i18n.shield))
        end,
        parts = {
            {
                -- Astral Protection
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAstralProtection',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Helmet'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('magic', i18n.helmet))
        end,
        parts = {
            {
                -- Further Invention
                item_id = 'Metadata/Items/DivinationCards/DivinationCardFurtherInvention',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Helmet'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_veiled, m_util.html.poe_color('rare', i18n.helmet))
        end,
        parts = {
            {
                -- The Journalist
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheJournalist',
                amount = 10,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Claw'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.claw))
        end,
        parts = {
            {
                -- The Wolverine
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWolverine',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Dagger', 'Rune Dagger'}},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.dagger))
        end,
        parts = {
            {
                -- Assassin's Favour
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAssassinsFavour',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Sceptre'},
        },
        text = function ()
            return string.format(i18n.fmt.random_shaper, m_util.html.poe_color('magic', string.format('%s %s', i18n.sceptre, h.modifier_link{id='LocalIncreasedAttackSpeed8'})))
        end,
        parts = {
            {
                -- The Lord of Celebration
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheLordOfCelebration',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Bow'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.bow))
        end,
        parts = {
            {
                -- Hunter's Resolve
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHuntersResolve',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewel))
        end,
        parts = {
            {
                -- The Garish Power
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheGarishPower',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.jewel))
        end,
        parts = {
            {
                -- The Eye of the Dragon
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheEyeOfTheDragon',
                amount = 10,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='PercentIncreasedLifeJewel'}, i18n.jewel)))
        end,
        parts = {
            {
                -- Shard of Fate
                item_id = 'Metadata/Items/DivinationCards/DivinationCardShardOfFate',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewel, h.modifier_link{id='CriticalStrikeMultiplierJewel'})))
        end,
        parts = {
            {
                -- The Mountain
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheMountain',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Jewel'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted_implicit, m_util.html.poe_color('rare', i18n.jewel), h.modifier_link{id='V2CorruptedBloodImmunityCorrupted'})
        end,
        parts = {
            {
                -- Lachrymal Necrosis
                item_id = 'Metadata/Items/DivinationCards/DivinationCardLachrymalNecrosis',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Amulet'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='IncreasedEnergyShieldPercent7'}, i18n.amulet)))
        end,
        parts = {
            {
                -- The Sigil
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheSigil',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Amulet'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.amulet))
        end,
        parts = {
            {
                -- The Warden
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWarden',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Ring'},
            h.conditions.factory.drop_level_not_greater_than{level=83},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('magic', string.format('%s %s', i18n.ring, h.modifier_link{id='ChaosResist6'})))
        end,
        parts = {
            {
                -- The Lord in Black
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheLordInBlack',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Ring'},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.ring))
        end,
        parts = {
            {
                -- The Opulent
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheOpulecent',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Ring'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.ring))
        end,
        parts = {
            {
                -- Hubris
                item_id = 'Metadata/Items/DivinationCards/DivinationCardHubris',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Ring'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.ring))
        end,
        parts = {
            {
                -- Blind Venture
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBlindVenture',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Belt'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.belt))
        end,
        parts = {
            {
                -- The Wretched
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWretched',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Belt'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.belt))
        end,
        parts = {
            {
                -- The Dungeon Master
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheDungeonMaster',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.map))
        end,
        parts = {
            {
                -- The Encroaching Darkness
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheEncroachingDarkness',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.map))
        end,
        parts = {
            {
                -- Otherworldly Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationUniqueMapsStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Wand'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.wand))
        end,
        parts = {
            {
                -- The Traitor
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTraitor',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.staff))
        end,
        parts = {
            {
                -- The Tower
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTower',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Staff', 'Warstaff'}},
            h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
            h.conditions.factory.drop_level_not_greater_than{level=66},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link_item_level_y, 5, 66, m_util.html.poe_color('normal', i18n.staff))
        end,
        parts = {
            {
                -- The Flora's Gift
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheFlorasGift',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Staff'},
            h.conditions.factory.not_arg{arg='tags', value='small_staff'}, -- Small staves excluded because they don't have enough sockets
            h.conditions.factory.drop_level_not_greater_than{level=55},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link_item_level_y, 6, 55, m_util.html.poe_color('normal', i18n.staff))
        end,
        parts = {
            {
                -- The Dark Mage
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheDarkMage',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link_item_level_y, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
        end,
        parts = {
            {
                -- The Dapper Prodigy
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheDapperProdigy',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link_item_level_y_random_influenced, 6, 100, m_util.html.poe_color('normal', i18n.body_armour))
        end,
        parts = {
            {
                -- Draped in Dreams
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDrapedInDreams',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
        end,
        parts = {
            {
                -- The Chains that Bind
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheChainsThatBind',
                amount = 11,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'}, 
        },
        text = function ()
            return string.format(i18n.fmt.random_x_link, 6, m_util.html.poe_color('normal', i18n.body_armour))
        end,
        parts = {
            {
                -- Geomancer's Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationArmour6LinkedStackable',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('rare', i18n.body_armour))
        end,
        parts = {
            {
                -- Destined to Crumble
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDestinedToCrumble',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Body Armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.body_armour))
        end,
        parts = {
            {
                -- Duality
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDuality',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('normal', i18n.map))
        end,
        parts = {
            {
                -- Boundless Realms
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBoundlessRealms',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Map'},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('rare', i18n.map))
        end,
        parts = {
            {
                -- The Explorer
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheExplorer',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Gloves'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.gloves))
        end,
        parts = {
            {
                -- Mitts
                item_id = 'Metadata/Items/DivinationCards/DivinationCardMitts',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', value='Boots'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_implicit_corrupted, string.format(i18n.fmt.item_level_x, 100, m_util.html.poe_color('unique', i18n.boots)))
        end,
        parts = {
            {
                -- The Shepherd's Sandals
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheShepherdsSandals',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
        end,
        parts = {
            {
                -- The Gambler
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheGambler',
                item_page = 'The Gambler', -- These need to be specified so that The Gambler can be a recipe for itself while saving itself.
                item_name = 'The Gambler',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='DivinationCard'},
            h.conditions.factory.not_arg{arg='tags', value='boss_drop_card'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('divination', i18n.divination_card))
        end,
        parts = {
            {
                -- Stacked Deck
                item_id = 'Metadata/Items/DivinationCards/DivinationCardDeck',
                amount = 1,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='HeistBlueprint'},
        },
        text = function ()
            return string.format(i18n.fmt.random, string.format(i18n.fmt.fully_revealed_x_area_level_y, m_util.html.poe_color('normal', i18n.blueprint), 83))
        end,
        parts = {
            {
                -- Something Dark
                item_id = 'Metadata/Items/DivinationCards/DivinationCardSomethingDark',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='IncubatorStackable'},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_amount, string.format(i18n.fmt.item_level_x, 84, m_util.html.poe_color('currency', i18n.incubator)), 10)
        end,
        parts = {
            {
                -- Parasitic Passengers
                item_id = 'Metadata/Items/DivinationCards/DivinationCardParasiticPassengers',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_replica = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', value='Relic'},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 83, m_util.html.poe_color('unique', i18n.relic))
        end,
        parts = {
            {
                -- Temperance
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTemperance',
                amount = 4,
            },
        },
    },
    --
    -- Multiple item classes
    --
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'One Hand Axe', 'Two Hand Axe'}},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.axe))
        end,
        parts = {
            {
                -- The Battle Born
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheBattleBorn',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
            h.conditions.factory.arg{arg='max_level', value=20},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.level_x_gem, 20)))
        end,
        parts = {
            {
                -- The Fox
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheFox',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', string.format(i18n.fmt.gem_x_quality, 20)))
        end,
        parts = {
            {
                -- Gemcutter's Promise
                item_id = 'Metadata/Items/DivinationCards/DivinationCardGemcuttersPromise',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.gems.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('gem', i18n.fmt.gem_quality))
        end,
        parts = {
            {
                -- Gemcutter's Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationGemLowStackable',
                amount = 1,
            },
        },
    },
    --[[{
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_quality, m_util.html.poe_color('unique', i18n.armour), 30)
        end,
        parts = {
            {
                -- Sambodhi's Wisdom
                item_id = 'Metadata/Items/DivinationCards/DivinationCardSambodhisWisdom',
                amount = 3,
            },
        },
    },--]]
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
            h.conditions.factory.arg{arg='tags', value='int_armour'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedEnergyShieldPercentAndStunRecovery6'}, i18n.armour)))
        end,
        parts = {
            {
                -- The Inoculated
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheInoculated',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.armor.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.life, i18n.armour)))
        end,
        parts = {
            {
                -- The Carrion Crow
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCarrionCrow',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_shaper_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
        end,
        parts = {
            {
                -- Perfection
                item_id = 'Metadata/Items/DivinationCards/DivinationCardPerfection',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.jewellery))
        end,
        parts = {
            {
                -- The Cache
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheCache',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
            h.conditions.factory.drop_level_not_greater_than{level=86},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_item_level_x, 86, m_util.html.poe_color('rare', i18n.jewellery))
        end,
        parts = {
            {
                -- The Awakened
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheAwakened',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
            h.conditions.factory.drop_level_not_greater_than{level=79},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 79, m_util.html.poe_color('rare', i18n.jewellery))
        end,
        parts = {
            {
                -- The Lover
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheLover',
                amount = 2,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
            h.conditions.factory.drop_level_not_greater_than{level=85},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 85, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='ReduceGlobalFlatManaCostStrIntMasterVendor'}, i18n.jewellery)))
        end,
        parts = {
            {
                -- Blessing of God
                item_id = 'Metadata/Items/DivinationCards/DivinationCardBlessingOfGod',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Ring', 'Amulet'}},
            h.conditions.factory.drop_level_not_greater_than{level=76},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 76, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='AddedLightningDamage9'}, i18n.jewellery)))
        end,
        parts = {
            {
                -- Struck by Lightning
                item_id = 'Metadata/Items/DivinationCards/DivinationCardStruckByLightning',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_shaper_hunter_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', i18n.jewellery, h.modifier_link{id='GrantsCatAspectCrafted'})))
        end,
        parts = {
            {
                -- A Familiar Call
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAFamiliarCall',
                amount = 3,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.jewellery.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('rare', i18n.jewellery))
        end,
        parts = {
            {
                -- Imperfect Memories
                item_id = 'Metadata/Items/DivinationCards/DivinationCardImperfectMemories',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Two Hand Sword', 'Two Hand Axe', 'Two Hand Mace', 'Staff', 'Bow', 'Warstaff'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.two_hand_weapon)))
        end,
        parts = {
            {
                -- Merciless Armament
                item_id = 'Metadata/Items/DivinationCards/DivinationCardMercilessArmament',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('rare', i18n.one_hand_weapon))
        end,
        parts = {
            {
                -- Prometheus' Armoury
                item_id = 'Metadata/Items/DivinationCards/DivinationCardPrometheusArmoury',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'One Hand Axe', 'One Hand Mace', 'Sceptre', 'Dagger', 'Claw', 'Wand', 'Rune Dagger'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.one_hand_weapon)))
        end,
        parts = {
            {
                -- The Jester
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheJester',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values={'Sceptre', 'Wand', 'Rune Dagger'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='SpellDamageOnWeapon8_'}, i18n.one_hand_weapon)))
        end,
        parts = {
            {
                -- The Road to Power
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheRoadToPower',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', values={'Thrusting One Hand Sword', 'One Hand Sword', 'Two Hand Sword'}},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.sword))
        end,
        parts = {
            {
                -- The Gentleman
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheGentleman',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_item_level_x, 100, m_util.html.poe_color('magic',string.format('%s %s', h.modifier_link{id='LocalIncreasedPhysicalDamagePercent8'}, i18n.weapon)))
        end,
        parts = {
            {
                -- The Tyrant
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheTyrant',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', i18n.weapon, h.modifier_link{id='StrIntMasterItemGenerationCanHaveMultipleCraftedMods'})))
        end,
        parts = {
            {
                -- The Web
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheWeb',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.weapons.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random_corrupted, m_util.html.poe_color('unique', i18n.weapon))
        end,
        parts = {
            {
                -- Atziri's Arsenal
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAtzirisArsenal',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            h.conditions.factory.arg{arg='class_id', values_assoc=cfg.class_groups.flasks.keys},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('magic', string.format('%s %s', h.modifier_link{id='FlaskChanceRechargeOnCrit5'}, i18n.flask)))
        end,
        parts = {
            {
                -- The Surgeon
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheSurgeon',
                amount = 4,
            },
        },
    },
    --[[{
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            h.conditions.factory.arg{arg='tags', value='two_hand_weapon'},
            h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
            h.conditions.factory.drop_level_not_greater_than{level=86},
        },
        text = function ()
            return string.format(i18n.fmt.random_x_quality, string.format(i18n.fmt.item_level_x, 86, m_util.html.poe_color('rare', i18n.experimented_two_hand_weapon)), 30)
        end,
        parts = {
            {
                -- Soul Quenched
                item_id = 'Metadata/Items/DivinationCards/DivinationCardSoulQuenched',
                amount = 5,
            },
        },
    },--]]
    {
        conditions = {
            is_normal = true,
            is_not_corrupted = true,
            item_class_has_influences = true,
            h.conditions.factory.acquisition_tag{tag = 'experimented base type'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_item_level_x, 100, m_util.html.poe_color('normal', i18n.experimented_base_type))
        end,
        parts = {
            {
                -- Auspicious Ambitions
                item_id = 'Metadata/Items/DivinationCards/DivinationCardAuspiciousAmbitions',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            item_class_has_corrupted_implicits = true,
            item_class_has_influences = true,
            h.conditions.factory.acquisition_tag{tag = 'league-specific'},
        },
        text = function ()
            return string.format(i18n.fmt.random_two_implicit_corrupted_two_influenced_item_level_x, 97, m_util.html.poe_color('unique', i18n.league_specific_item))
        end,
        parts = {
            {
                -- Fateful Meeting
                item_id = 'Metadata/Items/DivinationCards/DivinationCardFatefulMeeting',
                amount = 9,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.acquisition_tag{tag = 'league-specific'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
        end,
        parts = {
            {
                -- Time-Lost Relic
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTimeLostRelic',
                amount = 10,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            h.conditions.factory.acquisition_tag{tag = 'league-specific'},
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.league_specific_item))
        end,
        parts = {
            {
                -- Time-Lost Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationUniqueLeagueStackable',
                amount = 1,
            },
        },
    },
    --
    -- Generic items
    --
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            item_class_has_fractured_modifiers = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_fractured_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
        end,
        parts = {
            {
                -- A Dusty Memory
                item_id = 'Metadata/Items/DivinationCards/DivinationCardADustyMemory',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            item_class_has_influences = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_elder_item_level_x, 100, m_util.html.poe_color('rare', i18n.item))
        end,
        parts = {
            {
                -- The Hale Heart
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheHaleHeart',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            item_class_has_influences = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_influenced, m_util.html.poe_color('unique', i18n.item))
        end,
        parts = {
            {
                -- Prejudice
                item_id = 'Metadata/Items/DivinationCards/DivinationCardPrejudice',
                amount = 7,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            item_class_has_influences = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_two_influenced_x, m_util.html.poe_color('unique', i18n.item))
        end,
        parts = {
            {
                -- Costly Curio
                item_id = 'Metadata/Items/DivinationCards/DivinationCardCostlyCurio',
                amount = 6,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            drop_level_ngt_divcard_default_max_ilvl = true,
            item_class_has_influences = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_influenced_x_elevated, m_util.html.poe_color('magic', i18n.item))
        end,
        parts = {
            {
                -- The Aspirant
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheAspirant',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_normal = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
            item_class_has_synthesised_implicits = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_three_synthesised_item_level_x, 100, m_util.html.poe_color('normal', i18n.item))
        end,
        parts = {
            {
                -- Magnum Opus
                item_id = 'Metadata/Items/DivinationCards/DivinationCardMagnumOpus',
                amount = 5,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            item_class_has_corrupted_implicits = true,
        },
        text = function ()
            return string.format(i18n.fmt.random_two_implicit_corrupted, m_util.html.poe_color('unique', i18n.item))
        end,
        parts = {
            {
                -- Arrogance of the Vaal
                item_id = 'Metadata/Items/DivinationCards/DivinationCardArroganceOfTheVaal',
                amount = 8,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
        end,
        parts = {
            {
                -- Jack in the Box
                item_id = 'Metadata/Items/DivinationCards/DivinationCardJackInTheBox',
                amount = 4,
            },
        },
    },
    {
        conditions = {
            is_unique = true,
            is_not_drop_restricted = true,
            is_not_corrupted = true,
        },
        text = function ()
            return string.format(i18n.fmt.random, m_util.html.poe_color('unique', i18n.item))
        end,
        parts = {
            {
                -- Singular Incubator
                item_id = 'Metadata/Items/Currency/CurrencyIncubationUniquesStackable',
                amount = 1,
            },
        },
    },
}

-- ----------------------------------------------------------------------------
-- Exported functions
-- ----------------------------------------------------------------------------

local p = {}

function p.process_recipes(tpl_args)
    local query_data = {
        id = {},
        name = {},
        page = {},
    }
    local recipes = {}
    
    -- ------------------------------------------------------------------------
    -- Manual data
    -- ------------------------------------------------------------------------
    local recipe_num = #recipes + 1
    local recipe
    repeat
        local prefix = string.format('recipe%s_', recipe_num)
        local part_num = 1
        local part
        recipe = {
            parts = {},
            result_amount = tonumber(tpl_args[prefix .. 'result_amount']) or 1,
            text = m_util.cast.text(tpl_args[prefix .. 'description']),
            automatic = false,
        }
        repeat 
            local part_prefix = string.format('%spart%s_', prefix, part_num)
            part = {
                item_name = tpl_args[part_prefix .. 'item_name'],
                item_id = tpl_args[part_prefix .. 'item_id'], 
                item_page = tpl_args[part_prefix .. 'item_page'], 
                amount = tonumber(tpl_args[part_prefix .. 'amount']),
                notes = m_util.cast.text(tpl_args[part_prefix .. 'notes']),
            }
            
            if part.item_name ~= nil or part.item_id ~= nil or part.item_page ~= nil then
                if part.amount == nil then
                    error(string.format(i18n.errors.missing_amount, part_prefix .. 'amount'))
                else
                    for key, array in pairs(query_data) do
                        local value = part['item_' .. key]
                        if value then
                            if array[value] then
                                table.insert(array[value], {recipe_num, part_num})
                            else
                                array[value] = {{recipe_num, part_num}, }
                            end
                        end
                    end
                    recipe.parts[#recipe.parts+1] = part
                end
            end
            
            part_num = part_num + 1
        until part.item_name == nil and part.item_id == nil and part.item_page == nil
        
        -- recipe was empty, can terminate safely
        if #recipe.parts == 0 then
            recipe = nil
        else
            recipe_num = recipe_num + 1
            recipes[#recipes+1] = recipe
        end
    until recipe == nil

    -- ------------------------------------------------------------------------
    -- Automatic
    -- ------------------------------------------------------------------------
    
    --
    --  maps
    --
    local automatic_index = #recipes + 1
    -- TODO: 3.9.0 Unsure how this works yet, so disabled for now
    --[[if tpl_args.atlas_connections and tpl_args.rarity_id == 'normal' then
        local results = m_cargo.query(
            {'items', 'maps'},
            {'items._pageName',  'items.name'},
            {
                join='items._pageID=maps._pageID',
                where=string.format('items.class_id = "Map" AND items.rarity_id = "normal" AND maps.tier < %s AND items._pageName IN ("%s")', tpl_args.map_tier, table.concat(tpl_args.atlas_connections, '", "')),
            }
        )
        for _, row in ipairs(results) do
            recipes[#recipes+1] = {
                text = i18n.misc.upgraded_from_map,
                result_amount = 1,
                parts = {
                    {
                        item_name = row['items.name'],
                        item_page = row['items._pageName'],
                        amount = 3,
                        notes = nil,
                    },
                },
                automatic = true,
            }
        end
    end]]
    
    --
    -- oils
    --
    if tpl_args._flags.is_blight_item and tpl_args.blight_item_tier > 1 then
        local results = m_cargo.query(
            {'items', 'blight_items'},
            {'items._pageName',  'items.name'},
            {
                join='items._pageID=blight_items._pageID',
                where=string.format('blight_items.tier = %s', tpl_args.blight_item_tier - 1),
            }
        )
        for _, row in ipairs(results) do
            recipes[#recipes+1] = {
                text = nil,
                result_amount = 1,
                parts = {
                    {
                        item_name = row['items.name'],
                        item_page = row['items._pageName'],
                        amount = 3,
                        notes = nil,
                    },
                },
                automatic = true,
            }
        end
    end
    
    
    --
    -- essences
    --
    
    -- exclude remnant of corruption via type
    if tpl_args._flags.is_essence and tpl_args.essence_type > 0 then 
        local results = m_cargo.query(
            {'items', 'essences'},
            {
                'items._pageName',  
                'items.name', 
                'items.metadata_id',
                'essences.category',
                'essences.type',
            },
            {
                join='items._pageID=essences._pageID',
                where=string.format([[
                        (essences.category="%s" AND essences.level = %s)
                        OR (essences.type = %s AND essences.level = %s)
                        OR items.metadata_id = 'Metadata/Items/Currency/CurrencyCorruptMonolith'
                        OR (%s = 6 AND essences.type = 5 AND essences.level >= 5) 
                    ]], 
                    tpl_args.essence_category, tpl_args.essence_level - 1, 
                    tpl_args.essence_type - 1, tpl_args.essence_level,
                    -- special case for corruption only essences
                    tpl_args.essence_type
                ),
                orderBy='essences.level ASC, essences.type ASC',
            }
        )
        
        local remnant = results[1]
        if remnant['items.metadata_id'] ~= 'Metadata/Items/Currency/CurrencyCorruptMonolith' then
            error(string.format('Something went seriously wrong here. Got results: %s', mw.dumpObject(results)))
        end
        for i=2, #results do
            local row = results[i]
            if row['essences.category'] == tpl_args.essence_category then
                -- 3 to 1 recipe
                recipes[#recipes+1] = {
                    automatic = true,
                    result_amount = 1,
                    text = nil,
                    parts = {
                        {
                            item_id = row['items.metadata_id'],
                            item_page = row['items._pageName'],
                            item_name = row['items.name'],
                            amount = 3,
                        },
                    },
                }
                -- corruption +1
                recipes[#recipes+1] = {
                    automatic = true,
                    result_amount = 1,
                    text = i18n.essence_plus_one_level,
                    parts = {
                        {
                            item_id = row['items.metadata_id'],
                            item_page = row['items._pageName'],
                            item_name = row['items.name'],
                            amount = 1,
                        },
                        {
                            item_id = remnant['items.metadata_id'],
                            item_page = remnant['items._pageName'],
                            item_name = remnant['items.name'],
                            amount = 1,
                        },
                    },
                }
            elseif tonumber(row['essences.type']) == tpl_args.essence_type - 1 then
                -- corruption type change
                recipes[#recipes+1] = {
                    automatic = true,
                    result_amount = 1,
                    text = i18n.essence_type_change,
                    parts = {
                        {
                            item_id = row['items.metadata_id'],
                            item_page = row['items._pageName'],
                            item_name = row['items.name'],
                            amount = 1,
                        },
                        {
                            item_id = remnant['items.metadata_id'],
                            item_page = remnant['items._pageName'],
                            item_name = remnant['items.name'],
                            amount = 1,
                        },
                    },
                }
            end
        end
    end
    
    -- data based on mapping
    if tpl_args.drop_enabled and not tpl_args.disable_automatic_recipes then
        -- Test and cache results of all named conditions
        for k, condition in pairs(c.named_conditions) do
            if type(condition) == 'function' then
                c.named_conditions[k] = condition(tpl_args)
            end
        end

        for _, data in ipairs(c.automatic_recipes) do
            local valid = true -- Can this recipe produce the item?

            -- Check cached results for named conditions
            for k, condition in pairs(c.named_conditions) do
                if data.conditions[k] then
                    valid = condition
                    if not valid then
                        break
                    end
                end
            end

            -- Test anonymous conditions
            for _, condition in ipairs(data.conditions) do
                valid = condition(tpl_args) and valid
                if not valid then
                    break
                end
            end

            if valid then
                recipes[#recipes+1] = {
                    automatic = true,
                    result_amount = 1,
                    text = data.text(),
                    parts = data.parts,
                }
                for part_num, row in ipairs(data.parts) do
                    if query_data['id'][row.item_id] then
                        table.insert(query_data['id'][row.item_id], {#recipes, part_num})
                    else
                        query_data['id'][row.item_id] = {{#recipes, part_num}, }
                    end
                end
            end
        end
    end
    
    if #recipes == 0 then
        return
    end
    --
    -- Fetch item data in a single query to sacrifice database load with a lot of references
    --
    local query_data_array = {
        id = {},
        name = {},
        page = {},
    }
    local query_fields = {
        id = 'items.metadata_id',
        page = 'items._pageName',
        name = 'items.name',
    }
    local where = {}
    local expected_count = 0
    for key, thing_array in pairs(query_data) do
        for thing, _ in pairs(thing_array) do
            table.insert(query_data_array[key], thing)
        end
        if #query_data_array[key] > 0 then
            expected_count = expected_count + #query_data_array[key]
            local q_data = table.concat(query_data_array[key], '", "')
            table.insert(where, string.format('%s IN ("%s")', query_fields[key], q_data))
        end
    end
    local results = m_cargo.query(
        {'items'},
        {'items._pageName',  'items.name', 'items.metadata_id'},
        {
            where=table.concat(where, ' OR '),
        }
    )

    -- Now do The Void
    for _, row in ipairs(results) do
        if row[query_fields.id] and string.find(row[query_fields.id], 'Metadata/Items/DivinationCards/', 1, true) then
            local part = {
                item_id = 'Metadata/Items/DivinationCards/DivinationCardTheVoid',
                amount = 1,
            }
            local result = m_cargo.query(
                {'items'},
                {'items._pageName',  'items.name', 'items.metadata_id'},
                {
                    where=string.format('%s = "%s"', query_fields.id, part.item_id),
                }
            )
            if #result > 0 then
                recipes[#recipes+1] = {
                    automatic = true,
                    result_amount = 1,
                    text = i18n.the_void,
                    parts = {part},
                }
                if query_data['id'][part.item_id] then
                    table.insert(query_data['id'][part.item_id], {#recipes, 1})
                else
                    query_data['id'][part.item_id] = {{#recipes, 1}, }
                end
                table.insert(results, result[1])
            end
            break
        end
    end

    for _, row in ipairs(results) do
        for key, thing_array in pairs(query_data) do
            local recipe_parts = thing_array[row[query_fields[key]]]
            if recipe_parts then
                for _, recipe_part in ipairs(recipe_parts) do
                    local entry = recipes[recipe_part[1]].parts[recipe_part[2]]
                    for entry_key, data_key in pairs(query_fields) do
                        -- metadata_id may be nil, since we don't know them for unique items
                        if row[data_key] then
                            entry['item_' .. entry_key] = row[data_key]
                        end
                    end
                end
                -- set this to nil for error checking in later step
                thing_array[row[query_fields[key]]] = nil
            end
        end
    end
    
    -- sbow the broken references if needed
    if #results ~= expected_count then
        -- query data was pruned of existing keys earlier, so only broken keys remain
        for key, array in pairs(query_data) do
            for thing, recipe_parts in pairs(array) do
                for _, recipe_part in ipairs(recipe_parts) do
                    tpl_args._flags.invalid_recipe_parts = true
                    tpl_args._errors[#tpl_args._errors+1] = m_util.string.format(i18n.errors.invalid_recipe_parts, string.format('recipe%s_part%s_item_%s', recipe_part[1], recipe_part[2], key), thing)
                end
            end
        end
    end
    
    --
    -- Check for duplicates
    --
    local delete_recipes = {}
    for i=automatic_index, #recipes do
        for j=1, automatic_index-1 do
            if #recipes[i].parts == #recipes[j].parts then
                local match = true
                for row_id, row in ipairs(recipes[i].parts) do
                    -- Only the fields from the database query are matched since we can be sure they're correct. Other fields may be subject to user error.
                    for _, key in ipairs({'item_id', 'item_name', 'item_page'})  do
                        match = match and (row[key] == recipes[j].parts[row_id][key])
                    end
                end
                if match then
                    tpl_args._flags.duplicate_recipes = true
                    tpl_args._errors[#tpl_args._errors+1] = string.format(i18n.errors.duplicate_recipes, j)
                    delete_recipes[#delete_recipes+1] = j 
                end
            end
        end
    end
    
    for offset, index in ipairs(delete_recipes) do
        table.remove(recipes, index-(offset-1))
    end

    --
    -- Set data
    -- 
    tpl_args.recipes = recipes
    
    -- Set recipes data
    for i, recipe in ipairs(recipes) do
        table.insert(tpl_args._store_data, {
            _table = 'acquisition_recipes',
            recipe_id = i,
            result_amount = recipe.result_amount,
            description = recipe.text,
            automatic = recipe.automatic,
        })
        for j, part in ipairs(recipe.parts) do
            table.insert(tpl_args._store_data, {
                _table = 'acquisition_recipe_parts',
                part_id = j,
                recipe_id = i,
                item_name = part.item_name,
                item_id = part.item_id,
                item_page = part.item_page,
                amount = part.amount,
                notes = part.notes,
            })
        end
    end
end

--
-- Debugging
--

function p.debug_validate_auto_upgraded_from()
    local q = {}
    local chk = {}
    for _, data in ipairs(c.automatic_recipes) do
        for _, part in ipairs(data.parts) do
            q[#q+1] = part.item_id
            chk[part.item_id] = {
                amount=part.amount,
                text=data.text(),
            }
        end
    end
    
    local results = m_cargo.array_query{
        tables={'items', 'stackables'},
        fields={'items.name', 'items.class_id', 'items.description', 'stackables.stack_size'},
        id_field='items.metadata_id',
        id_array=q,
        query={
            join='items._pageName=stackables._pageName',
        },
    }
    
    for _, row in ipairs(results) do
        if row['items.class_id'] == 'DivinationCard' and chk[row['items.metadata_id']].amount ~= tonumber(row['stackables.stack_size']) then
            mw.logObject(string.format('Amount mismatch %s, expected %s', row['items.metadata_id'], row['stackables.stack_size']))
        end
    end
    
    local tbl = mw.html.create('table')
    tbl:attr('class', 'wikitable sortable')
    for _, row in ipairs(results) do
        tbl
            :tag('tr')
                :tag('td')
                    :wikitext(row['items.name'])
                    :done()
                :tag('td')
                    :wikitext(chk[row['items.metadata_id']].text)
                    :done()
                :tag('td')
                    :wikitext(row['items.description'])
                    :done()
                :done()
    end
    
    return tostring(tbl)
end

return p