Module:Sandbox: Difference between revisions

No edit summary
No edit summary
Line 71: Line 71:
     local color = colors[item_type] or colors.Weapon
     local color = colors[item_type] or colors.Weapon


     -- Process components
     -- Process components - more robust handling
     local components = {}
     local component_text = ""
     if item.Components and type(item.Components) == "table" then
     if item.Components and type(item.Components) == "table" then
        local valid_components = {}
         for _, comp_id in ipairs(item.Components) do
         for _, comp_id in ipairs(item.Components) do
             local component = data[comp_id]
             local component = data[comp_id]
             if component and component.Name then
             if component and component.Name then
                 table.insert(components, component.Name)
                 table.insert(valid_components, "{{ItemIcon|" .. component.Name .. "}}")
             end
             end
        end
       
        if #valid_components > 0 then
            component_text = string.format(
                '|-\n! colspan="4" style="text-align:left; padding:0 12px; font-weight:bold; font-size:16px; font-family:\'Retail Demo Bold\',serif; background-color: %s; color: %s" | COMPONENTS:<br/>%s',
                (item_type == "Weapon" and "#9E630C" or item_type == "Vitality" and "#203500" or "#372248"),
                (item_type == "Weapon" and "#DCCFC6" or item_type == "Vitality" and "#C7C9C6" or "#C9C7CB"),
                table.concat(valid_components, "<br/>")
            )
         end
         end
     end
     end


     -- Process stats
     -- Process stats - including Rapid Recharge specific stats
     local stats = {}
     local stats = {}
     local stat_config = {
     local stat_config = {
Line 91: Line 101:
         AbilityCooldown = {icon = "Cooldown Icon.png", suffix = "s Cooldown"},
         AbilityCooldown = {icon = "Cooldown Icon.png", suffix = "s Cooldown"},
         AbilityCastRange = {suffix = "m Cast Range"},
         AbilityCastRange = {suffix = "m Cast Range"},
         AbilityUnitTargetLimit = {prefix = "Targets: "}
         AbilityUnitTargetLimit = {prefix = "Targets: "},
        -- Rapid Recharge specific stats
        CooldownBetweenChargeReduction = {suffix = "% Charge Cooldown Reduction"},
        BonusAbilityCharges = {prefix = "+", suffix = " Bonus Charges"},
        CooldownReductionOnChargedAbilities = {suffix = "% Charged Ability Cooldown Reduction"},
        BaseAttackDamagePercent = {suffix = "% Base Attack Damage"}
     }
     }


Line 101: Line 116:
             text = text .. tostring(value)
             text = text .. tostring(value)
             if config.icon then text = text .. " [[File:" .. config.icon .. "|20px]]" end
             if config.icon then text = text .. " [[File:" .. config.icon .. "|20px]]" end
             if config.suffix then text = text .. " " .. config.suffix end
             if config.suffix then text = text .. config.suffix end
             table.insert(stats, text)
             table.insert(stats, text)
         end
         end
Line 156: Line 171:


     -- Add components if they exist
     -- Add components if they exist
     if #components > 0 then
     if component_text ~= "" then
        table.insert(parts, component_text)
    end
 
    -- Add description if it exists
    if item.Description then
         table.insert(parts,
         table.insert(parts,
             string.format(
             string.format(
                 '|-\n! colspan="4" style="text-align:left; padding:0 12px; font-weight:bold; font-size:16px; font-family:\'Retail Demo Bold\',serif; background-color: %s; color: %s" | COMPONENTS:<br/>%s',
                 '|-\n| colspan="4" style="text-align:left; padding:0 12px; color:#FFEFD7; background-color: %s" | %s',
                 (item_type == "Weapon" and "#9E630C" or item_type == "Vitality" and "#203500" or "#372248"),
                 color.bg, item.Description
                (item_type == "Weapon" and "#DCCFC6" or item_type == "Vitality" and "#C7C9C6" or "#C9C7CB"),
                table.concat(components, "<br/>{{ItemIcon|", "{{ItemIcon|", "}}")
             )
             )
         )
         )
     end
     end
    -- Add description
    table.insert(parts,
        string.format(
            '|-\n| colspan="4" style="text-align:left; padding:0 12px; color:#FFEFD7; background-color: %s" | %s',
            color.bg, item.Description or ""
        )
    )


     -- Add stats if they exist
     -- Add stats if they exist