Module:Sports table/Badminton team: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 32:
show_points = true
end
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'matches'
Line 38 ⟶ 39:
-- First convert to lower case if it is a string
for_against_style = string.lower(for_against_style)
if for_against_style=='gm' or for_against_style=='match' or for_against_style=='matches' then
fa_letter = 'M'
fa_word_sing = 'Match'
Line 49 ⟶ 50:
fa_word_plur = 'Matches'
end
-- Whether to use goal ratio (goal average) instead
local use_ratio_val = Args['use_goal_ratio'] or 'no'
Line 60 ⟶ 62:
-- 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
pfa_letter = 'G'
pfa_word_sing = 'Game'
pfa_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
-- Use points instead of point for/against
local point_for_against_styleuse_ratio_val = Args['point_for_against_styleuse_goal_ratio'] or 'pointsno'
local do_ratio = false
local pfa_letter, pfa_word_sing, pfa_word_plur
-- True if exist, false otherwise
local hide_point_for_against = false
if yesno(use_ratio_val) then do_ratio = true end
-- 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
-- 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 119 ⟶ 151:
tt = p_sub.colhead(tt,28,'<abbr title="'..fa_word_sing..' difference">'..fa_letter..'D</abbr>') -- Difference col
end
if not hide_point_for_againsthide_game_for_against then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_plurgfa_word_plur..' for">'..pfa_lettergfa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_plurgfa_word_plur..' against">'..pfa_lettergfa_letter..'A</abbr>') -- Against col
if do_ratio then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_singgfa_word_sing..' ratio">'..pfa_lettergfa_letter..'R</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_singgfa_word_sing..' percentage">%</abbr>') -- Percentage col
else
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_singgfa_word_sing..' difference">'..pfa_lettergfa_letter..'D</abbr>') -- Difference col
end
if not hide_point_for_against then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_plur..' for">'..pfa_letter..'F</abbr>') -- For col
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_plur..' against">'..pfa_letter..'A</abbr>') -- Against col
if do_ratio then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_sing..' ratio">'..pfa_letter..'R</abbr>') -- Ratio col
elseif do_percentage then
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_sing..' percentage">%</abbr>') -- Percentage col
else
tt = p_sub.colhead(tt,28,'<abbr title="'..pfa_word_sing..' difference">'..pfa_letter..'D</abbr>') -- Difference col
end
end
end
end
Line 218 ⟶ 262:
elseif mcomp < 0 then
mcomp='&minus;'..-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'
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 gaig == 0 then
gcomp = '&mdash;'
else
gcomp = mm._precision_format(gfor / gaig, 3)
end
elseif yesno(use_percentage_val) then
-- Now it is the percentage
if gaig == 0 then
gcomp = '&mdash;'
else
gcomp = mm._precision_format(100 * gfor / gaig , 1)
end
else
-- It's match difference
gcomp = gfor - gaig
-- Formatting with signs
if gcomp>0 then
gcomp='+'..gcomp
elseif gcomp < 0 then
gcomp='&minus;'..-gcomp
end
end
Line 293 ⟶ 367:
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..maig..'\n') -- MA
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..mcomp..'\n') -- Match comparison
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
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..pfor..'\n') -- PF
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..paig..'\n') -- PA