Module:StreetBrawlItems: Difference between revisionsGive feedback
Remove unused item/item_in_pool functions and now-dead helpers; rename normal to average; move all display text to the caller; anchor the gate above the Tier 1 heading so the reveal link lands on it (with help from vergir-bot LLM) |
m make item cards on the Street Brawl section sliiiightly bigger (+5%) |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 8: | Line 8: | ||
local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 } | local SLOT_RANK = { Weapon = 1, Armor = 2, Tech = 3 } | ||
-- Card scale passed to ItemBox. | -- Card scale passed to ItemBox. | ||
local CARD_SIZE = "0. | local CARD_SIZE = "0.7" | ||
local NAME_TO_KEY = {} | local NAME_TO_KEY = {} | ||
| Line 54: | Line 54: | ||
local function render_item(frame, code) | local function render_item(frame, code) | ||
local name = iname(code); if not name then return nil end | local name = iname(code); if not name then return nil end | ||
local args = { name, size = CARD_SIZE } | -- These hero pages place hundreds of cards at once, so the cards render in | ||
-- lowGraphics mode: ItemBox swaps its paper texture for a single cacheable | |||
-- overlay, which keeps scrolling smooth. See [[Template:ItemBox]]. | |||
local args = { name, size = CARD_SIZE, lowGraphics = "true" } | |||
-- Legendary (tier 5) cards omit the tier badge; it is redundant in the Legendary tier. | -- Legendary (tier 5) cards omit the tier badge; it is redundant in the Legendary tier. | ||
if itier(code) ~= 5 then args.showTierTag = "true" end | if itier(code) ~= 5 then args.showTierTag = "true" end | ||
| Line 181: | Line 184: | ||
out[#out + 1] = classdiv(parts, "sb-cards") | out[#out + 1] = classdiv(parts, "sb-cards") | ||
return table.concat(out, "\n") | return table.concat(out, "\n") | ||
end | |||
-- {{#invoke:StreetBrawlItems|counters_table}} | |||
-- Every hero that has counter items, one row each, sorted by hero name. Items | |||
-- within a row are listed alphabetically. Built as HTML rather than pipe-table | |||
-- markup so the invoke does not have to sit at the start of a line. | |||
function p.counters_table(frame) | |||
local by_hero, rows = {}, {} | |||
for _, o in ipairs(sb.Outliers) do | |||
if o.Counter ~= nil and iok(o.Item) then | |||
local hero = heroes[o.Hero] | |||
if hero and hero.Name then | |||
local row = by_hero[o.Hero] | |||
if not row then | |||
row = { name = hero.Name, items = {}, seen = {} } | |||
by_hero[o.Hero] = row | |||
rows[#rows + 1] = row | |||
end | |||
-- Guard against a hero/item pair being listed twice. | |||
if not row.seen[o.Item] then | |||
row.seen[o.Item] = true | |||
row.items[#row.items + 1] = iname(o.Item) | |||
end | |||
end | |||
end | |||
end | |||
if #rows == 0 then return "" end | |||
table.sort(rows, function(a, b) return a.name < b.name end) | |||
local tbl = mw.html.create("table"):addClass("wikitable") | |||
local head = tbl:tag("tr") | |||
head:tag("th"):wikitext("Hero") | |||
head:tag("th"):wikitext("Items") | |||
for _, row in ipairs(rows) do | |||
table.sort(row.items) | |||
local icons = {} | |||
for _, n in ipairs(row.items) do | |||
icons[#icons + 1] = frame:expandTemplate{title = "ItemIcon", args = {n}} | |||
end | |||
local tr = tbl:tag("tr") | |||
tr:tag("td"):wikitext(frame:expandTemplate{title = "HeroIcon", args = {row.name}}) | |||
tr:tag("td"):wikitext(table.concat(icons, ", ")) | |||
end | |||
return tostring(tbl) | |||
end | end | ||
return p | return p | ||