ماڊيول:Sports table/CricketRR: جي ورجائن ۾ تفاوت

ڊاٿل مواد شامل ڪيل مواد
سنوار جو تَتُ ڪونهي
ٽيگَ: موبائل سنوار موبائل ويب سنوار
سنوار جو تَتُ ڪونهي
سِٽَ 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 12 ⟶ 33:
local team_width = Args['teamwidth'] or '180'
local sort_text = yesno(Args['sortable_table'] or 'no') and ' sortable' or ''
--local show_played = not yesno(Args['hide_played'] or 'no')
 
table.insert(t,'{|class="wikitable'..sort_text..'" style="text-align:center;"\n') -- Open table
Line 22 ⟶ 42:
 
--Header specific options
--local show_playedshow_pts = not yesno(Args['hide_playedshow_header_pts'] or 'no')
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 'ٽيم'
local tie_head_text = Args['tie_header'] or abbr_header('<abbr title="Tied">برابر</abbr>', 'T', show_pts, pts.tie)
local nr_head_text = Args['nr_header'] or abbr_header('<abbr title="No result">بلا نتیجو</abbr>', 'NR', show_pts, pts.nr)
local bonus_head_text = Args['bonus_header'] or '<abbr title="Bonus points">بونس پوائنٽس پوائنٽس</abbr>'
local deduct_head_text = Args['deduct_header'] or '<abbr title="Deductions">Ded</abbr>'
local nrr_head_text = Args['nrr_header'] or '<abbr title="Net run rate">[[نيٽ رن ريٽ|NRR]]</abbr>'
--
local loss_first = yesno(Args['loss_before_tie'] or 'yes')
Line 35 ⟶ 59:
local show_bonus_points = yesno(Args['show_bonus_points'] or 'no')
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 49 ⟶ 71:
tt = p_sub.colhead(tt,28,pos_label) -- Position col
end
 
-- Add group header
if full_table and group_col then
tt = p_sub.colhead(tt,28,group_head_text) -- Group col
end
 
tt = p_sub.colhead(tt, team_width, team_head_text..VTE_text) -- Team col
Line 56 ⟶ 83:
if full_table then
 
tt = p_sub.colhead(tt,28,abbr_header('<abbr title="Won">کٽيا</abbr>','W',show_pts,pts.win) ) -- Win col
local loss_head_text = abbr_header('هاريا', 'L', show_pts, pts.loss)
if loss_first then
tt = p_sub.colhead(tt,28,'<abbr title="Lost">هاريا</abbr>'loss_head_text) -- Loss col
 
if show_tie then
Line 69 ⟶ 97:
end
 
tt = p_sub.colhead(tt, 28, '<abbr title="Lost">L</abbr>'loss_head_text) -- Loss col
end
if show_nr then
Line 87 ⟶ 115:
if show_nrr then
tt = p_sub.colhead(tt,28,nrr_head_text) -- NRR col
end
if show_nrr_fa then
tt = p_sub.colhead(tt, 60, 'For')
tt = p_sub.colhead(tt, 60, 'Against')
end
tt.count = tt.count+1
Line 93 ⟶ 125:
return tt
end
 
 
local function rr_to_dec(runs, overs, balls_per_over)
if overs == 0 then
return 0
end
local balls = overs % 1
return runs / (overs - balls + balls * 10 / balls_per_over)
end
 
Line 102 ⟶ 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 118 ⟶ 151:
local show_deduct = yesno(Args['show_deductions'] or 'no')
local show_nrr = yesno(Args['show_nrr'] or 'yes')
local show_nrr_fa = yesno(Args['show_nrr_fa'] or 'no') and show_nrr
 
-- Get some input
Line 126 ⟶ 160:
local bonuses = tonumber(Args['bonus_'..team_code_ii]) or 0
local deductions = tonumber(Args['ded_'..team_code_ii]) or 0
local nrr = tonumber(Args['nrr_'..team_code_ii]) or nil
 
local oversbowled = tonumber(Args['ob_'..team_code_ii]) or 0
Line 131 ⟶ 166:
local oversreceived = tonumber(Args['or_'..team_code_ii]) or 0
local runsscored = tonumber(Args['rs_'..team_code_ii]) or 0
local balls_per_over = tonumber(Args['balls_per_over']) or 6
 
local hth_local = Args['hth_'..team_code_ii] or nil
Line 137 ⟶ 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
Line 170 ⟶ 207:
end
local nrr_for = rr_to_dec(runsscored, oversreceived, balls_per_over)
local nrr_against = rr_to_dec(runsconceded, oversbowled, balls_per_over)
 
-- Set Net Run Rate. This is probabaly over-engineered and could just be done with a single precalculated value
localif nrr ~= nil then
nrr = mm._precision_format(nrr, 3)
ifelseif (oversbowled == 0 ) or (oversreceived == 0) then -- if 0 or null then have mdash rather than 0?
nrr = '&mdash;'
else
nrr = mm._precision_format((runsscored / oversreceived)nrr_for - (runsconceded / oversbowled ) nrr_against, 3)
end
 
Line 214 ⟶ 255:
end
if show_deduct then
table.insert(t,'| style="'..ii_fw..bg_col..'" | '..deductions..'\n')
end
end
Line 225 ⟶ 266:
if show_nrr then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..nrr..'\n') -- Net run rate
end
if show_nrr_fa then
local nrr_for_text = oversreceived > 0 and runsscored..'/'..oversreceived or '&mdash;'
local nrr_against_text = oversbowled > 0 and runsconceded..'/'..oversbowled or '&mdash;'
table.insert(t, '| data-sort-value="'..nrr_for..'" style="'..ii_fw..bg_col..'" |'..nrr_for_text..'\n')
table.insert(t, '| data-sort-value="'..nrr_against..'" style="'..ii_fw..bg_col..'" |'..nrr_against_text..'\n')
end
end
Line 241 ⟶ 288:
status_code = { A='Advances to a further round', C='فتح', D='نااهل',
E='ٻاهر', G='مهمان', H='ميزبان', O='پلي آف فتح', P='Promoted', Q='مرحلي جي لاءِ قواليفائي ڪيائون',
R='Relegated', T='Qualified, but not yet to the particular phase indicated' }
local status_letters = (Args['status_order'] or '') .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'