From 8745b7358a716c09bd1318bacd3b828b0c25e64a Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Thu, 12 Dec 2024 16:59:41 +0100 Subject: [PATCH] feat(match2): support both normal and ffa handling for a single wiki (#5195) * feat(match2): support both normal and ffa handling for a single wiki * init value * rename commons file * fix tests * type safety * unused * missing anno * adjust logic based on feedback --- .../commons/brkts_wiki_specific_base.lua | 7 ++++--- components/match2/commons/match_group.lua | 9 ++++++--- .../commons/match_group_display_helper.lua | 10 ++++++++++ .../match_group_display_horizontallist.lua | 2 +- .../match2/commons/match_group_input.lua | 8 ++++++++ .../match2/commons/match_group_input_util.lua | 18 ++++++++++++------ ...mary_ffa.lua => match_summary_base_ffa.lua} | 12 ++++++------ .../match2/wikis/apexlegends/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../match2/wikis/autochess/game_summary.lua | 6 +++--- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../wikis/dota2/match_group_input_custom.lua | 2 +- .../match2/wikis/fortnite/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../match2/wikis/freefire/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../match_group_input_custom.lua | 2 +- .../match2/wikis/naraka/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- components/match2/wikis/pubg/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../match2/wikis/pubgmobile/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../wikis/rocketleague/brkts_wiki_specific.lua | 3 ++- .../match2/wikis/smash/brkts_wiki_specific.lua | 3 ++- .../wikis/starcraft/brkts_wiki_specific.lua | 3 ++- .../wikis/starcraft2/brkts_wiki_specific.lua | 3 ++- .../wikis/trackmania/brkts_wiki_specific.lua | 2 +- .../match2/wikis/underlords/game_summary.lua | 2 +- ...match_summary.lua => match_summary_ffa.lua} | 4 ++-- .../widget_match_summary_ffa_table_header.lua | 2 +- .../match2_matchlist_smoke_apexlegends.txt | 2 +- spec/match2_spec.lua | 15 +++++++++++++++ 33 files changed, 101 insertions(+), 54 deletions(-) rename components/match2/commons/{match_summary_ffa.lua => match_summary_base_ffa.lua} (97%) rename components/match2/wikis/apexlegends/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/autochess/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/fortnite/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/freefire/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/naraka/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/pubg/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/pubgmobile/{match_summary.lua => match_summary_ffa.lua} (92%) rename components/match2/wikis/underlords/{match_summary.lua => match_summary_ffa.lua} (92%) diff --git a/components/match2/commons/brkts_wiki_specific_base.lua b/components/match2/commons/brkts_wiki_specific_base.lua index 41e55288ba9..79e8b2f3220 100644 --- a/components/match2/commons/brkts_wiki_specific_base.lua +++ b/components/match2/commons/brkts_wiki_specific_base.lua @@ -51,9 +51,10 @@ 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 (maxOpponentCount > 2 or not Lua.moduleExists('Module:MatchSummary')) and + Lua.moduleExists('Module:MatchSummary/Ffa') 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 26be75816e7..f8175e95bde 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 0e60ad611f6..7e4940dcc0d 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 956fcd4c134..50e8de3b14d 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 f3e5f9476d3..5014fab67dd 100644 --- a/components/match2/commons/match_group_input.lua +++ b/components/match2/commons/match_group_input.lua @@ -348,6 +348,14 @@ function MatchGroupInput.applyOverrideArgs(matches, args) end end +---@param matches {match2opponents: table[]}[] +---@return integer +function MatchGroupInput.getMaxOpponentCount(matches) + return Array.reduce(matches, function(cur, match) + return math.max(#match.match2opponents, cur) + end, 0) +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 3c26047801b..f4490b8b76e 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -1088,12 +1088,13 @@ end --- - DATE_FALLBACKS: string[] --- - OPPONENT_CONFIG: table ---@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 +1108,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 +1136,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) @@ -1351,6 +1356,7 @@ end --- ---@param match table ---@param opponents table[] +---@param scoreSettings table ---@param Parser MapParserInterface ---@return table function MatchGroupInputUtil.standardProcessFfaMaps(match, opponents, scoreSettings, Parser) diff --git a/components/match2/commons/match_summary_ffa.lua b/components/match2/commons/match_summary_base_ffa.lua similarity index 97% rename from components/match2/commons/match_summary_ffa.lua rename to components/match2/commons/match_summary_base_ffa.lua index e759ae5e9d8..69f89fc6615 100644 --- a/components/match2/commons/match_summary_ffa.lua +++ b/components/match2/commons/match_summary_base_ffa.lua @@ -1,7 +1,7 @@ --- -- @Liquipedia -- wiki=commons --- page=Module:MatchSummary/Ffa +-- page=Module:MatchSummary/Base/Ffa -- -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- @@ -140,7 +140,7 @@ local MATCH_OVERVIEW_COLUMNS = { class = 'cell--match-points', icon = 'matchpoint', show = function(match) - return match.extradata.settings.matchPointThreshold + return (match.extradata.settings or {}).matchPointThreshold end, header = { value = 'MPe Game', @@ -161,7 +161,7 @@ local MATCH_OVERVIEW_COLUMNS = { local GAME_OVERVIEW_COLUMNS = { { show = function(match) - return match.extradata.settings.showGameDetails + return (match.extradata.settings or {}).showGameDetails end, class = 'panel-table__cell__game-placement', icon = 'placement', @@ -191,7 +191,7 @@ local GAME_OVERVIEW_COLUMNS = { }, { show = function(match) - if match.extradata.settings.showGameDetails == false then + if (match.extradata.settings or {}).showGameDetails == false then return false end return Table.any(match.extradata.placementinfo or {}, function(_, value) @@ -211,7 +211,7 @@ local GAME_OVERVIEW_COLUMNS = { }, { show = function(match) - return not match.extradata.settings.showGameDetails + return not (match.extradata.settings or {}).showGameDetails end, class = 'panel-table__cell__game-total-points', icon = 'points', @@ -551,7 +551,7 @@ function MatchSummaryFfa.updateMatchOpponents(match) end) end) - local matchPointThreshold = match.extradata.settings.matchPointThreshold + local matchPointThreshold = (match.extradata.settings or {}).matchPointThreshold if matchPointThreshold then Array.forEach(match.opponents, function(opponent) local matchPointReachedIn diff --git a/components/match2/wikis/apexlegends/game_summary.lua b/components/match2/wikis/apexlegends/game_summary.lua index 441cacf4237..6702e0a5d75 100644 --- a/components/match2/wikis/apexlegends/game_summary.lua +++ b/components/match2/wikis/apexlegends/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class ApexMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/apexlegends/match_summary.lua b/components/match2/wikis/apexlegends/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/apexlegends/match_summary.lua rename to components/match2/wikis/apexlegends/match_summary_ffa.lua index d832a22444d..1cd5c98a4ea 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/autochess/game_summary.lua b/components/match2/wikis/autochess/game_summary.lua index c6a674d909b..7f26e08bd40 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 @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class AutochessMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/autochess/match_summary.lua b/components/match2/wikis/autochess/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/autochess/match_summary.lua rename to components/match2/wikis/autochess/match_summary_ffa.lua index bfff8cf046f..1ee274b2d04 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/dota2/match_group_input_custom.lua b/components/match2/wikis/dota2/match_group_input_custom.lua index 54924860acf..5fab22b2f74 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/game_summary.lua b/components/match2/wikis/fortnite/game_summary.lua index f23c57c0940..6d9af80026a 100644 --- a/components/match2/wikis/fortnite/game_summary.lua +++ b/components/match2/wikis/fortnite/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class FortniteMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/fortnite/match_summary.lua b/components/match2/wikis/fortnite/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/fortnite/match_summary.lua rename to components/match2/wikis/fortnite/match_summary_ffa.lua index fdfa2de1b75..c365ee0b444 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/freefire/game_summary.lua b/components/match2/wikis/freefire/game_summary.lua index 6f5278e646b..cd27bcca66d 100644 --- a/components/match2/wikis/freefire/game_summary.lua +++ b/components/match2/wikis/freefire/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class FreefireMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/freefire/match_summary.lua b/components/match2/wikis/freefire/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/freefire/match_summary.lua rename to components/match2/wikis/freefire/match_summary_ffa.lua index d0e93b647c8..8198aa21746 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua index fb4f57b326d..3ae16244233 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/game_summary.lua b/components/match2/wikis/naraka/game_summary.lua index fed798b637e..feea9c0174f 100644 --- a/components/match2/wikis/naraka/game_summary.lua +++ b/components/match2/wikis/naraka/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class NarakaMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/naraka/match_summary.lua b/components/match2/wikis/naraka/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/naraka/match_summary.lua rename to components/match2/wikis/naraka/match_summary_ffa.lua index 7d4c50b7b62..e29818df9ce 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/pubg/game_summary.lua b/components/match2/wikis/pubg/game_summary.lua index 7a1d41908f3..5c7190ca768 100644 --- a/components/match2/wikis/pubg/game_summary.lua +++ b/components/match2/wikis/pubg/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class PubgMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/pubg/match_summary.lua b/components/match2/wikis/pubg/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/pubg/match_summary.lua rename to components/match2/wikis/pubg/match_summary_ffa.lua index bde3b460b87..2fd9a40021a 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/pubgmobile/game_summary.lua b/components/match2/wikis/pubgmobile/game_summary.lua index 9e85ef2e651..1d7bcc33b26 100644 --- a/components/match2/wikis/pubgmobile/game_summary.lua +++ b/components/match2/wikis/pubgmobile/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class PubgmMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/pubgmobile/match_summary.lua b/components/match2/wikis/pubgmobile/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/pubgmobile/match_summary.lua rename to components/match2/wikis/pubgmobile/match_summary_ffa.lua index b399cf8659e..ddc7a14820b 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/match2/wikis/rocketleague/brkts_wiki_specific.lua b/components/match2/wikis/rocketleague/brkts_wiki_specific.lua index cbeda236537..10222aab7a0 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 8c8a95e5483..603d301f97d 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 972d0fe7898..784a259fb5c 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 32657f091da..a79315ad4af 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 f85dc472afc..05d6d088abc 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/game_summary.lua b/components/match2/wikis/underlords/game_summary.lua index 788d5f452ef..0632547235e 100644 --- a/components/match2/wikis/underlords/game_summary.lua +++ b/components/match2/wikis/underlords/game_summary.lua @@ -12,7 +12,7 @@ local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') ---@class UnderlordsMatchGroupUtilGame: MatchGroupUtilGame diff --git a/components/match2/wikis/underlords/match_summary.lua b/components/match2/wikis/underlords/match_summary_ffa.lua similarity index 92% rename from components/match2/wikis/underlords/match_summary.lua rename to components/match2/wikis/underlords/match_summary_ffa.lua index 19cd6541ae4..675474773c9 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 -- @@ -11,7 +11,7 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') -local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') diff --git a/components/widget/match/summary/ffa/widget_match_summary_ffa_table_header.lua b/components/widget/match/summary/ffa/widget_match_summary_ffa_table_header.lua index ba9800739a3..c9dc78726b9 100644 --- a/components/widget/match/summary/ffa/widget_match_summary_ffa_table_header.lua +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_table_header.lua @@ -19,7 +19,7 @@ local MatchSummaryFfaTableHeader = Class.new(Widget) ---@return Widget function MatchSummaryFfaTableHeader:render() return HtmlWidgets.Div{ - classes = {'panel-table__row', 'row--header '}, + classes = {'panel-table__row', 'row--header'}, attributes = { ['data-js-battle-royale'] = 'header-row' }, diff --git a/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt b/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt index 86b09ab6643..e8ff79291bc 100644 --- a/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt +++ b/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/spec/match2_spec.lua b/spec/match2_spec.lua index 41a7b862fdd..fb3ec7f3bd6 100644 --- a/spec/match2_spec.lua +++ b/spec/match2_spec.lua @@ -80,6 +80,21 @@ describe('match2', function() } }, } + }, + apexlegends = { + input = { + storeMatch1 = false, storePageVar = false, + matches = { + { + date = '2022-01-05', + comment = 'A Match Comment', + opponent1 = Json.stringify{name = 'A', link='abc', score = 3, type = 'solo'}, + opponent2 = Json.stringify{name = 'B', score = 2, type = 'solo'}, + opponent3 = Json.stringify{name = 'C', score = 4, type = 'solo'}, + opponent4 = Json.stringify{name = 'D', score = 1, type = 'solo'}, + } + }, + } } }) end)