Module:Sports table/CricketRR: Difference between revisions

Content deleted Content added
m Protected "Module:Sports table/CricketRR": High-risk template or module (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))
m show_header_pts arg
Line 2:
local pp = { }
 
 
local function args_points(Args)
local pts = {}
 
-- Do not change these defaults without first checking which tables use them
local win_pointspts.win = tonumber(Args['winpoints']) or 2
local tie_points pts.tie = tonumber(Args['tiepoints']) or 1
local nr_points pts.nr = tonumber(Args['nrpoints']) or 1
local loss_points pts.loss = tonumber(Args['losspoints']) or 0
pts.bonus = tonumber(Args['bonuspoints']) or 1
 
return pts
end
 
local function abbr_header(txt, abbr, show_header_pts, pts)
if show_header_pts then
txt = txt .. ' – ' .. pts .. (pts == 1 and ' point' or ' points')
end
 
return '<abbr title="' .. txt .. '">' .. abbr .. '</abbr>'
end
 
function pp.header(t, Args, p_sub, pos_label, group_col, VTE_text, full_table, results_header_txt)
Line 21 ⟶ 42:
 
--Header specific options
--local ranking_styleshow_pts = yesno(Args['ranking_styleshow_header_pts'] or 'ptsno')
local pts = args_points(Args)
 
local group_head_text = Args['group_header'] or '<abbr title="Group">Grp</abbr>'
local team_head_text = Args['team_header'] or 'Team'
local tie_head_text = Args['tie_header'] or abbr_header('<abbr title="Tied">', 'T</abbr>', show_pts, pts.tie)
local nr_head_text = Args['nr_header'] or abbr_header('<abbr title="No result">', 'NR</abbr>', show_pts, pts.nr)
local bonus_head_text = Args['bonus_header'] or '<abbr title="Bonus points">BP</abbr>'
local deduct_head_text = Args['deduct_header'] or '<abbr title="Deductions">Ded</abbr>'
Line 36 ⟶ 60:
local show_nrr = yesno(Args['show_nrr'] or 'yes')
local show_nrr_fa = yesno(Args['show_nrr_fa'] or 'no') and show_nrr
 
-- What to rank the teams by
--local ranking_style = Args['ranking_style'] or 'pts'
 
-- Initialize
Line 62 ⟶ 83:
if full_table then
 
tt = p_sub.colhead(tt,28,abbr_header('<abbr title="Won">','W</abbr>',show_pts,pts.win) ) -- Win col
local loss_head_text = abbr_header('Lost', 'L', show_pts, pts.loss)
if loss_first then
tt = p_sub.colhead(tt,28,'<abbr title="Lost">L</abbr>'loss_head_text) -- Loss col
 
if show_tie then
Line 75 ⟶ 97:
end
 
tt = p_sub.colhead(tt, 28, '<abbr title="Lost">L</abbr>'loss_head_text) -- Loss col
end
if show_nr then
Line 121 ⟶ 143:
local mm = require('Module:Math')
local yesno = require('Module:Yesno')
 
-- Get custom/default options for in table
-- Do not change these defaults without first checking which tables use them
local win_points = tonumber(Args['winpoints']) or 2
local tie_points = tonumber(Args['tiepoints']) or 1
local nr_points = tonumber(Args['nrpoints']) or 1
local loss_points = tonumber(Args['losspoints']) or 0
local bonus_points = tonumber(Args['bonuspoints']) or 1 -- in some competitions it is 4 pts for win + bonus point for some winning margin
 
-- table options, to match those in the header
Line 159 ⟶ 173:
local matches = wins + losses + ties + noresults
 
local s_bpspts = bonus_points * bonusesargs_points(Args)
local s_bps = pts.bonus*bonuses
local points = win_pointspts.win*wins + loss_pointspts.loss*losses + tie_pointspts.tie*ties + nr_pointspts.nr*noresults + s_bps - deductions
-- Some local vars