Content deleted Content added
No edit summary |
Sports2021 (talk | contribs) mNo edit summary |
||
(28 intermediate revisions by 2 users not shown) | |||
Line 9:
-- Pre stuff
local team_width = Args['teamwidth'] or '190'
local group_width = Args['groupwidth'] or '28'
local score_width = Args['scorewidth'] or '28'
local sort_text = yesno(Args['sortable_table'] or 'no') and ' sortable' or ''
local show_played = not yesno(Args['hide_played'] or 'no')
Line 19 ⟶ 21:
-- Custom header options
local played_head_text = Args['pld_header'] or '<abbr title="Played">Pld</abbr>'
local
local group_head_text = Args['group_header'] or '<abbr title="Group">Grp</abbr>'
local team_head_text = Args['team_header'] or 'Team'
local bonus_head_text = Args['bonus_header'] or '<abbr title="Bonus points">BP</abbr>'
local loss_first = Args['
-- What to rank the teams by
local ranking_style = Args['ranking_style'] or 'perc'
Line 42 ⟶ 44:
end
local show_bonus_points = yesno(Args['show_bonus_points'] or 'no')
local
-- Use points instead of goals for/against
local for_against_style = Args['for_against_style'] or 'goals'
Line 78 ⟶ 80:
local do_scored = yesno(Args['use_goals_scored'] or 'no')
-- Whether to show totals instead of
local only_totals = yesno(Args['only_totals'] or 'no')
-- Whether to show totals instead of conference and overall
local only_conference = yesno(Args['only_conference'] or 'no')
-- Whether to show for against/totals instead of home/away for/against
Line 88 ⟶ 93:
-- Spacer style
local sps = only_totals and '' or only_conference and '' or ' style="border-width:1px 1px 1px 3px;"'
-- Initialize
Line 100 ⟶ 105:
-- 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
if show_played then
tt = p_sub.colhead(tt,
end
if full_table then
local lbls = only_totals and {{'', 'Total '}} or only_conference and {{'', 'Conference '}} or {{'C', 'Conference '}, {'', 'Total '}}
for k,v in ipairs(lbls) do
local apre, tpre = v[1], v[2]
tt = p_sub.colhead(tt,
if loss_first then
tt = p_sub.colhead(tt,
if
tt = p_sub.colhead(tt,
end
else
if
tt = p_sub.colhead(tt,
end
tt = p_sub.colhead(tt,
end
if rounds_won then
tt = p_sub.colhead(tt,
end
if not hide_for_against and not only_fa_totals then
tt = p_sub.colhead(tt,
tt = p_sub.colhead(tt,
end
if show_perc then
Line 135 ⟶ 140:
tt = p_sub.colhead(tt,36,'<abbr title="'..tpre..'win percentage">'..apre..'PCT</abbr>')
end
tt = p_sub.colhead(tt,28,'<abbr title="Games behind">GB</abbr>')▼
end
end
Line 156 ⟶ 164:
end
end
▲ end
▲ if show_GB then -- Games behind header
▲ tt = p_sub.colhead(tt,28,'<abbr title="Games behind">GB</abbr>')
end
if show_bonus_points then
Line 184 ⟶ 189:
local cwin_points = tonumber(Args['cwinpoints']) or tonumber(Args['winpoints']) or 3
local ncwin_points = tonumber(Args['ncwinpoints']) or tonumber(Args['winpoints']) or 3
local
local loss_points = tonumber(Args['losspoints']) or 0
local rw_points = tonumber(Args['rwpoints']) or 1
-- Order of
local loss_first = Args['
-- Optional rounds won
Line 195 ⟶ 200:
-- Get some input
local cwins = (tonumber(Args['cwin_'..team_code_ii]) or 0)
local ncwins = (tonumber(Args['ncwin_'..team_code_ii]) or 0)
local wins = cwins + ncwins
local
local
local
local closses = (tonumber(Args['closs_'..team_code_ii]) or 0)
local nclosses = (tonumber(Args['ncloss_'..team_code_ii]) or 0)
local losses = closses + nclosses
local crw = (tonumber(Args['crw_'..team_code_ii]) or 0)
local ncrw = (tonumber(Args['ncrw_'..team_code_ii]) or 0)
local rw = crw + ncrw
Line 225 ⟶ 230:
local hth_local = Args['hth_'..team_code_ii] or nil
-- Then calculate some values
local matches = wins +
if yesno(Args['only_conference'] or 'no') then
local points = cwin_points*cwins + ncwin_points*ncwins + draw_points*draws + loss_points*losses + rw_points*rw + s_pts▼
matches = cwins + cties + closses
end▼
▲ local points = cwin_points*cwins + ncwin_points*ncwins +
if Args['goalpoints'] and tonumber(gfor) then
points = points + (tonumber(Args['goalpoints']) or 1)*tonumber(gfor)
end
local
▲ end
local win_perc = ''
local cwin_perc = ''
local include_ties = yesno(Args['include_ties'] or 'yes')
if tonumber(matches) == nil or matches == 0 then
-- Escape for zero matches
win_perc = '—'
else
--Some sports use
if include_ties then
win_perc = mm._precision_format((2*wins +
else
if losses > 0 then
-- Drop the leading zero (from the string)
Line 251 ⟶ 259:
end
end
if tonumber(cwins+closses) == nil or (cwins+closses+
-- Escape for zero matches
cwin_perc = '—'
else
--Some sports use
if include_ties then
▲ cwin_perc = mm._precision_format((2*cwins + cdraws) / (2*(cwins+cdraws+closses)), 3)
cwin_perc = mm._precision_format((2*cwins + cties) / (2*(cwins+cties+closses)), 3)
else
cwin_perc = mm._precision_format(cwins / (cwins+closses), 3)
end
if closses > 0 then
-- Drop the leading zero (from the string)
Line 325 ⟶ 337:
-- Do nothing, it's vs this team
else
local wins_GB = (tonumber(Args['cwin_'..team_list[GB_team_no]]) or 0)
local local
▲ local GB_num = (wins_GB-wins+losses-losses_GB)/2 + (draws_GB - draws)
-- Display options
if GB_num >0 then
Line 379 ⟶ 391:
-- Whether to show totals instead of home and away
local only_totals = yesno(Args['only_totals'] or 'no')
-- Whether to show totals instead of home and away
local only_conference = yesno(Args['only_conference'] or 'no')
-- Spacer style
local sps = only_totals and '' or only_conference and '' or 'border-width:1px 1px 1px 3px;'
-- Row building
if show_played then
Line 386 ⟶ 400:
end
if full_table then
-- Use actual values if wins,
if (cwins == 0 and ncwins == 0 and
local function numorval(s)
return s and ((s == '' and 0) or tonumber(s) or s) or 0
Line 393 ⟶ 407:
cwins = numorval(Args['cwin_'..team_code_ii])
ncwins = numorval(Args['ncwin_'..team_code_ii])
closses = numorval(Args['closs_'..team_code_ii])
nclosses = numorval(Args['ncloss_'..team_code_ii])
end
local stats = only_totals and {{wins, ties, losses, rw, gfor, gaig}} or
only_conference and {{
{{cwins,
local first_pass = true
for k,v in ipairs(stats) do
table.insert(t,'| style="'..sps..win_fw..bg_col..'" |'..(v[1])..win_string..'\n') -- Won
Line 406 ⟶ 421:
if loss_first then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(v[3])..'\n') -- Lost
if
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(v[2])..'\n') --
end
else
if
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(v[2])..'\n') --
end
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(v[3])..'\n') -- Lost
Line 423 ⟶ 438:
end
if rank_perc then
if first_pass then
table.insert(t,'| style="font-weight: bold;'..bg_col..'" | '..(v[7])..hth_string..'\n')
else
end
end
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..GB_text..'\n') -- GB
end
first_pass = false
end
if not hide_for_against then
Line 435 ⟶ 458:
table.insert(t,'| style="'..lsps..ii_fw..bg_col..'" |'..gcomp..'\n') -- Goal comparison
end
▲ end
▲ if show_GB then
▲ table.insert(t,'| style="'..ii_fw..bg_col..'" |'..GB_text..'\n') -- GB
end
if show_bonus_points then
Line 466 ⟶ 485:
local status_code, status_called = {}, {}
status_code = { A='Advance to a further round', C='Champion', D='Disqualified',
E='Eliminated', G='Guest', H='Host', O='Play-off winner', P='Promoted', Q='Qualified
R='Relegated', T='Qualified, but not yet
local status_letters = (Args['status_order'] or '') .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|