Module:Sports table/WDL: Difference between revisions

Content deleted Content added
should fix latest error
fix inconsistent use of ranking_style=='wpct' or ranking_style=='%w' which was causing strange results when either was uses
 
(8 intermediate revisions by 3 users not shown)
Line 32:
if ranking_style=='w' or ranking_style=='win' or ranking_style=='wins' or ranking_style=='none' then
-- Based on wins
elseif ranking_style=='wperc' or ranking_style=='win percentage' or ranking_style=='wpct' or ranking_style=='%w' then
show_wperc = true
elseif ranking_style=='perc' or ranking_style=='percentage' or ranking_style=='%' then
Line 91:
fa_letter = 'R'
fa_word_sing = 'Run'
fa_word_plur = 'Runs'
elseif for_against_style=='l' or for_against_style=='leg' or for_against_style=='legs' then
fa_letter = 'L'
fa_word_sing = 'Leg'
fa_word_plur = 'Legs'
elseif for_against_style=='none' then
hide_for_against = true
Line 104 ⟶ 108:
 
-- Whether to use goal percentage instead
local do_percentage = yesno(Args['use_goal_percentage'] or Args['use_against_percentage'] or Args['use_point_percentage'] or 'no')
local do_point_for_avg = yesno(Args['use_goals_per_match'] or Args['use_points_per_match'] or 'no')
Line 274 ⟶ 278:
local hth_local = yesno(Args['show_hth'] or 'yes') and Args['hth_'..team_code_ii] or nil
local ranking_style = string.lower(Args['ranking_style'] or 'pts')
local pct_style = string.lower(Args['pct_style'] or 'ratio')
 
-- Then calculate some values
Line 297 ⟶ 302:
else
--Some sports use draw as well
win_perc = (pct_style == 'ratio') and
mm._precision_format((2*wins + draws + s_pts) / (2*matches), 3) or
mm._precision_format(100*(2*wins + draws + s_pts) / (2*matches), 2)
-- Allow win_perc to be altered due to point deductions/additions
ppg = mm._precision_format(points / matches, 2)
if (losses > 0 or draws > 0) and pct_style == 'ratio' then
-- Drop the leading zero (from the string)
win_perc = string.sub(win_perc,2,string.len(win_perc))
end
end
if ranking_style=='wperc' or ranking_style=='win percentage' or ranking_style=='wpct' or ranking_style=='%w' then
if matches == 0 then
win_perc = '—'
Line 337 ⟶ 345:
else
gcomp = mm._precision_format(100 * gfor / gaig , 1)
end
elseif yesno(Args['use_against_percentage'] or 'no') then
-- Now it is the percentage
if (gfor == '?') or (gaig == '?') or gfor == 0 then
gcomp = '—'
else
gcomp = mm._precision_format(100 * gaig / gfor , 1)
end
elseif yesno(Args['use_point_percentage'] or 'no') then
Line 414 ⟶ 429:
win_fw=ii_fw
win_string = ''
elseif ranking_style=='wperc' or ranking_style=='win percentage' or ranking_style=='wpct' or ranking_style=='%w' then
-- Based on percentage
rank_wperc = true
Line 561 ⟶ 576:
-- ------------------------------------------------------------
local status_code, status_called = {}, {}
status_code = { A='Advance to a further round', C='ChampionChampions', D='Disqualified',
E='Eliminated', G='GuestGuests', H='HostHosts', O='Play-off winnerwinners', P='Promoted', Q='Qualified tofor the phase indicated',
R='Relegated', T='Qualified, but not yet tofor the particular phase indicated'}
local status_letters = (Args['status_order'] or '') .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'