Module:StreetBrawlItems: Difference between revisionsGive feedback
Populate Street Brawl item-weighting helper: joins Data:StreetBrawlData.json with ItemData/HeroData, renders favored/unfavored/common/counter groups for hero and item pages (with help from vergir-bot LLM) |
Wrap rendered groups in flex rows so cards and hero icons have consistent spacing (with help from vergir-bot LLM) |
||
| Line 40: | Line 40: | ||
end | end | ||
-- Wraps a rendered | -- Lays rendered members out in a wrapping flex row with a consistent gap. | ||
-- Returns "" when the | local function flexrow(parts, gap, center) | ||
if #parts == 0 then return "" end | |||
local align = center and "center" or "flex-start" | |||
return '<div style="display:flex; flex-wrap:wrap; gap:' .. gap .. '; align-items:' .. align .. '">' | |||
.. table.concat(parts) .. '</div>' | |||
end | |||
-- Wraps a rendered row with an optional bold label / italic note, or a collapsible box. | |||
-- Returns "" when the row is empty, so nothing (not even the label) shows. | |||
local function wrap(inner, label, note, collapse) | local function wrap(inner, label, note, collapse) | ||
if inner == "" then return "" end | if inner == "" then return "" end | ||
| Line 105: | Line 113: | ||
local parts = {} | local parts = {} | ||
for _, c in ipairs(codes) do local r = render_item(frame, c, style); if r then parts[#parts + 1] = r end end | for _, c in ipairs(codes) do local r = render_item(frame, c, style); if r then parts[#parts + 1] = r end end | ||
local is_icon = (style == "icon") | |||
local inner = flexrow(parts, is_icon and "4px 10px" or "8px", is_icon) | |||
return wrap(inner, frame.args.label, nil, collapse) | |||
end | end | ||
| Line 126: | Line 136: | ||
if heading and heading ~= "" then out[#out + 1] = "=== " .. heading .. " ===" end | if heading and heading ~= "" then out[#out + 1] = "=== " .. heading .. " ===" end | ||
local note = frame.args.note | local note = frame.args.note | ||
if note and note ~= "" then out[#out + 1] = "''" .. note .. "'' | if note and note ~= "" then out[#out + 1] = "''" .. note .. "''" end | ||
out[#out + 1] = | out[#out + 1] = flexrow(parts, "8px", false) | ||
return table.concat(out, "\n") | return table.concat(out, "\n") | ||
end | end | ||
| Line 151: | Line 161: | ||
local parts = {} | local parts = {} | ||
for _, k in ipairs(list) do local r = render_hero(frame, k); if r then parts[#parts + 1] = r end end | for _, k in ipairs(list) do local r = render_hero(frame, k); if r then parts[#parts + 1] = r end end | ||
return wrap( | local inner = flexrow(parts, "4px 10px", true) | ||
return wrap(inner, frame.args.label, frame.args.note, false) | |||
end | end | ||