| Latest revision |
Your text |
| 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.7" | | local CARD_SIZE = "0.667" |
|
| |
|
| 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 |