Content deleted Content added
S.A. Julio (talk | contribs) improve logic |
S.A. Julio (talk | contribs) allow for manual coloring of aggregate cell when legs=0 |
||
Line 77:
-- Function to determine the winner based on scores within parentheses (first) or regular format (second)
local function determineWinner(cleanScore, matchType, team1, team2, boldWinner, colorWinner, aggregate, isFBRStyle)
local team1Winner, team2Winner = false, false
local score1, score2
Line 111:
manualColor2 = team2:find("''") and not (team2:gsub("''", ""):match("^%s*$"))
team2 = team2:gsub("''", "")
end
if aggregate then
manualColorDraw = aggregate:find("''") and not (aggregate:gsub("''", ""):match("^%s*$"))
aggregate = aggregate:gsub("''", "")
end
Line 123 ⟶ 127:
team2Winner = true
end
manualColor = true
end
if manualColorDraw then
isDraw = true
manualColor = true
end
-- 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 or isFBRStyle) then
local parenthetical = cleanScore:match('%((%d+%-+%d+)%)')
local outsideParenthetical = cleanScore:match('^(%d+%-+%d+)')
Line 139 ⟶ 147:
team1Winner = tonumber(score1) > tonumber(score2)
team2Winner = tonumber(score1) < tonumber(score2)
isDraw = tonumber(score1) == tonumber(score2)
end
end
end
return team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregate
end
Line 377 ⟶ 387:
local cleanAggregate = cleanScore(aggregateScore)
-- Determine the winning team on aggregate
team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, matchType, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle)
-- 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;'
Line 401 ⟶ 411:
-- Create aggregate score cell with conditional styling
local aggregateStyle = 'text-align: center;'
if legs == 0 or manualColor then
if isFBRStyle and legs == 0 then
if team1Winner then
aggregateStyle = aggregateStyle .. '; background-color: #BBF3FF;'
Line 410 ⟶ 420:
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
elseif isDraw
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
Line 433 ⟶ 443:
local cleanAggregate = cleanScore(aggregateScore)
-- Determine the winning team on aggregate
team1, team2, team1Winner, team2Winner, manualBold, manualColor, isDraw, aggregateScore = determineWinner(cleanAggregate, matchType, team1, team2, boldWinner, colorWinner, aggregateScore, isFBRStyle)
-- 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;'
Line 453 ⟶ 463:
-- Create aggregate score cell with conditional styling
local aggregateStyle = 'text-align: center;'
if legs == 0 or manualColor then
if isFBRStyle and legs == 0 then
if team1Winner then
aggregateStyle = aggregateStyle .. '; background-color: #BBF3FF;'
Line 462 ⟶ 472:
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
elseif isDraw
aggregateStyle = aggregateStyle .. '; background-color: #FFFFBB;'
end
|