Module:StreetBrawlItems: Difference between revisionsGive feedback
Render Street Brawl item cards in lowGraphics mode; these hero pages place hundreds of cards, so they use the cacheable overlay texture for smooth scrolling (with help from vergir-bot LLM) |
m make item cards on the Street Brawl section sliiiightly bigger (+5%) |
||
| (One intermediate revision by one other user 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 184: | 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 | ||