Modulo:TeamBracket: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Moroboshi (discussione | contributi)
Nessun oggetto della modifica
Moroboshi (discussione | contributi)
remake meccanismo addpath e bye intermedi vuoit
Riga 17:
header_third_place = "text-align:center;border:1px solid #aaa;background-color:#f2f2f2",
header_cell = "text-align:center;border:1px solid #aaa;background-color:#f2f2f2",
path1path_bottom = "border:0 solid black;border-rightbottom-width:2px1px;",
path2path_rigth_top = "border:0 solid black;border-top-width:1px;border-right-width:2px;",
path3path_right_bottom = "border:0 solid black;border-bottom-width:1px;border-right-width:2px;",
path_top = "border:0 solid black;border-top-width:2px;",
group = "text-align:center",
winner = {'font-weight' , 'bold'},
Line 35 ⟶ 36:
if debug then
style.group = style.group .. ";background-color:green"
style.path1path_bottom = style.path1path_bottom .. ";background-color:#F08080"
style.path2 path_top= style.path2path_top .. ";background-color:#F08080"
style.path_rigth_top= style.path_rigth_top .. ";background-color:#F08080"
style.path_right_bottom= style.path_right_bottom .. ";background-color:#F08080"
end
 
Line 208 ⟶ 211:
nulli la funzione non disegna niente.
===============================================================================]]
function TeamBracket:addPath(row1, row2, row_gap, col, next_match)
 
if not (row1 or row2) then
local col = self.current_col + self.current_width + 1
self.render_match[self.current_round+1][next_match] = false
local half_gap = row_gap / 2
return
if not (row1 or row2) then return end
else
self.render_match[self.current_round+1][next_match] = true
-- first half
if row1 then
self.rows[row1+1]:tag('td'):cssText(style.path_bottom)
for r = row1+1, row1+3 do self.last_element[r] = col end
for r = row1+4, row1+4+half_gap-1 do self:addGap(r, col, 0, 'ap1') end
self.rows[row1+2]:tag('td')
:attr('rowspan', half_gap + 2)
:cssText(style.path_rigth_top)
end
--second half
if row2 then
self.rows[row2+2]:tag('td'):cssText(style.path_top)
for r = row2, row2+2 do self.last_element[r] = col end
for r = row2-half_gap, row2-1 do self:addGap(r, col, 0, 'ap2') end
self.rows[row2-half_gap]:tag('td')
:attr('rowspan', half_gap+2)
:cssText(style.path_right_bottom)
end
local start_row = row1 and row1 + 2
local end_row = row2
local middle_row
middle_row = (row1 and (row1 + 3 + half_gap)) or (row2 - half_gap - 1)
if start_row then
self:addGap(middle_row, col+1, 0, 'ap3')
if not end_row then
self:addGap(middle_row+1, col+1, 0, 'ap3')
row_gap = row_gap / 2
self.rows[middle_row]:tag('td'):cssText(style.path_bottom)
middle_row = start_row + row_gap - 1
self.rows[middle_row+1]:tag('td'):cssText(style.path_top)
else
middle_row = start_row + row_gap/2 - 1
end
else
row_gap = row_gap / 2
middle_row = end_row - row_gap + 2
end
if start_row then
for i = start_row, middle_row -1 do self:addGap(i, col, 0, 'ap1') end
end
self:addGap(middle_row, col, 1, 'ap2')
if end_row then
for i = middle_row +1, end_row+1 do self:addGap(i, col, 0, 'ap3') end
end
 
local cell = self.rows[start_row or middle_row]
:tag('td')
:attr('rowspan', row_gap)
:cssText(style.path1)
if start_row then cell:css('border-top-width', '2px') end
if end_row then cell:css('border-bottom-width', '2px') end
local cell2 = self.rows[middle_row]:tag('td'):cssText(style.path2)
if start_row then
cell2:css('border-bottom-width', '2px')
else
cell2:css('border-top-width', '2px')
end
end
 
