Module:StreetBrawlItems: Difference between revisionsGive feedback
Revert p.tier to three sibling columns (High | Middle | Low) (with help from vergir-bot LLM) Tag: Manual revert |
p.tier: add layout=grid mode (one wrapping grid, cards outlined by chance) (with help from vergir-bot LLM) |
||
| Line 139: | Line 139: | ||
end | end | ||
-- {{#invoke:StreetBrawlItems|tier|HERO|TIER|style=icon|card|size=..|theme=..|high=..|middle=..|low=..}} | -- {{#invoke:StreetBrawlItems|tier|HERO|TIER|style=icon|card|size=..|theme=..|layout=grid|high=..|middle=..|low=..}} | ||
-- | -- Default: three columns High chance (favored) | Middle chance (pool) | Low chance (unfavored). | ||
-- layout=grid: one wrapping grid of the whole tier, each card outlined by its chance. | |||
function p.tier(frame) | function p.tier(frame) | ||
local hkey = hero_key(frame.args[1]); if not hkey then return "" end | local hkey = hero_key(frame.args[1]); if not hkey then return "" end | ||
| Line 161: | Line 161: | ||
table.sort(normal, item_less) | table.sort(normal, item_less) | ||
table.sort(low, item_less) | table.sort(low, item_less) | ||
-- layout=grid: single wrapping grid, cards outlined by chance (High, then Middle, then Low). | |||
if frame.args.layout == "grid" then | |||
local function chips(codes, chance) | |||
local out = {} | |||
for _, c in ipairs(codes) do | |||
local r = render_item(frame, c, "card", size) | |||
if r then out[#out + 1] = '<span class="sb-chip ' .. chance .. '">' .. r .. '</span>' end | |||
end | |||
return table.concat(out) | |||
end | |||
return '<div class="sb-grid">' | |||
.. chips(high, "sb-chip-high") | |||
.. chips(normal, "sb-chip-normal") | |||
.. chips(low, "sb-chip-low") | |||
.. '</div>' | |||
end | |||
local body_class = (style == "card") and "sb-col-body sb-col-cards" or "sb-col-body" | local body_class = (style == "card") and "sb-col-body sb-col-cards" or "sb-col-body" | ||