Skip to content

Commit

Permalink
fix(match2): tournament_status is not working (#4881)
Browse files Browse the repository at this point in the history
* add `postponed` as allowed np input (used on cs)

* fix status/finished processing on cs

* Update components/match2/commons/match_group_input_util.lua

* do not overwrite input values directly

* couldn't find usage in matches so lets kick it

* as per discussion
  • Loading branch information
hjpalpha authored Oct 23, 2024
1 parent 89b8d7a commit 6a67a09
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 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,7 @@ local CustomMatchGroupInput = {}
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local finishedInput = match.finished --[[@as string?]]
local finishedInput = Logic.nilIfEmpty(match.finished) or Variables.varDefault('tournament_status') --[[@as string?]]
local winnerInput = match.winner --[[@as string?]]

Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date))
Expand Down Expand Up @@ -77,15 +77,14 @@ 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)

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 +197,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 +240,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 finishedInput or nil,
overturned = Logic.isNotEmpty(match.overturned),
featured = MatchFunctions.isFeatured(match, opponents),
hidden = Logic.readBool(Variables.varDefault('match_hidden'))
Expand Down

0 comments on commit 6a67a09

Please sign in to comment.