Modul:Sports series: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
opsi pewarnaan agregat untuk leg=0 |
opsi penentuan pemenang dengan peraturan gol tandang |
||
Baris 8:
return frame:expandTemplate{ title = templateName, args = params }
end
-- Function to check the existence of template passed via |flag=
local function templateExists(templateName)
local title = mw.title.new('Templat:' .. templateName)
Baris 73:
-- Function to determine the winner based on scores within parentheses (first) or regular format (second)
local function determineWinner(
local team1Winner, team2Winner = false, false
local score1, score2
Baris 99:
end
-- Handling for manual coloring of team or aggregate cells
if team1 and type(team1) == 'string' then
manualColor1 = team1:find("''") and not (team1:gsub("''", ""):match("^%s*$"))
Baris 110:
if aggregate then
if aggregate:find("'''") then
aggregate = aggregate:gsub("'''", "")
aggregate = "<strong>" .. aggregate .. "</strong>"
manualColorDraw = aggregate:find("''") and not (aggregate:gsub("''", ""):match("^%s*$"))
aggregate = aggregate:gsub("''", "")
Baris 132 ⟶ 136:
-- Regular winner determination logic if manual bolding or coloring is not conclusive
if not team1Winner and not team2Winner and not isDraw and (boldWinner or colorWinner) then
local parenthetical =
local outsideParenthetical =
if parenthetical then -- Prioritize checking score inside parenthetical
score1, score2 = parenthetical:match('(%d+)%-+(%d+)')
elseif outsideParenthetical then
Baris 141 ⟶ 145:
if score1 and score2 then
team2Winner = tonumber(score1) < tonumber(score2)▼
elseif score1 == score2 and legs == 2 and not disableAwayGoals then
-- Apply away goals rule
local cleanLeg1 = cleanScore(leg1Score):gsub('[()]', '')
local cleanLeg2 = cleanScore(leg2Score):gsub('[()]', '')
local _, team2AwayGoals = cleanLeg1:match('(%d+)%-+(%d+)')
local team1AwayGoals = cleanLeg2:match('(%d+)%-+(%d+)')
if team1AwayGoals and team2AwayGoals then
team1AwayGoals, team2AwayGoals = tonumber(team1AwayGoals), tonumber(team2AwayGoals)
team1Winner = true
team2Winner = true
end
if (colorWinner or isFBRStyle) and legs == 0 then
isDraw = not team1Winner and not team2Winner
end
end
end
Baris 162 ⟶ 189:
end
-- Function to add a legend to below the table when |matches_style=FBR
local function createFBRLegend()
return mw.html.create('div')
Baris 189 ⟶ 217:
local fillBlanks = args.fill_blanks and (args.fill_blanks == 'y' or args.fill_blanks == 'yes' or args.fill_blanks == '1' or args.fill_blanks == 'true')
-- Process the font size parameter
local size
if args.size then
Baris 244 ⟶ 272:
local isFBRStyle = matchesStyle and matchesStyle:upper() == "FBR"
local isHA = args.h_a == 'y' or args.h_a == 'yes' or args.h_a == '1' or args.h_a == 'true'
local disableAwayGoals = args.away_goals == 'n' or args.away_goals == 'no' or args.away_goals == '0' or args.away_goals == 'false' or args.away_goals == 'null'
local tableClass = 'wikitable'
Baris 359 ⟶ 388:
local team1, aggregateScore, team2
local team1Winner, team2Winner, manualBold, manualColor, isDraw = false, false, false, false, false
local leg1Score, leg2Score = false, false
local team1Asterick, team2Asterick = false, false
Baris 382 ⟶ 412:
-- Clean the aggregate score
local cleanAggregate = cleanScore(aggregateScore)
-- Name the 1st/2nd leg scores for two-legged ties for possibly determining the winner on away goals
leg1Score = args[i+3]
leg2Score = args[i+4]
end
-- Determine the winning team on aggregate
team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, matchType, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle, legs, leg1Score, leg2Score, disableAwayGoals)
-- Add background-color for winning team if set by user
local team1Style = team1Winner and ((colorWinner or manualColor) and 'background-color: #CCFFCC;' or '') .. 'text-align: right;' or 'text-align: right;'
Baris 406 ⟶ 441:
end
-- Create aggregate score cell with conditional styling
▲ if team1Winner then
elseif team2Winner then
▲ aggregateStyle = aggregateStyle .. '; background-color: #BBF3FF;'
▲ elseif team2Winner then
aggregateStyle = aggregateStyle .. '; background-color: # elseif isDraw then ▲ elseif isDraw then
▲ aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
▲ end
▲ end
-- Create rows for aggregate score and team names, bolded if set by user
row:tag('td'):cssText(team1Style):wikitext((team1Winner and (boldWinner or manualBold) and team1Text ~= '') and ('<strong>' .. team1Text .. '</strong>') or team1Text)
Baris 438 ⟶ 471:
-- Clean the aggregate score
local cleanAggregate = cleanScore(aggregateScore)
-- Name the 1st/2nd leg scores for two-legged ties for possibly determining the winner on away goals
if legs == 2 then
if noFlagIcons then
leg1Score = args[i+3]
leg2Score = args[i+4]
else
leg1Score = args[i+5]
leg2Score = args[i+6]
end
end
-- Determine the winning team on aggregate
team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, matchType, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle, legs, leg1Score, leg2Score, disableAwayGoals)
-- Add background-color for winning team if set by user
local team1Style = team1Winner and ((colorWinner or manualColor) and 'background-color: #CCFFCC;' or '') .. 'text-align: right;' or 'text-align: right;'
Baris 459 ⟶ 502:
-- Create aggregate score cell with conditional styling
local aggregateStyle = 'text-align: center;'
if isFBRStyle and legs == 0
▲ if team1Winner then
▲ elseif team2Winner then
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
▲ elseif isDraw then
end
▲ aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
▲ elseif isDraw then
▲ aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
▲ end
end
-- Create rows for aggregate score and team names, bolded if set by user
|