diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index c4c51f696a..48e3f8b94e 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -1064,6 +1064,7 @@ end ---@class MatchParserInterface ---@field extractMaps fun(match: table, opponents: table[], mapProps: any?): table[] ---@field getBestOf fun(bestOfInput: string|integer|nil, maps: table[]): integer? +---@field switchToFfa? fun(match: table, opponents: table[]): boolean ---@field calculateMatchScore? fun(maps: table[], opponents: table[]): fun(opponentIndex: integer): integer? ---@field removeUnsetMaps? fun(maps: table[]): table[] ---@field getExtraData? fun(match: table, games: table[], opponents: table[]): table? @@ -1083,6 +1084,7 @@ end --- - getBestOf(bestOfInput, maps): integer? --- --- It may optionally have the following functions: +--- - switchToFfa(match, opponents): boolean --- - calculateMatchScore(maps, opponents): fun(opponentIndex): integer? --- - removeUnsetMaps(maps): table[] --- - getExtraData(match, games, opponents): table? @@ -1116,7 +1118,11 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser, FfaParser, mapP return opponent end) - if FfaParser and #opponents > 2 then + local function defaultSwitchToFfa() + return #opponents > 2 + end + local switchToFfa = Parser.switchToFfa or defaultSwitchToFfa + if FfaParser and switchToFfa(match, opponents) then return MatchGroupInputUtil.standardProcessFfaMatch(matchInput, FfaParser, mapProps) end diff --git a/components/match2/wikis/trackmania/match_group_input_custom.lua b/components/match2/wikis/trackmania/match_group_input_custom.lua index 7dfe32e4ff..cc750de03a 100644 --- a/components/match2/wikis/trackmania/match_group_input_custom.lua +++ b/components/match2/wikis/trackmania/match_group_input_custom.lua @@ -36,7 +36,14 @@ function CustomMatchGroupInput.processMatch(match, options) return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions, FfaMatchFunctions) end ---- Normal 2-opponent Match +--- Up to 4-opponents + +---@param match table +---@param opponents table[] +---@return boolean +function MatchFunctions.switchToFfa(match, opponents) + return #opponents > 4 +end ---@param match table ---@param opponents table[]