diff --git a/components/match2/commons/brkts_wiki_specific_base.lua b/components/match2/commons/brkts_wiki_specific_base.lua index 41e55288ba..c74ce75f36 100644 --- a/components/match2/commons/brkts_wiki_specific_base.lua +++ b/components/match2/commons/brkts_wiki_specific_base.lua @@ -51,9 +51,8 @@ Called from MatchGroup -- @returns module ]] -function WikiSpecificBase.getMatchGroupContainer(matchGroupType) - -- TODO Add a check if opponent count is > 2 - if Lua.moduleExists('Module:GameSummary') then +function WikiSpecificBase.getMatchGroupContainer(matchGroupType, maxOpponentCount) + if Lua.moduleExists('Module:MatchSummary/Ffa') and maxOpponentCount > 2 then local Horizontallist = Lua.import('Module:MatchGroup/Display/Horizontallist') return Horizontallist.BracketContainer elseif matchGroupType == 'matchlist' then diff --git a/components/match2/commons/match_group.lua b/components/match2/commons/match_group.lua index 26be75816e..f8175e95bd 100644 --- a/components/match2/commons/match_group.lua +++ b/components/match2/commons/match_group.lua @@ -37,8 +37,9 @@ function MatchGroup.MatchList(args) local matchlistNode if options.show then + local maxOpponentCount = MatchGroupInput.getMaxOpponentCount(matches) local MatchlistDisplay = Lua.import('Module:MatchGroup/Display/Matchlist') - local MatchlistContainer = WikiSpecific.getMatchGroupContainer('matchlist') + local MatchlistContainer = WikiSpecific.getMatchGroupContainer('matchlist', maxOpponentCount) matchlistNode = MatchlistContainer({ bracketId = options.bracketId, config = MatchlistDisplay.configFromArgs(args), @@ -62,8 +63,9 @@ function MatchGroup.Bracket(args) local bracketNode if options.show then + local maxOpponentCount = MatchGroupInput.getMaxOpponentCount(matches) local BracketDisplay = Lua.import('Module:MatchGroup/Display/Bracket') - local BracketContainer = WikiSpecific.getMatchGroupContainer('bracket') + local BracketContainer = WikiSpecific.getMatchGroupContainer('bracket', maxOpponentCount) bracketNode = BracketContainer({ bracketId = options.bracketId, config = BracketDisplay.configFromArgs(args), @@ -153,7 +155,8 @@ function MatchGroup.MatchGroupById(args) Logic.wrapTryOrLog(MatchGroupInput.applyOverrideArgs)(matches, args) - local MatchGroupContainer = WikiSpecific.getMatchGroupContainer(matchGroupType) + local maxOpponentCount = MatchGroupInput.getMaxOpponentCount(matches) + local MatchGroupContainer = WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) return MatchGroupContainer({ bracketId = bracketId, config = config, diff --git a/components/match2/commons/match_group_display_helper.lua b/components/match2/commons/match_group_display_helper.lua index 0e60ad611f..7e4940dcc0 100644 --- a/components/match2/commons/match_group_display_helper.lua +++ b/components/match2/commons/match_group_display_helper.lua @@ -211,6 +211,16 @@ function DisplayHelper.DefaultMatchSummaryContainer(props) return MatchSummaryModule.getByMatchId(props) end +---@param props table +---@return Html +function DisplayHelper.DefaultFfaMatchSummaryContainer(props) + local MatchSummaryModule = Lua.import('Module:MatchSummary/Ffa') + + assert(MatchSummaryModule.getByMatchId, 'Expected MatchSummary/Ffa.getByMatchId to be a function') + + return MatchSummaryModule.getByMatchId(props) +end + ---@param props table ---@return Html function DisplayHelper.DefaultGameSummaryContainer(props) diff --git a/components/match2/commons/match_group_display_horizontallist.lua b/components/match2/commons/match_group_display_horizontallist.lua index 956fcd4c13..50e8de3b14 100644 --- a/components/match2/commons/match_group_display_horizontallist.lua +++ b/components/match2/commons/match_group_display_horizontallist.lua @@ -66,7 +66,7 @@ end ---@return Html function HorizontallistDisplay.Bracket(props) local config = { - MatchSummaryContainer = DisplayHelper.DefaultMatchSummaryContainer, + MatchSummaryContainer = DisplayHelper.DefaultFfaMatchSummaryContainer, } local list = mw.html.create('ul'):addClass('navigation-tabs__list'):attr('role', 'tablist') diff --git a/components/match2/commons/match_group_input.lua b/components/match2/commons/match_group_input.lua index f3e5f9476d..388530e386 100644 --- a/components/match2/commons/match_group_input.lua +++ b/components/match2/commons/match_group_input.lua @@ -348,6 +348,12 @@ function MatchGroupInput.applyOverrideArgs(matches, args) end end +function MatchGroupInput.getMaxOpponentCount(matches) + return Array.reduce(matches, function(cur, match) + return math.max(#match.match2opponents, cur) + end) +end + ---@param headerInput string? ---@return string? function MatchGroupInput._inheritedHeader(headerInput) diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 3c26047801..437309d007 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -1066,6 +1066,7 @@ end ---@field DEFAULT_MODE? string ---@field DATE_FALLBACKS? string[] ---@field OPPONENT_CONFIG? readOpponentOptions +---@field HAS_FFA? boolean --- The standard way to process a match input. --- @@ -1087,13 +1088,15 @@ end --- - DEFAULT_MODE: string --- - DATE_FALLBACKS: string[] --- - OPPONENT_CONFIG: table +--- - HAS_FFA: boolean ---@param match table ----@param Parser MatchParserInterface +---@param Parser MatchParserInterface? +---@param FfaParser FfaMatchParserInterface? ---@param mapProps any? ---@return table -function MatchGroupInputUtil.standardProcessMatch(match, Parser, mapProps) - local finishedInput = match.finished --[[@as string?]] - local winnerInput = match.winner --[[@as string?]] +function MatchGroupInputUtil.standardProcessMatch(match, Parser, FfaParser, mapProps) + Parser = Parser or {} + local matchInput = Table.deepCopy(match) local dateProps = Parser.readDate and Parser.readDate(match) or MatchGroupInputUtil.readDate(match.date, Parser.DATE_FALLBACKS) @@ -1107,6 +1110,10 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser, mapProps) return opponent end) + if FfaParser and #opponents > 2 then + return MatchGroupInputUtil.standardProcessFfaMatch(matchInput, FfaParser, mapProps) + end + local games = Parser.extractMaps(match, opponents, mapProps) match.bestof = Parser.getBestOf(match.bestof, games) games = Parser.removeUnsetMaps and Parser.removeUnsetMaps(games) or games @@ -1131,8 +1138,8 @@ function MatchGroupInputUtil.standardProcessMatch(match, Parser, mapProps) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) - match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(matchInput.winner, matchInput.finished) + match.winner = MatchGroupInputUtil.getWinner(match.status, matchInput.winner, opponents) Array.forEach(opponents, function(opponent, opponentIndex) opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) @@ -1337,6 +1344,7 @@ function MatchGroupInputUtil.standardProcessFfaMatch(match, Parser, mapProps) match.stream = Streams.processStreams(match) match.links = MatchGroupInputUtil.getLinks(match) match.extradata = Parser.getExtraData and Parser.getExtraData(match, games, opponents, settings) or {} + match.extradata.ffa = true match.games = games match.opponents = opponents diff --git a/components/match2/wikis/apexlegends/match_summary.lua b/components/match2/wikis/apexlegends/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/apexlegends/match_summary.lua rename to components/match2/wikis/apexlegends/match_summary_ffa.lua index d832a22444..9d1d8424f2 100644 --- a/components/match2/wikis/apexlegends/match_summary.lua +++ b/components/match2/wikis/apexlegends/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=apexlegends --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/autochess/game_summary.lua b/components/match2/wikis/autochess/game_summary.lua index c6a674d909..7e462a810f 100644 --- a/components/match2/wikis/autochess/game_summary.lua +++ b/components/match2/wikis/autochess/game_summary.lua @@ -1,6 +1,6 @@ --- --- @autochess --- wiki=underlords +-- @Liquipedia +-- wiki=autochess -- page=Module:GameSummary -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute diff --git a/components/match2/wikis/autochess/match_summary.lua b/components/match2/wikis/autochess/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/autochess/match_summary.lua rename to components/match2/wikis/autochess/match_summary_ffa.lua index bfff8cf046..d48be732bb 100644 --- a/components/match2/wikis/autochess/match_summary.lua +++ b/components/match2/wikis/autochess/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=autochess --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/dota2/match_group_input_custom.lua b/components/match2/wikis/dota2/match_group_input_custom.lua index 54924860ac..5fab22b2f7 100644 --- a/components/match2/wikis/dota2/match_group_input_custom.lua +++ b/components/match2/wikis/dota2/match_group_input_custom.lua @@ -74,7 +74,7 @@ end ---@param match table ---@return table function CustomMatchGroupInput.processMatchWithoutStandalone(MapParser, match) - return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions, MapParser) + return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions, nil, MapParser) end ---@param match table diff --git a/components/match2/wikis/fortnite/match_summary.lua b/components/match2/wikis/fortnite/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/fortnite/match_summary.lua rename to components/match2/wikis/fortnite/match_summary_ffa.lua index fdfa2de1b7..9a7484296b 100644 --- a/components/match2/wikis/fortnite/match_summary.lua +++ b/components/match2/wikis/fortnite/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=fortnite --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/freefire/match_summary.lua b/components/match2/wikis/freefire/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/freefire/match_summary.lua rename to components/match2/wikis/freefire/match_summary_ffa.lua index d0e93b647c..92e0a8d9c4 100644 --- a/components/match2/wikis/freefire/match_summary.lua +++ b/components/match2/wikis/freefire/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=freefire --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua index fb4f57b326..3ae1624423 100644 --- a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua +++ b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua @@ -68,7 +68,7 @@ end ---@param match table ---@return table function CustomMatchGroupInput.processMatchWithoutStandalone(MapParser, match) - return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions, MapParser) + return MatchGroupInputUtil.standardProcessMatch(match, MatchFunctions, nil, MapParser) end ---@param match table diff --git a/components/match2/wikis/naraka/match_summary.lua b/components/match2/wikis/naraka/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/naraka/match_summary.lua rename to components/match2/wikis/naraka/match_summary_ffa.lua index 7d4c50b7b6..916061abd8 100644 --- a/components/match2/wikis/naraka/match_summary.lua +++ b/components/match2/wikis/naraka/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=naraka --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/pubg/match_summary.lua b/components/match2/wikis/pubg/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/pubg/match_summary.lua rename to components/match2/wikis/pubg/match_summary_ffa.lua index bde3b460b8..e6fcd2a928 100644 --- a/components/match2/wikis/pubg/match_summary.lua +++ b/components/match2/wikis/pubg/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=pubg --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/pubgmobile/match_summary.lua b/components/match2/wikis/pubgmobile/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/pubgmobile/match_summary.lua rename to components/match2/wikis/pubgmobile/match_summary_ffa.lua index b399cf8659..d43461f5bc 100644 --- a/components/match2/wikis/pubgmobile/match_summary.lua +++ b/components/match2/wikis/pubgmobile/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=pubgmobile --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- diff --git a/components/match2/wikis/rocketleague/brkts_wiki_specific.lua b/components/match2/wikis/rocketleague/brkts_wiki_specific.lua index cbeda23653..10222aab7a 100644 --- a/components/match2/wikis/rocketleague/brkts_wiki_specific.lua +++ b/components/match2/wikis/rocketleague/brkts_wiki_specific.lua @@ -15,8 +15,9 @@ local BaseWikiSpecific = Lua.import('Module:Brkts/WikiSpecific/Base') local WikiSpecific = Table.copy(BaseWikiSpecific) ---@param matchGroupType string +---@param maxOpponentCount integer ---@return function -function WikiSpecific.getMatchGroupContainer(matchGroupType) +function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) return matchGroupType == 'matchlist' and Lua.import('Module:MatchGroup/Display/Matchlist').MatchlistContainer or Lua.import('Module:MatchGroup/Display/Bracket/Custom').BracketContainer diff --git a/components/match2/wikis/smash/brkts_wiki_specific.lua b/components/match2/wikis/smash/brkts_wiki_specific.lua index 8c8a95e548..603d301f97 100644 --- a/components/match2/wikis/smash/brkts_wiki_specific.lua +++ b/components/match2/wikis/smash/brkts_wiki_specific.lua @@ -22,8 +22,9 @@ WikiSpecific.matchFromRecord = FnUtil.lazilyDefineFunction(function() end) ---@param matchGroupType string +---@param maxOpponentCount integer ---@return function -function WikiSpecific.getMatchGroupContainer(matchGroupType) +function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) return matchGroupType == 'matchlist' and Lua.import('Module:MatchGroup/Display/Matchlist').MatchlistContainer or Lua.import('Module:MatchGroup/Display/Bracket/Custom').BracketContainer diff --git a/components/match2/wikis/starcraft/brkts_wiki_specific.lua b/components/match2/wikis/starcraft/brkts_wiki_specific.lua index 972d0fe789..784a259fb5 100644 --- a/components/match2/wikis/starcraft/brkts_wiki_specific.lua +++ b/components/match2/wikis/starcraft/brkts_wiki_specific.lua @@ -26,8 +26,9 @@ WikiSpecific.processMatch = FnUtil.lazilyDefineFunction(function() end) ---@param matchGroupType string +---@param maxOpponentCount integer ---@return function -function WikiSpecific.getMatchGroupContainer(matchGroupType) +function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) if matchGroupType == 'matchlist' then local MatchList = Lua.import('Module:MatchGroup/Display/Matchlist') return WikiSpecific.adjustMatchGroupContainerConfig(MatchList.MatchlistContainer) diff --git a/components/match2/wikis/starcraft2/brkts_wiki_specific.lua b/components/match2/wikis/starcraft2/brkts_wiki_specific.lua index 32657f091d..a79315ad4a 100644 --- a/components/match2/wikis/starcraft2/brkts_wiki_specific.lua +++ b/components/match2/wikis/starcraft2/brkts_wiki_specific.lua @@ -26,8 +26,9 @@ WikiSpecific.processMatch = FnUtil.lazilyDefineFunction(function() end) ---@param matchGroupType string +---@param maxOpponentCount integer ---@return function -function WikiSpecific.getMatchGroupContainer(matchGroupType) +function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) if matchGroupType == 'matchlist' then local MatchList = Lua.import('Module:MatchGroup/Display/Matchlist') return WikiSpecific.adjustMatchGroupContainerConfig(MatchList.MatchlistContainer) diff --git a/components/match2/wikis/trackmania/brkts_wiki_specific.lua b/components/match2/wikis/trackmania/brkts_wiki_specific.lua index f85dc472af..05d6d088ab 100644 --- a/components/match2/wikis/trackmania/brkts_wiki_specific.lua +++ b/components/match2/wikis/trackmania/brkts_wiki_specific.lua @@ -14,7 +14,7 @@ local BaseWikiSpecific = Lua.import('Module:Brkts/WikiSpecific/Base') ---@class TrackmaniaBrktsWikiSpecific: BrktsWikiSpecific local WikiSpecific = Table.copy(BaseWikiSpecific) -function WikiSpecific.getMatchGroupContainer(matchGroupType) +function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) return matchGroupType == 'matchlist' and Lua.import('Module:MatchGroup/Display/Matchlist').MatchlistContainer or Lua.import('Module:MatchGroup/Display/Bracket/Custom').BracketContainer diff --git a/components/match2/wikis/underlords/match_summary.lua b/components/match2/wikis/underlords/match_summary_ffa.lua similarity index 97% rename from components/match2/wikis/underlords/match_summary.lua rename to components/match2/wikis/underlords/match_summary_ffa.lua index 19cd6541ae..4563f2b9c5 100644 --- a/components/match2/wikis/underlords/match_summary.lua +++ b/components/match2/wikis/underlords/match_summary_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=underlords --- page=Module:MatchSummary +-- page=Module:MatchSummary/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute --