diff --git a/lua/wikis/lab/MatchSummary.lua b/lua/wikis/lab/MatchSummary.lua index 60911d3df58..55ce9ec4c95 100644 --- a/lua/wikis/lab/MatchSummary.lua +++ b/lua/wikis/lab/MatchSummary.lua @@ -7,39 +7,50 @@ local Lua = require('Module:Lua') +local Array = Lua.import('Module:Array') + local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local MatchSummary = Lua.import('Module:MatchSummary/Base') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All') -local WidgetUtil = Lua.import('Module:Widget/Util') +---@class LabMatchSummary: CustomMatchSummaryInterface local CustomMatchSummary = {} +---@class LabMatchSummaryGameRowComponentProps: MatchSummaryGameRowComponentProps +local GameRowComponentProps = { + createGameOverview = MatchSummaryWidgets.GameRow.mapDisplay, +} + +local LabMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent(GameRowComponentProps) + ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args) end ----@param date string ----@param game MatchGroupUtilGame ----@param gameIndex integer ----@return Widget? -function CustomMatchSummary.createGame(date, game, gameIndex) - local function makeTeamSection(opponentIndex) - return { - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = opponentIndex}, - DisplayHelper.MapScore(game.opponents[opponentIndex], game.status) - } - end - - return MatchSummaryWidgets.Row{ - classes = {'brkts-popup-body-game'}, - children = WidgetUtil.collect( - MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(1)}, - MatchSummaryWidgets.GameCenter{children = DisplayHelper.Map(game)}, - MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(2), flipped = true}, - MatchSummaryWidgets.GameComment{children = game.comment} - ) +---@param match MatchGroupUtilMatch +---@return VNode[] +function CustomMatchSummary.createBody(match) + return { + MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + return LabMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) + }, + MatchSummaryWidgets.Mvp(match.extradata.mvp), + MatchSummaryWidgets.MapVeto(MatchSummary.preProcessMapVeto(match.extradata.mapveto, {game = match.game})) + } +end + + +---@param props MatchSummaryGameRowProps +---@param opponentIndex integer +---@return Renderable[] +function GameRowComponentProps.createGameOpponentView(props, opponentIndex) + local game = props.game + return { + DisplayHelper.MapScore(game.opponents[opponentIndex], game.status) } end