Module:Sandbox: Difference between revisions

No edit summary
No edit summary
Line 79: Line 79:
     end
     end
      
      
     local stats_text = table.concat(stats, "\n|-\n| ")
     local stats_text = table.concat(stats, "\\n|\\n| ")
      
      
     -- Generate components section if exists
     -- Generate components section if exists
Line 94: Line 94:
         if #component_names > 0 then
         if #component_names > 0 then
             components_text = string.format(
             components_text = string.format(
                 [=[! colspan="4" style="text-align:left; padding:0 12px; font-weight:bold; font-size:16px; font-family:'Retail Demo Bold',serif; %s">COMPONENTS:<br/>]=],
                 "! colspan=\"4\" style=\"text-align:left; padding:0 12px; font-weight:bold; font-size:16px; font-family:'Retail Demo Bold',serif; %s\" | COMPONENTS:<br/>%s",
                 (item_type == "Weapon" and "background-color: #9E630C; color: #DCCFC6;" or
                 (item_type == "Weapon" and "background-color: #9E630C; color: #DCCFC6;" or
                 item_type == "Vitality" and "background-color: #203500; color: #C7C9C6;" or
                 item_type == "Vitality" and "background-color: #203500; color: #C7C9C6;" or
                 "background-color: #372248; color: #C9C7CB;")
                 "background-color: #372248; color: #C9C7CB;"),
                table.concat(component_names, "<br/>{{ItemIcon|", "{{ItemIcon|", "}}")
             )
             )
           
            for i, name in ipairs(component_names) do
                if i > 1 then components_text = components_text .. "<br/>" end
                components_text = components_text .. "{{ItemIcon|" .. name .. "}}"
            end
         end
         end
     end
     end
Line 120: Line 116:
     end
     end
      
      
     -- Generate the full infobox
     -- Build the infobox as separate parsed chunks
     local infobox = string.format([=[
     local infobox_parts = {
<div class="infobox_item" style="float:right; display:inline-block; vertical-align:top;">
        frame:preprocess(string.format(
{| class="wikitable" style="text-align:left; border-collapse:collapse; width:312px; max-width:100%%; color: #FFEFD7; padding:12px; font-family:'Retail Demo Regular',serif; %s"
            [[<div class="infobox_item" style="float:right; display:inline-block; vertical-align:top;">
! colspan="4" style="width:280px; padding:5px 12px; text-align:center; font-size:24px; font-family:'Retail Demo Bold',serif; %s">%s
            {| class="wikitable" style="text-align:left; border-collapse:collapse; width:312px; max-width:100%%; color: #FFEFD7; padding:12px; font-family:'Retail Demo Regular',serif; %s"
|-
            ! colspan="4" style="width:280px; padding:5px 12px; text-align:center; font-size:24px; font-family:'Retail Demo Bold',serif; %s" | %s]],
| colspan=4 class="infobox-image" style="padding:5px; text-align:center;">[[File:%s.png|144px]]
            (item_type == "Weapon" and "background-color: #80550F;" or
|-
            item_type == "Vitality" and "background-color: #4D7214;" or
| colspan=2 style="text-align:right; width:50%%; %s padding-right:0.5em;">Cost
            "background-color: #623585;"),
| colspan=2 style="padding-left:0.5em;">{{Souls|%s}}
            (item_type == "Weapon" and "background-color: #C97A03;" or
|-
            item_type == "Vitality" and "background-color: #659818;" or
| colspan=2 style="text-align:right; width:50%%; %s padding-right:0.5em;">Tier
            "background-color: #8B56B4;"),
| colspan=2 style="padding-left:0.5em;">%s
            item.Name
|-
         )),
| colspan=2 style="text-align:right; width:50%%; %s padding-right:0.5em;">Shop Bonus
| colspan=2 style="padding-left:0.5em;">%s
|-
%s
|-
| colspan="4" style="text-align:left; padding:0 12px; color:#FFEFD7; %s">%s
|-
| %s
|}
</div>]=],
        -- Background color
        (item_type == "Weapon" and "background-color: #80550F;" or
        item_type == "Vitality" and "background-color: #4D7214;" or
        "background-color: #623585;"),
       
        -- Header color
        (item_type == "Weapon" and "background-color: #C97A03;" or
        item_type == "Vitality" and "background-color: #659818;" or
        "background-color: #8B56B4;"),
       
        -- Item name
        item.Name,
       
        -- Image
        item.Name,
       
        -- Cost border
         (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
        item_type == "Vitality" and "border-right:1px solid #659818;" or
        "border-right:1px solid #8B56B4;"),
       
        -- Cost value
        formatNum(item.Cost or 0),
          
          
         -- Tier border (same as cost)
         frame:preprocess(string.format(
        (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
            "|-\n| colspan=4 class=\"infobox-image\" style=\"padding:5px; text-align:center;\" | [[File:%s.png|144px]]",
        item_type == "Vitality" and "border-right:1px solid #659818;" or
            item.Name
        "border-right:1px solid #8B56B4;"),
        )),
          
          
         -- Tier value
         frame:preprocess(string.format(
        item.Tier or "1",
            "|-\n| colspan=2 style=\"text-align:right; width:50%%; %s padding-right:0.5em;\" | Cost\n| colspan=2 style=\"padding-left:0.5em;\" | {{Souls|%s}}",
            (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
            item_type == "Vitality" and "border-right:1px solid #659818;" or
            "border-right:1px solid #8B56B4;"),
            formatNum(item.Cost or 0)
        )),
          
          
         -- Shop bonus border (same as cost)
         frame:preprocess(string.format(
        (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
            "|-\n| colspan=2 style=\"text-align:right; width:50%%; %s padding-right:0.5em;\" | Tier\n| colspan=2 style=\"padding-left:0.5em;\" | %s",
        item_type == "Vitality" and "border-right:1px solid #659818;" or
            (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
        "border-right:1px solid #8B56B4;"),
            item_type == "Vitality" and "border-right:1px solid #659818;" or
            "border-right:1px solid #8B56B4;"),
            item.Tier or "1"
        )),
          
          
         -- Shop bonus
         frame:preprocess(string.format(
         shop_bonus,
            "|-\n| colspan=2 style=\"text-align:right; width:50%%; %s padding-right:0.5em;\" | Shop Bonus\n| colspan=2 style=\"padding-left:0.5em;\" | %s",
            (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
            item_type == "Vitality" and "border-right:1px solid #659818;" or
            "border-right:1px solid #8B56B4;"),
            shop_bonus
         )),
          
          
         -- Components
         components_text ~= "" and frame:preprocess("|-\n"..components_text) or "",
        components_text,
          
          
         -- Description background
         frame:preprocess(string.format(
        (item_type == "Weapon" and "background-color: #80550F;" or
            "|-\n| colspan=\"4\" style=\"text-align:left; padding:0 12px; color:#FFEFD7; %s\" | %s",
        item_type == "Vitality" and "background-color: #4D7214;" or
            (item_type == "Weapon" and "background-color: #80550F;" or
        "background-color: #623585;"),
            item_type == "Vitality" and "background-color: #4D7214;" or
            "background-color: #623585;"),
            item.Description or ""
        )),
          
          
         -- Description text
         stats_text ~= "" and frame:preprocess("|-\n| "..stats_text) or "",
        item.Description or "",
          
          
         -- Stats
         frame:preprocess("|}\n</div>")
        stats_text
     }
     )
      
      
     -- Process the wikitext through the parser before returning
     -- Combine all parts and return
     return frame:preprocess(infobox)
     return table.concat(infobox_parts)
end
end


return p
return p