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

fix(match2): tournament_status is not working #4881

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions components/match2/wikis/counterstrike/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ local CustomMatchGroupInput = {}
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local finishedInput = match.finished --[[@as string?]]
---@type string
local finishedInput = tostring(Logic.nilOr(
Logic.readBoolOrNil(match.finished),
Variables.varDefault('tournament_status'),
match.finished,
''
))
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved
local winnerInput = match.winner --[[@as string?]]

Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date))
Expand Down Expand Up @@ -76,7 +82,6 @@ function CustomMatchGroupInput.processMatch(match, options)

match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team'))
match.publishertier = Logic.emptyOr(match.publishertier, Variables.varDefault('tournament_valve_tier'))
match.status = Logic.emptyOr(match.status, Variables.varDefault('tournament_status'))
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

match.stream = Streams.processStreams(match)
Expand All @@ -85,7 +90,7 @@ function CustomMatchGroupInput.processMatch(match, options)
match.games = games
match.opponents = opponents

match.extradata = MatchFunctions.getExtraData(match, opponents)
match.extradata = MatchFunctions.getExtraData(match, opponents, finishedInput)

return match
end
Expand Down Expand Up @@ -198,14 +203,6 @@ function MatchFunctions.getLinks(match, maps)
end)
end

---@param match table
---@return string?
function MatchFunctions.getMatchStatus(match)
if match.resulttype == 'np' then
return Logic.emptyOr(match.status, Variables.varDefault('tournament_status'))
end
end

---@param name string?
---@param year string|osdate
---@return number
Expand Down Expand Up @@ -249,11 +246,12 @@ end

---@param match table
---@param opponents table[]
---@param finishedInput string
---@return table
function MatchFunctions.getExtraData(match, opponents)
function MatchFunctions.getExtraData(match, opponents, finishedInput)
return {
mapveto = MatchGroupInputUtil.getMapVeto(match),
status = MatchFunctions.getMatchStatus(match),
status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and Logic.nilIfEmpty(finishedInput) or nil,
overturned = Logic.isNotEmpty(match.overturned),
featured = MatchFunctions.isFeatured(match, opponents),
hidden = Logic.readBool(Variables.varDefault('match_hidden'))
Expand Down
Loading