Skip to content

Commit

Permalink
parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Jan 3, 2025
1 parent 2354325 commit b66665d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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?
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down

0 comments on commit b66665d

Please sign in to comment.