-- Based on percentage
rank_wperc = true
win_fw=ii_fw
win_string = ''
elseif ranking_style=='ppg' or ranking_style=='points per game' or ranking_style=='ptspergame' then
-- Based on points per game
rank_ppg = true
win_fw=ii_fw
win_string = ''
elseif ranking_style=='percpts' or ranking_style=='%pts' then
-- Based on percentage and points
rank_perc = true
rank_points = true
win_fw=ii_fw
win_string = ''
elseif ranking_style=='ppgpts' then
-- Based on ppg and points
rank_ppg = true
rank_points = true
win_fw=ii_fw
win_string = ''
elseif ranking_style=='' then
win_fw=ii_fw
win_string = ''
else
-- Based on points
rank_points = true
win_fw=ii_fw
win_string = ''
end
local show_played = not yesno(Args['hide_played'] or 'no')
local show_away_goals = yesno(Args['show_away_goals'] or 'no')
local show_bonus_points = yesno(Args['show_bonus_points'] or 'no')
local pts_perc_first = yesno((rank_points and Args['pts_first']) or ((rank_perc or rank_wperc) and Args['perc_first']) or 'no')
-- Row building
if (tonumber(Args['adjust_points_'..team_code_ii]) and tonumber(Args['startpoints_'..team_code_ii])) then
table.insert(t,'\n')
end
if pts_perc_first then
if rank_points then
-- Add &minus; for negative point totals
if points<0 then
table.insert(t,'| | &minus;'..num_align(-points,digits)..hth_string..'\n')
else
table.insert(t,'| | '..num_align(points,digits)..hth_string..'\n')
end
end
if rank_perc then
table.insert(t,'| | '..win_perc..hth_string..'\n')
elseif rank_wperc then
table.insert(t,'| | '..win_perc..hth_string..'\n')
end
if rank_ppg then
table.insert(t,'| | '..ppg..hth_string..'\n')
end
end
if show_played then
table.insert(t,'| |'..matches_text..'\n') -- Played
end
if full_table then
-- Use actual values if wins, draws, and losses are not numeric
if (wins == 0 and draws == 0 and losses == 0) then
local function numorval(s)
return s and ((s == '' and 0) or tonumber(s) or s) or 0
end
wins = numorval(Args['win_'..team_code_ii])
draws = numorval(Args['draw_'..team_code_ii])
losses = numorval(Args['loss_'..team_code_ii])
end
if show_win then
table.insert(t,'| |'..num_align(wins,digits)..win_string..'\n') -- Won
end  
if loss_first then
if show_loss then
table.insert(t,'| |'..num_align(losses,digits)..'\n') -- Lost
end
if show_draw then
table.insert(t,'| |'..num_align(draws,digits)..'\n') -- Drawn
end
else
if show_draw then
table.insert(t,'| |'..num_align(draws,digits)..'\n') -- Drawn
end
if show_loss then
table.insert(t,'| |'..num_align(losses,digits)..'\n') -- Lost
end
end
if rounds_won then
if tonumber(Args['rw_' .. team_code_ii] or 0) == nil then
rw = Args['rw_' .. team_code_ii] or ''
end
table.insert(t,'| |'..rw..'\n') -- Rounds won
end
if not hide_for_against then
if not yesno(Args['hide_for_against_columns'] or 'no') then
table.insert(t,'| |'..num_align(gfor,digits)..'\n') -- GF
table.insert(t,'| |'..num_align(gaig,digits)..'\n') -- GA
end
if gcomp then
table.insert(t,'| |'..gcomp..'\n') -- Goal comparison
end
end  
end
if show_away_goals then
table.insert(t,'| | '..(Args['away_goals_'..team_code_ii] or '')..'\n')
end
if show_bonus_points then
if s_pts < 0 then
table.insert(t,'| | &minus;'..num_align(-s_pts,digits)..'\n')
else
table.insert(t,'| | '..num_align(s_pts,digits)..'\n')
end
end
if not pts_perc_first then
if rank_points then
-- Add &minus; for negative point totals
if points<0 then
table.insert(t,'| | &minus;'..num_align(-points,digits)..hth_string..'\n')
else
table.insert(t,'| | '..num_align(points,digits)..hth_string..'\n')
end
end
if rank_perc then
table.insert(t,'| | '..win_perc..hth_string..'\n')
elseif rank_wperc then
table.insert(t,'| | '..win_perc..hth_string..'\n')
end
if rank_ppg then
table.insert(t,'| | '..ppg..hth_string..'\n')
end
end
if show_GB then
table.insert(t,'| |'..GB_text..'\n') -- GB
end
return {t=t, notes_exist=notes_exist, hth_id_list=hth_id_list}
end  
function pp.status(Args)
-- Declare status options
-- ------------------------------------------------------------
-- NOTE: If you add to status_code, also add to status_called and status_letters!!
-- Or functionality will be compromised
-- ------------------------------------------------------------
local status_code, status_called = {}, {}
status_code = { A='அடுத்த சுற்றுக்கு முன்னேற்றம்', C='வாகையாளர்', D='தகுதி நீக்கம்',
E='நீக்கம்', G='விருந்தினர்', H='நடத்தும் நாடு', O='Play-off winner', P='Promoted', Q='Qualified for the phase indicated',
R='Relegated', T='Qualified, but not yet for the particular phase indicated'}
local status_letters = (Args['status_order'] or '') .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'  
-- Status position (before or after read and default)
local stat_pos_val = string.lower(Args['status_pos'] or '')
local status_position = 'after' -- Default location
if stat_pos_val=='before' then
status_position = 'before'
elseif stat_pos_val=='after' then
status_position = 'after'
end
-- Read in custom status options
for l in mw.text.gsplit(status_letters, '') do
status_called[l] = false
status_code[l] = status_code[l] or '?'
status_letters = mw.ustring.gsub(status_letters, '(' .. l ..'.-)' .. l, '%1')  
if Args['status_text_' .. l] then
status_code[l] = Args['status_text_' .. l]
end
end  
return {code=status_code, called=status_called, letters=status_letters, position=status_position}
end  
return pp