Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(match2): support postponed #5174

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion components/match2/commons/match_group_display_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function DisplayHelper.MatchCountdownBlock(match)

local stream = Table.merge(match.stream, {
date = dateString,
finished = match.finished and 'true' or nil,
finished = (match.finished or match.status == 'postponed') and 'true' or nil,
})
return mw.html.create('div'):addClass('match-countdown-block')
:css('text-align', 'center')
Expand Down
16 changes: 16 additions & 0 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ MatchGroupInputUtil.STATUS.SCORE = 'S'

MatchGroupInputUtil.MATCH_STATUS = {
NOT_PLAYED = 'notplayed',
POSTPONED = 'postponed',
}

MatchGroupInputUtil.SCORE_NOT_PLAYED = -1
Expand Down Expand Up @@ -603,12 +604,21 @@ function MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput)
or (type(finishedInput) == 'string' and MatchGroupInputUtil.isNotPlayedInput(finishedInput))
end

---@param winnerInput integer|string|nil
---@param finishedInput string?
---@return boolean
function MatchGroupInputUtil.isPostponed(winnerInput, finishedInput)
return winnerInput == 'postponed' or finishedInput == 'postponed'
end

---@param winnerInput integer|string|nil
---@param finishedInput string?
---@return string? #Match Status
function MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput)
if MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput) then
return MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED
elseif MatchGroupInputUtil.isPostponed(winnerInput, finishedInput) then
return MatchGroupInputUtil.MATCH_STATUS.POSTPONED
end
end

Expand Down Expand Up @@ -813,6 +823,8 @@ end
function MatchGroupInputUtil.matchIsFinished(match, opponents)
if MatchGroupInputUtil.isNotPlayed(match.winner, match.finished) then
return true
elseif MatchGroupInputUtil.isPostponed(match.winner, match.finished) then
return false
end

local finished = Logic.readBoolOrNil(match.finished)
Expand Down Expand Up @@ -1141,6 +1153,8 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser, FfaParser, mapP
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex)
end)
elseif MatchGroupInputUtil.isPostponed(matchInput.winner, matchInput.finished) then
match.status = MatchGroupInputUtil.getMatchStatus(matchInput.winner, matchInput.finished)
end

match.mode = Parser.getMode and Parser.getMode(opponents)
Expand Down Expand Up @@ -1333,6 +1347,8 @@ function MatchGroupInputUtil.standardProcessFfaMatch(match, Parser, mapProps)

match.winner = Parser.getMatchWinner and Parser.getMatchWinner(match.status, winnerInput, opponents)
or MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents)
elseif MatchGroupInputUtil.isPostponed(winnerInput, finishedInput) then
match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput)
end

match.mode = Parser.getMode and Parser.getMode(opponents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ function CustomMatchGroupInput.processMatch(match, options)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex)
end)
elseif MatchGroupInputUtil.isPostponed(winnerInput, finishedInput) then
match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput)
end

match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team'))
match.publishertier = Logic.emptyOr(match.publishertier, Variables.varDefault('tournament_valve_tier'))
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))
Expand Down Expand Up @@ -210,7 +211,7 @@ end
function MatchFunctions.getExtraData(match, opponents, finishedInput)
return {
mapveto = MatchGroupInputUtil.getMapVeto(match),
status = match.status == MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED and finishedInput or nil,
status = match.status == MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED and finishedInput or match.status,
overturned = Logic.isNotEmpty(match.overturned),
featured = MatchFunctions.isFeatured(match, opponents),
hidden = Logic.readBool(Variables.varDefault('match_hidden'))
Expand Down