Content deleted Content added
No edit summary |
added argument sb_before_w |
||
(21 intermediate revisions by 3 users not shown) | |||
Line 2:
local pp = {}
function pp.preprocess(Args,N_teams,prefix,drawfractions)
local legs = 1
for ii=1,N_teams do
Line 26:
elseif gii == '½' then
Args[prefix..'draw_'..ti] = Args[prefix..'draw_'..ti] + 1
gii = mw.getCurrentFrame():extensionTag{
-- gii = '<span class="visualhide"> </span><sup>1</sup>⁄<sub>2</sub>'▼
name = 'templatestyles', args = { src = 'Screen reader-only/styles.css' }
--end▼
elseif gii == '0' then
Args[prefix..'loss_'..ti] = Args[prefix..'loss_'..ti] + 1
Line 58 ⟶ 60:
local sort_text = ''
local sort_table_val = Args['sortable_table'] or 'no'
if yesno(sort_table_val) then sort_text = ' sortable' end
-- Open table
table.insert(t,'{|class="wikitable -- if Args['title'] or Args['table_header'] then
table.insert(t,'|+ ' .. (Args['title'] or Args['table_header']) .. '\n')
-- Preprocess match data
local top_pos = tonumber(Args['highest_pos']) or 1
local N_teams = top_pos - 1 -- Default to 0 at start, but higher number needed to skip certain entries
while Args['team'..N_teams+1] ~= nil do N_teams = N_teams+1 end
pp.preprocess(Args,N_teams,'',yesno(Args['crosstable_fractions'] or 'no'))
local tb_numplayers = tonumber(Args['tb_numplayers']) or 0
if tb_numplayers > N_teams then
Line 71 ⟶ 78:
end
if tb_numplayers >= 2 then
pp.preprocess(Args,tb_numplayers,'tb',yesno(Args['crosstable_fractions'] or 'no'))
end
-- Which columns to show
Line 81 ⟶ 88:
local show_draw = yesno(Args['show_draw'] or 'no')
local show_loss = yesno(Args['show_loss'] or 'no')
local show_sb = yesno(Args['show_sb'] or 'no')
▲ local show_tpr = yesno(Args['show_tpr'] or 'no')
local extra_cols = tonumber(Args['extra_cols']) or 0
-- Custom header options
Line 93 ⟶ 100:
tt.tab_text = t -- Actual text
-- Actual headers
if pos_label ~= nil then
tt = p_sub.colhead(tt,28,pos_label) -- Add group header
if full_table and group_col then
Line 99 ⟶ 108:
end
tt = p_sub.colhead(tt,player_width,player_head_text..VTE_text) -- Player col
if full_table and
local rate_date = Args['rate_date'] or ''
tt = p_sub.colhead(tt,28, '[[FIDE world rankings|Rating]]<br/><small><span style="white-space:nowrap">'..rate_date..'</span></small>')
end
if show_played then
tt = p_sub.colhead(tt,28, '<abbr title="Games Played">Pld</abbr>')
end
tt = p_sub.colhead(tt,28, '
if full_table then
if show_hth and hth_first then
tt = p_sub.colhead(tt,28, '<abbr title="Head-to-head">H2H</abbr>') -- Head-to-head col
if show_sb and sb_first then
tt = p_sub.colhead(tt,28, '<abbr title="
end
if show_win then
Line 123 ⟶ 135:
tt = p_sub.colhead(tt,28, '<abbr title="Head-to-head">H2H</abbr>') -- Head-to-head col if not first tiebreak
end
if show_sb and not sb_first then
tt = p_sub.colhead(tt,28, '<abbr title="Sonneborn–Berger score">[[
end
for ecol=1,extra_cols do
local
tt = p_sub.colhead(tt,28,extra_head_text)
▲ end
if show_tpr then▼
▲ tt = p_sub.colhead(tt,28, '<abbr title="Tournament performance rating">[[Glossary of chess#performance rating|TPR]]</abbr>')
end
tt.count = tt.count+1
Line 160 ⟶ 168:
local show_rating = yesno(Args['show_rating'] or 'no')
local show_played = not yesno(Args['hide_played'] or 'no')
local score_over_played = yesno(Args['score_over_played'] or 'no')
local hth_first = yesno(Args['hth_before_w'] or 'yes')
local show_hth = yesno(Args['show_hth'] or 'yes')
Line 165 ⟶ 174:
local show_draw = yesno(Args['show_draw'] or 'no')
local show_loss = yesno(Args['show_loss'] or 'no')
local wdl_iff_hth = yesno(Args['wdl_iff_hth'] or 'no')
local sb_first = yesno(Args['sb_before_w'] or 'no')
local show_sb = yesno(Args['show_sb'] or 'no')
local
local
local disp_fractions = yesno(Args['disp_fractions'] or 'yes')
-- Then calculate some values
Line 174 ⟶ 186:
local sb_score = 0
local templatestyles = mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Screen reader-only/styles.css' }
}
hth_local = mw.ustring.gsub(hth_local, '%s*½', '.5')
if hth_local == '' then
Line 181 ⟶ 196:
if math.floor(hth_local) ~= hth_local then
if math.floor(hth_local) > 0 then
hth_local = math.floor(hth_local) .. templatestyles .. '<span class="
else
hth_local = templatestyles .. '<span class="
▲ end
if hth_local < 0 then▼
hth_local = '—'▼
end
end
end
if
points = '<span style="white-space:nowrap">' .. points .. ' / ' .. matches .. '</span>'
elseif disp_fractions then
if math.floor(points) ~= points then
if math.floor(points) > 0 then
points = math.floor(points) .. templatestyles .. '<span class="
else
points = templatestyles .. '<span class="
end
end
end
--
if show_sb then
if (sb_iff_hth and hth_local == '—') or nosb then
▲ local legs = tonumber(Args['legs']) or 1
sb_score = '—'
for jj=1,N_teams do▼
end
local tj = Args['team' .. jj]▼
local tjpoints = win_points*Args['win_'..tj] + draw_points*Args['draw_'..tj] + loss_points*Args['loss_'..tj]▼
local legs = tonumber(Args['legs']) or 1
if ii ~= jj then▼
▲ for jj=1,N_teams do
local match_str = Args['match_' .. team_code_ii .. '_' .. tj] or ''▼
▲ local tj = Args['team' .. jj]
for l=1,legs do▼
▲ local tjpoints = win_points*Args['win_'..tj] + draw_points*Args['draw_'..tj] + loss_points*Args['loss_'..tj]
local gii = mw.ustring.match(match_str, '^%s*([^%+%s]*)%s*%+?')▼
▲ local match_str = Args['match_' .. team_code_ii .. '_' .. tj] or ''
sb_score = sb_score + win_points*tjpoints▼
▲ local gii = mw.ustring.match(match_str, '^%s*([^%+%s]*)%s*%+?')
sb_score = sb_score + draw_points*tjpoints▼
sb_score = sb_score +
elseif gii == '½' then
end
match_str = mw.ustring.gsub(match_str, '^%s*([^%+%s]*)%s*%+?', '') or ''▼
end
▲ match_str = mw.ustring.gsub(match_str, '^%s*([^%+%s]*)%s*%+?', '') or ''
end
end
Line 244 ⟶ 262:
if show_hth and hth_first then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(hth_local or '')..'\n') -- Head-to-head
end
if show_sb and sb_first then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..
end
if show_win then
end
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..wins..'\n') -- Won
end
if show_draw then
if wdl_iff_hth and hth_local == '—' then
draws = '—'
end
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..draws..'\n') -- Drew
end
if show_loss then
if wdl_iff_hth and hth_local == '—' then
losses = '—'
end
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..losses..'\n') -- Lost
end
Line 257 ⟶ 287:
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..(hth_local or '')..'\n') -- Head-to-head if not first tiebreak
end
if show_sb and not sb_first then
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..sb_score..'\n') --
end
local extraii = Args['
table.insert(t,'| style="'..ii_fw..bg_col..'" |'..extraii..'\n') -- Extra
▲ end
▲ local tprii = Args['tpr_'..team_code_ii] or ''
▲ table.insert(t,'| style="'..ii_fw..bg_col..'" |'..tprii..'\n') -- Performance rating
end
end
|