Content deleted Content added
No edit summary |
MusikBot II (talk | contribs) m Protected "Module:Sports table/Badminton team": High-risk template or module: 270 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite)) |
||
(30 intermediate revisions by 4 users not shown) | |||
Line 8:
-- Create table header
-- Pre stuff
local team_width = Args['teamwidth'] or '
local sort_text = ''
local sort_table_val = Args['sortable_table'] or 'no'
Line 32:
show_points = true
end
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'matches'
local fa_letter, fa_word_sing, fa_word_plur
local show_matches = yesno(Args['show_matches'] or 'yes')
local hide_for_against = false
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if for_against_style=='
fa_letter = 'M'
fa_word_sing = 'Match'
fa_word_plur = 'Matches'
elseif for_against_style=='none' then
hide_for_against = true
Line 53 ⟶ 51:
fa_word_plur = 'Matches'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
Line 64 ⟶ 63:
-- True if exist, false otherwise
if yesno(use_percentage_val) then do_percentage = true end
-- Use points instead of point for/against
local game_for_against_style = Args['game_for_against_style'] or 'games'
local gfa_letter, gfa_word_sing, gfa_word_plur
local hide_game_for_against = false
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if game_for_against_style=='g' or game_for_against_style=='game' or game_for_against_style=='games' then
gfa_letter = 'G'
gfa_word_sing = 'Game'
gfa_word_plur = 'Games'
elseif game_for_against_style=='none' then
hide_game_for_against = true
else
gfa_letter = 'G'
gfa_word_sing = 'Game'
gfa_word_plur = 'Games'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local do_ratio = false
-- True if exist, false otherwise
if yesno(use_ratio_val) then do_ratio = true end
-- Whether to use goal percentage instead
local use_percentage_val = Args['use_goal_percentage'] or 'no'
local do_percentage = false
-- True if exist, false otherwise
if yesno(use_percentage_val) then do_percentage = true end
-- Use points instead of point for/against
local point_for_against_style = Args['point_for_against_style'] or 'points'
local pfa_letter, pfa_word_sing, pfa_word_plur
local hide_point_for_against = false
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if point_for_against_style=='p' or point_for_against_style=='match' or point_for_against_style=='points' then
pfa_letter = 'P'
pfa_word_sing = 'Point'
pfa_word_plur = 'Points'
elseif point_for_against_style=='none' then
hide_point_for_against = true
else
pfa_letter = 'P'
pfa_word_sing = 'Point'
pfa_word_plur = 'Points'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local do_ratio = false
-- True if exist, false otherwise
if yesno(use_ratio_val) then do_ratio = true end
-- Whether to use goal percentage instead
local use_percentage_val = Args['use_goal_percentage'] or 'no'
local do_percentage = false
-- True if exist, false otherwise
if yesno(use_percentage_val) then do_percentage = true end
-- Initialize
Line 70 ⟶ 128:
tt.tab_text = t -- Actual text
-- Actual headers
tt = p_sub.colhead(tt,
-- Add group header
if full_table and group_col then
tt = p_sub.colhead(tt,
end
tt = p_sub.colhead(tt,team_width,team_head_text..VTE_text) -- Team col
tt = p_sub.colhead(tt,
if full_table then
tt = p_sub.colhead(tt,
if loss_first then
tt = p_sub.colhead(tt,
else
tt = p_sub.colhead(tt,20,'<abbr title="Lost">L</abbr>') -- Loss col
end
if not hide_for_against then
if show_matches then
tt = p_sub.colhead(tt,
tt = p_sub.colhead(tt,20,'<abbr title="'..fa_word_plur..' against">'..fa_letter..'A</abbr>') -- Against col
if do_ratio then
tt = p_sub.colhead(tt,20,'<abbr title="'..fa_word_sing..' ratio">'..fa_letter..'R</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,20,'<abbr title="'..fa_word_sing..' percentage">%</abbr>') -- Percentage col
else
tt = p_sub.colhead(tt,20,'<abbr title="'..fa_word_sing..' difference">'..fa_letter..'D</abbr>') -- Difference col
end
end
if not hide_game_for_against then
tt = p_sub.colhead(tt,20,'<abbr title="'..gfa_word_plur..' for">'..gfa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,20,'<abbr title="'..gfa_word_plur..' against">'..gfa_letter..'A</abbr>') -- Against col
if do_ratio then
tt = p_sub.colhead(tt,20,'<abbr title="'..gfa_word_sing..' ratio">'..gfa_letter..'R</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,20,'<abbr title="'..gfa_word_sing..' percentage">%</abbr>') -- Percentage col
else
tt = p_sub.colhead(tt,20,'<abbr title="'..gfa_word_sing..' difference">'..gfa_letter..'D</abbr>') -- Difference col
end
if not hide_point_for_against then
tt = p_sub.colhead(tt,20,'<abbr title="'..pfa_word_plur..' for">'..pfa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,20,'<abbr title="'..pfa_word_plur..' against">'..pfa_letter..'A</abbr>') -- Against col
if do_ratio then
tt = p_sub.colhead(tt,20,'<abbr title="'..pfa_word_sing..' ratio">'..pfa_letter..'R</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,20,'<abbr title="'..pfa_word_sing..' percentage">%</abbr>') -- Percentage col
else
tt = p_sub.colhead(tt,20,'<abbr title="'..pfa_word_sing..' difference">'..pfa_letter..'D</abbr>') -- Difference col
end
end
end
end
end
if show_points then
tt = p_sub.colhead(tt,
elseif show_perc then
tt = p_sub.colhead(tt,36,'<abbr title="Win percentage">PCT</abbr>') -- Win percentage col
Line 126 ⟶ 211:
local mfor = tonumber(Args['mf_'..team_code_ii]) or tonumber(Args['mf_'..team_code_ii]) or 0
local maig = tonumber(Args['ma_'..team_code_ii]) or tonumber(Args['ma_'..team_code_ii]) or 0
local gfor = tonumber(Args['gf_'..team_code_ii]) or tonumber(Args['gf_'..team_code_ii]) or 0
local gaig = tonumber(Args['ga_'..team_code_ii]) or tonumber(Args['ga_'..team_code_ii]) or 0
local pfor = tonumber(Args['pf_'..team_code_ii]) or tonumber(Args['pf_'..team_code_ii]) or 0
local paig = tonumber(Args['pa_'..team_code_ii]) or tonumber(Args['pa_'..team_code_ii]) or 0
local s_pts = tonumber(Args['adjust_points_'..team_code_ii]) or tonumber(Args['startpoints_'..team_code_ii]) or 0
local hth_local = Args['hth_'..team_code_ii] or nil
Line 132 ⟶ 221:
local points = win_points*wins + loss_points*losses + s_pts
local win_perc = ''
if matches == 0 then
-- Escape for zero matches
win_perc = '—'
else
--Some sports use draw as well
win_perc =
if losses > 0 then
-- Drop the leading zero (from the string)
win_perc = string.sub(win_perc,2,string.len(win_perc))
end
end
-- Show for/against
local for_against_style = Args['for_against_style'] or 'goals'
local show_matches = yesno(Args['show_matches'] or 'yes')
local hide_for_against = false
for_against_style = string.lower(for_against_style)
Line 151 ⟶ 244:
-- Comparison of for against
local
-- Whether to use goal ratio (goal average) or goal percentage instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local use_percentage_val = Args['use_goal_percentage'] or 'no'
local skip_sign
if yesno(use_ratio_val) then
-- Now it is the goal ratio/goal average
if maig == 0 then
mcomp = '—'
else
mcomp = mm._precision_format(gfor / gaig, 3)
end
elseif yesno(use_percentage_val) then
-- Now it is the percentage
if maig == 0 then
mcomp = '—'
else
mcomp = mm._precision_format(100 * gfor / gaig , 1)
end
else
-- It's match difference
mcomp = mfor - maig
-- Formatting with signs
if mcomp>0 then
mcomp='+'..mcomp
elseif mcomp < 0 then
mcomp='−'..-mcomp
end
end
local gcomp
-- Whether to use goal ratio (goal average) or goal percentage instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
Line 172 ⟶ 295:
else
-- It's match difference
-- Formatting with signs
if
elseif
end
end
local pcomp
-- Whether to use goal ratio (goal average) or goal percentage instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
local use_percentage_val = Args['use_goal_percentage'] or 'no'
local skip_sign
if yesno(use_ratio_val) then
-- Now it is the goal ratio/goal average
if paig == 0 then
pcomp = '—'
else
pcomp = mm._precision_format(gfor / gaig, 3)
end
elseif yesno(use_percentage_val) then
-- Now it is the percentage
if paig == 0 then
pcomp = '—'
else
pcomp = mm._precision_format(100 * gfor / gaig , 1)
end
else
-- It's match difference
pcomp = pfor - paig
-- Formatting with signs
if pcomp>0 then
pcomp='+'..pcomp
elseif pcomp < 0 then
pcomp='−'..-pcomp
end
end
-- Some local vars
local hth_string
Line 215 ⟶ 367:
if loss_first then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') -- Lost
else
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') -- Lost
end
if not hide_for_against then
if show_matches then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..mcomp..'\n') -- Match comparison
end
if Args['game_for_against_style'] ~= 'none' then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gfor..'\n') -- GF
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gaig..'\n') -- GA
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..gcomp..'\n') -- Game comparison
if Args['point_for_against_style'] ~= 'none' then -- game param hides games and points in header
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..pfor..'\n') -- PF
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..paig..'\n') -- PA
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..pcomp..'\n') -- Point comparison
end
end
end
|