From 6a67a09539aa7b495f179b603618e6abee93dc5a Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:07:26 +0200 Subject: [PATCH] fix(match2): `tournament_status` is not working (#4881) * 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 --- .../counterstrike/match_group_input_custom.lua | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 523d4decf86..63c1a2bf9cf 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -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)) @@ -77,7 +77,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) @@ -85,7 +84,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 @@ -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 @@ -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'))