Line 293 ⟶ 285:
-- score_results: risultato degli scores individuali (1: vinto dal primo team, 2 vinto dal secondo, 3 pari)
===============================================================================]]
function TeamBracket:renderTeam(team_name, team_number, row, show_seed, top, winner, score_results, is_bye)
 
self:addGap(row, self.current_col, self.current_width, 'rt')
self:addGap(row+1, self.current_col, self.current_width, 'rt')
-- seed cell
local seedCell
local pos = (top and 1) or 2
local seedArg = self:getTeamArg(self.current_round, 'seed', team_number)
Line 342 ⟶ 333:
if score_results[i] == pos then scoreCell:css(style.winner[1], style.winner[2]) end
end
ifself.not_draw_top = (self.current_round == 1) then self.not_draw_top =and (not self.not_draw_top end)
end
 
Line 351 ⟶ 342:
 
function TeamBracket:renderMatch(match_number, row_base)
 
local function getTeams(team_number1, team_number2)
local team_name1 = self:getTeamArg(self.current_round, 'team', team_number1)
local team_name2 = self:getTeamArg(self.current_round, 'team', team_number2)
if team_name1 == 'bye' or team_name2 == 'bye' or not (team_name1 and team_name2) then
self.not_draw_top = false
return '', '', true
end
return team_name1, team_name2, false
end
 
local team_number2 = match_number * 2
local team_number1 = team_number2 - 1
local team_name1, team_name2, is_bye = self:getTeamArggetTeams(self.current_roundteam_number1, 'team', team_number1team_number2) --or 'bye'
if is_bye then
local team_name2 = self:getTeamArg(self.current_round, 'team', team_number2) --or 'bye'
if team_name1 == 'bye' or team_name2 == 'bye' then
self.not_draw_top = false
if self.render_match[self.current_round][match_number] then
self:addGap(for r = row_base, self.current_col,row_base+4 self.current_width,do 'rm')
self:addGap(row_base+1r, self.current_col, self.current_width, 'rm')
end
self.rows[row_base]:tag('td')
:attr('rowspan', '2')
:attr('colspan', '3'self.current_width +1)
:cssText(style.path_bottom)
--:css('background-color', 'blue')
--:cssTextwikitext(style.path3match_number)
:css('background-color', '#ADD8E6')
:wikitext(match_number)
self.rows[row_base+2]:tag('td')
:attr('rowspan', '2')
:attr('colspan', self.current_width +1)
:cssText(style.path_top)
--:wikitext(match_number)
:css('background-color', '#ADD8E6')
return row_base
end
return nil
end
end
local seedArg1 = self:getTeamArg(self.current_round, 'seed', team_number1)
local showSeed = false
local seedArg2 = self:getTeamArg(self.current_round, 'seed', team_number2)
local showSeed = self.showSeeds
or (seedArg1 and seedArg1 == '-')
or (seedArg2 and seedArg2 == '-')
local winner, score_results = 0, {}
if self.bold_winnernot is_bye then
winner,local score_resultsseedArg1 = self:getWinnergetTeamArg(self.current_round, 'seed', team_number1)
local seedArg2 = self:getTeamArg(self.current_round, 'seed', team_number2)
local showSeed = self.showSeeds
or (seedArg1 and seedArg1 == '-')
or (seedArg2 and seedArg2 == '-')
if self.bold_winner then
winner, score_results = self:getWinner(team_number1)
end
end
self:renderTeam(team_name1, team_number1, row_base, showSeed, true, winner, score_results, is_bye)
self:renderTeam(team_name2, team_number2, row_base+2, showSeed, false, winner, score_results, is_bye)
return row_base
end
Line 461 ⟶ 472:
group_number = group_number + 1
end
self:addPath(match1, match2, gap + 4, self.current_col + self.current_width + 1, (n+1)/2)
row_base = row_base + 2 * gap + 8
end