Module:StreetBrawlItems: Difference between revisions

Jump to navigation Jump to search
p.tier: add layout=grid mode (one wrapping grid, cards outlined by chance) (with help from vergir-bot LLM)
p.tier columns: conditional widths (drop empty Low; 35/65; narrow one-card Low when High present, fit-content Low when High absent); card size 0.8 (with help from vergir-bot LLM)
Line 8: Line 8:
local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 }
local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 }
-- Default card scale passed to ItemBox (tier columns and counter cards).
-- Default card scale passed to ItemBox (tier columns and counter cards).
local CARD_SIZE = "0.875"
local CARD_SIZE = "0.8"


local NAME_TO_KEY, KEY_TO_NAME, RELEASED = {}, {}, {}
local NAME_TO_KEY, KEY_TO_NAME, RELEASED = {}, {}, {}
Line 140: Line 140:


-- {{#invoke:StreetBrawlItems|tier|HERO|TIER|style=icon|card|size=..|theme=..|layout=grid|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).
-- Default: conditional columns. High chance (favored) 35% and Middle chance (pool) fill
-- layout=grid: one wrapping grid of the whole tier, each card outlined by its chance.
-- the rest. Low chance (unfavored) is dropped when empty; when present alongside High it
-- becomes a narrow one-card column on the right; when High is absent it sits on the right
-- sized to fit its cards on one line. layout=grid: one grid, cards outlined by 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 196: Line 198:
local cls = "sb-tier"
local cls = "sb-tier"
if theme ~= "" then cls = cls .. " " .. theme end
if theme ~= "" then cls = cls .. " " .. theme end
return '<div class="' .. cls .. '">'
 
.. col(high, "sb-col-high", hi)
-- Conditional columns per the presence of High and Low.
.. col(normal, "sb-col-normal", mid)
local out = {}
.. col(low, "sb-col-low", lo)
if #high > 0 then
.. '</div>'
out[#out + 1] = col(high, "sb-col-high sb-w-high", hi)
end
out[#out + 1] = col(normal, "sb-col-normal sb-w-fill", mid)
if #low > 0 then
local low_w = (#high > 0) and "sb-low-narrow" or "sb-low-wide"
out[#out + 1] = col(low, "sb-col-low " .. low_w, lo)
end
return '<div class="' .. cls .. '">' .. table.concat(out) .. '</div>'
end
end