Module:StreetBrawlItems: Difference between revisionsGive feedback
Remove temporary max-row counter (with help from vergir-bot LLM) |
Add p.tier: three-column High/Normal/Low chance layout for a tier (prototype) (with help from vergir-bot LLM) |
||
| Line 138: | Line 138: | ||
if label ~= "" then out = out .. '<div class="sb-label">' .. label .. '</div>' end | if label ~= "" then out = out .. '<div class="sb-label">' .. label .. '</div>' end | ||
return out .. classdiv(parts, row_class) .. '</div>' | return out .. classdiv(parts, row_class) .. '</div>' | ||
end | |||
-- {{#invoke:StreetBrawlItems|tier|HERO|TIER|high=..|normal=..|low=..}} | |||
-- Renders one tier as three columns: High chance (favored), Normal chance | |||
-- (the leftover pool), Low chance (unfavored). Empty columns still render. | |||
function p.tier(frame) | |||
local hkey = hero_key(frame.args[1]); if not hkey then return "" end | |||
local tier = tonumber(frame.args[2]) | |||
local favored, unfavored = hero_sets(hkey) | |||
local high, normal, low = {}, {}, {} | |||
for _, c in ipairs(sb.AvailableItems) do | |||
if iok(c) and (tier == nil or itier(c) == tier) then | |||
if favored[c] then high[#high + 1] = c | |||
elseif unfavored[c] then low[#low + 1] = c | |||
else normal[#normal + 1] = c end | |||
end | |||
end | |||
table.sort(high, item_less) | |||
table.sort(normal, item_less) | |||
table.sort(low, item_less) | |||
local function col(codes, cls, head) | |||
local parts = {} | |||
for _, c in ipairs(codes) do local r = render_item(frame, c, "icon"); if r then parts[#parts + 1] = r end end | |||
return '<div class="sb-col ' .. cls .. '">' | |||
.. '<div class="sb-col-head">' .. head .. '</div>' | |||
.. '<div class="sb-col-body">' .. table.concat(parts, "<br>") .. '</div>' | |||
.. '</div>' | |||
end | |||
local hi = frame.args.high or "High chance" | |||
local no = frame.args.normal or "Normal chance" | |||
local lo = frame.args.low or "Low chance" | |||
return '<div class="sb-tier">' | |||
.. col(high, "sb-col-high", hi) | |||
.. col(normal, "sb-col-normal", no) | |||
.. col(low, "sb-col-low", lo) | |||
.. '</div>' | |||
end | end | ||