diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 01a1d8753d..b7ab16dfe3 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -837,7 +837,12 @@ function MatchGroupInputUtil.matchIsFinished(match, opponents) return true end + local playall = Logic.readBoolOrNil(match.playall) local bestof = match.bestof + if playall then + return MatchGroupInputUtil.allHasBeenPlayed(bestof, opponents) + end + if not bestof then return false end @@ -891,6 +896,13 @@ function MatchGroupInputUtil.majorityHasBeenWon(bestof, opponents) return false end +---@param games table[] +---@return boolean +function MatchGroupInputUtil.allHasBeenPlayed(playall, opponents) + local scoreSum = Array.reduce(opponents, function(sum, opponent) return sum + (opponent.score or 0) end, 0) + return scoreSum >= playall +end + ---@param bestOfInput string|integer? ---@param maps table[] ---@return integer? @@ -1141,6 +1153,7 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser, mapProps) match.stream = Streams.processStreams(match) match.extradata = Parser.getExtraData and Parser.getExtraData(match, games, opponents) or {} + match.extradata = Table.merge({playall = Logic.readBoolOrNil(match.playall)}, match.extradata) match.games = games match.opponents = opponents