From Arms of God Wiki
Documentation for this module may be created at Module:Compare/doc
-- Module:Compare — Phase 12 comparison-table renderer (Arms of God).
-- Reads Data:Compare_<Cat>.json (headers + rows of {t=display, s=sortval}).
-- Renders a class="sortable wikitable" with data-sort-value on numeric cells.
-- Pure presentation; no game logic. Re-run safe — data lives in the Data: page.
local p = {}
local function cell(c, isFirst)
local t = tostring(c.t or '—')
if isFirst then
-- first column: link to the entity page (display name == page title)
if t ~= '—' then t = '[[' .. t .. ']]' end
return '| ' .. t
end
if c.s ~= nil then
return '| data-sort-value="' .. tostring(c.s) .. '" | ' .. t
end
return '| ' .. t
end
function p.render(frame)
local cat = frame.args[1] or frame.args.cat
if not cat or cat == '' then
return '<strong class="error">Module:Compare: missing category arg</strong>'
end
local ok, data = pcall(mw.loadJsonData, 'Data:Compare_' .. cat .. '.json')
if not ok or type(data) ~= 'table' or not data.rows then
return '<strong class="error">Module:Compare: cannot load Data:Compare_'
.. cat .. '.json</strong>'
end
local out = { '{| class="wikitable sortable" style="font-size:0.95em;"' }
-- header row
out[#out+1] = '|-'
for _, h in ipairs(data.headers or {}) do
out[#out+1] = '! ' .. tostring(h)
end
for _, row in ipairs(data.rows) do
out[#out+1] = '|-'
for i, c in ipairs(row) do
out[#out+1] = cell(c, i == 1)
end
end
out[#out+1] = '|}'
return table.concat(out, '\n')
end
return p