require('strict')
local getArgs = require('Module:Arguments').getArgslocal roundAndPad = require('Module:Math')._precision_format
local p =
local function total(frame, played, won, drawn, lost, category) if played
'—' then return '—' elseif not played then if not won and not drawn and not lost then return end return frame:expandTemplate elseif tonumber(played) ~= (won or 0) + (drawn or 0) + (lost or 0) then return '
error' .. (category or ) .. '' else return frame:expandTemplate endendlocal function displayWinPercent(frame, winPercent, decimals) local retval = if winPercent < 10 then retval = '
' elseif winPercent < 100 then retval = ' ' end return retval .. frame:expandTemplateendlocal function pct(frame, played, won, drawn, lost, decimals) if played
'—' then return '—' elseif not played then if not won and not drawn and not lost then return elseif (won or 0) + (drawn or 0) + (lost or 0) <= 0 then return '
—' end return displayWinPercent(frame, 100 * (won or 0) / (((won or 0) + (drawn or 0) + (lost or 0)) or 1), decimals) elseif tonumber(played) <= 0 then return ' —' else return displayWinPercent(frame, 100 * (won or 0) / played, decimals) endendfunction p.main(frame, otherargs) local args = otherargs or getArgs(frame) local tableprefix = string.format('| style="%stext-align:%s" |', args.total and 'font-weight:bold;background:#efefef;' or , args.align or 'center') local retval = tableprefix .. total(frame, args[1], args[2], args[3], args[4], args.demospace and or '') .. '\n' retval = retval .. tableprefix .. frame:expandTemplate .. '\n' retval = retval .. tableprefix .. frame:expandTemplate .. '\n' retval = retval .. tableprefix .. frame:expandTemplate .. '\n' if args['for'] then retval = retval .. tableprefix .. frame:expandTemplate .. '\n' end if args.against then retval = retval .. tableprefix .. frame:expandTemplate .. '\n' end if args.diff
return p