From 774f77d650ef97946a7c99e4a49a55562b2d2fee Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:05:32 +0900 Subject: [PATCH 1/5] use grid layout in overwatch --- lua/wikis/overwatch/MatchSummary.lua | 57 +++++++++++----------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/lua/wikis/overwatch/MatchSummary.lua b/lua/wikis/overwatch/MatchSummary.lua index 9b81a2d04db..aacfdabb471 100644 --- a/lua/wikis/overwatch/MatchSummary.lua +++ b/lua/wikis/overwatch/MatchSummary.lua @@ -8,7 +8,8 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') +local Class = Lua.import('Module:Class') +local Logic = Lua.import('Module:Logic') local Table = Lua.import('Module:Table') local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') @@ -18,8 +19,13 @@ local WidgetUtil = Lua.import('Module:Widget/Util') local MAX_NUM_BANS = 1 +---@class OverwatchCustomMatchSummary: CustomMatchSummaryInterface local CustomMatchSummary = {} +---@class OverwatchMatchSummaryGameRow: MatchSummaryGameRow +---@operator call(MatchSummaryGameRowProps): OverwatchMatchSummaryGameRow +local OverwatchMatchSummaryGameRow = Class.new(MatchSummaryWidgets.GameRow) + ---@param args table ---@return Widget function CustomMatchSummary.getByMatchId(args) @@ -27,56 +33,39 @@ function CustomMatchSummary.getByMatchId(args) end ---@param match MatchGroupUtilMatch ----@param createGame fun(date: string, game: table, gameIndex: integer): Widget ---@return Widget[] -function CustomMatchSummary.createBody(match, createGame) +function CustomMatchSummary.createBody(match) local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(createGame, match.date)), + MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + if Logic.isEmpty(game.map) then + return + end + return OverwatchMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) + }, MatchSummaryWidgets.Mvp(match.extradata.mvp), MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} ) end ----@param date string ----@param game MatchGroupUtilGame ----@param gameIndex integer ----@return Widget? -function CustomMatchSummary.createGame(date, game, gameIndex) - if not game.map then - return - end - - local function makeTeamSection(opponentIndex) - return { - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = opponentIndex}, - CustomMatchSummary._gameScore(game, opponentIndex) - } - end - - return MatchSummaryWidgets.Row{ - classes = {'brkts-popup-body-game'}, - children = WidgetUtil.collect( - MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(1)}, - MatchSummaryWidgets.GameCenter{children = DisplayHelper.MapAndMode(game)}, - MatchSummaryWidgets.GameTeamWrapper{children = makeTeamSection(2), flipped = true}, - MatchSummaryWidgets.GameComment{children = game.comment} - ) - } +---@return string +function OverwatchMatchSummaryGameRow:createGameOverview() + return DisplayHelper.MapAndMode(self.props.game) end ----@param game MatchGroupUtilGame ---@param opponentIndex integer ----@return Html -function CustomMatchSummary._gameScore(game, opponentIndex) +---@return string +function OverwatchMatchSummaryGameRow:createGameOpponentView(opponentIndex) + local game = self.props.game local opponentCopy = Table.deepCopy(game.opponents[opponentIndex]) if opponentCopy.score and game.mode == 'Push' then opponentCopy.score = opponentCopy.score .. 'm' end - local scoreDisplay = DisplayHelper.MapScore(opponentCopy, game.status) - return mw.html.create('div'):wikitext(scoreDisplay) + return DisplayHelper.MapScore(opponentCopy, game.status) end return CustomMatchSummary From feecea7548f968520fae625abe865310c3ffb4e9 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:29:40 +0900 Subject: [PATCH 2/5] use grid layout in HoK --- lua/wikis/honorofkings/MatchSummary.lua | 83 +++++++++++++------------ 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/lua/wikis/honorofkings/MatchSummary.lua b/lua/wikis/honorofkings/MatchSummary.lua index 33826e3bb8c..676bfcb8650 100644 --- a/lua/wikis/honorofkings/MatchSummary.lua +++ b/lua/wikis/honorofkings/MatchSummary.lua @@ -5,12 +5,10 @@ -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- -local CustomMatchSummary = {} - local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') +local Class = Lua.import('Module:Class') local Logic = Lua.import('Module:Logic') local MatchSummary = Lua.import('Module:MatchSummary/Base') @@ -20,6 +18,13 @@ local WidgetUtil = Lua.import('Module:Widget/Util') local MAX_NUM_BANS = 5 local NUM_CHAMPIONS_PICK = 5 +---@class HoKCustomMatchSummary: CustomMatchSummaryInterface +local CustomMatchSummary = {} + +---@class HoKMatchSummaryGameRow: MatchSummaryGameRow +---@operator call(MatchSummaryGameRowProps): HoKMatchSummaryGameRow +local HoKMatchSummaryGameRow = Class.new(MatchSummaryWidgets.GameRow) + ---@param args table ---@return Widget function CustomMatchSummary.getByMatchId(args) @@ -31,50 +36,50 @@ end function CustomMatchSummary.createBody(match) local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) + ---@param game MatchGroupUtilGame + ---@return boolean + local function hasCharacterData(game) + local extradata = game.extradata or {} + return Array.any(Array.range(1, NUM_CHAMPIONS_PICK), function (index) + return Logic.isNotEmpty(extradata['team1champion' .. index]) + or Logic.isNotEmpty(extradata['team2champion' .. index]) + end) + end + return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(CustomMatchSummary._createGame, match.date)), + MatchSummaryWidgets.GamesContainer{ + gridLayout = 'standard', + children = Array.map(match.games, function (game, gameIndex) + if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and not hasCharacterData(game) then + return + end + return HoKMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) + }, MatchSummaryWidgets.Mvp(match.extradata.mvp), MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} ) end ----@param date string ----@param game MatchGroupUtilGame ----@param gameIndex integer ----@return MatchSummaryRow? -function CustomMatchSummary._createGame(date, game, gameIndex) - local extradata = game.extradata or {} - - -- TODO: Change to use participant data - local characterData = { - MatchSummary.buildCharacterList(extradata, 'team1champion', NUM_CHAMPIONS_PICK), - MatchSummary.buildCharacterList(extradata, 'team2champion', NUM_CHAMPIONS_PICK), - } +---@return Renderable? +function HoKMatchSummaryGameRow:createGameOverview() + return self:lengthDisplay() +end - if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and Logic.isDeepEmpty(characterData) then - return nil - end +---@param opponentIndex integer +---@return Widget +function HoKMatchSummaryGameRow:createGameOpponentView(opponentIndex) + local props = self.props + local game = props.game + local extradata = game.extradata or {} - return MatchSummaryWidgets.Row{ - classes = {'brkts-popup-body-game'}, - children = WidgetUtil.collect( - MatchSummaryWidgets.Characters{ - flipped = false, - characters = characterData[1], - bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata.team1side or ''), - date = date, - }, - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 1}, - MatchSummaryWidgets.GameCenter{children = Logic.nilIfEmpty(game.length) or ('Game ' .. gameIndex)}, - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 2}, - MatchSummaryWidgets.Characters{ - flipped = true, - characters = characterData[2], - bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata.team2side or ''), - date = date, - }, - MatchSummaryWidgets.GameComment{children = game.comment} - ) + return MatchSummaryWidgets.Characters{ + flipped = opponentIndex == 2, + characters = MatchSummary.buildCharacterList( + extradata, 'team' .. opponentIndex .. 'champion', NUM_CHAMPIONS_PICK + ), + bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata['team' .. opponentIndex .. 'side'] or ''), + date = game.date, } end From b5837bc0a5d5ba07a2bb0d380ad11b1fb7b743de Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:48:03 +0900 Subject: [PATCH 3/5] use grid layout in counterstrike --- lua/wikis/counterstrike/MatchSummary.lua | 77 ++++++++++-------------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/lua/wikis/counterstrike/MatchSummary.lua b/lua/wikis/counterstrike/MatchSummary.lua index be52a69b4f4..d5182ba22f4 100644 --- a/lua/wikis/counterstrike/MatchSummary.lua +++ b/lua/wikis/counterstrike/MatchSummary.lua @@ -8,18 +8,23 @@ local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') +local Class = Lua.import('Module:Class') local Logic = Lua.import('Module:Logic') local String = Lua.import('Module:StringUtils') local Table = Lua.import('Module:Table') local VodLink = Lua.import('Module:VodLink') -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 CounterstrikeCustomMatchSummary: CustomMatchSummaryInterface local CustomMatchSummary = {} +---@class CounterstrikeMatchSummaryGameRow: MatchSummaryGameRow +---@operator call(MatchSummaryGameRowProps): CounterstrikeMatchSummaryGameRow +local CounterstrikeMatchSummaryGameRow = Class.new(MatchSummaryWidgets.GameRow) + ---@param args table ---@return Widget function CustomMatchSummary.getByMatchId(args) @@ -63,7 +68,15 @@ function CustomMatchSummary.createBody(match) matchStatusText = 'Match ' .. mw.getContentLanguage():ucfirst(match.extradata.status) .. '' end return WidgetUtil.collect( - Array.map(match.games, CustomMatchSummary._createMap), + MatchSummaryWidgets.GamesContainer{ + gridLayout = 'standard', + children = Array.map(match.games, function (game, gameIndex) + if Logic.isEmpty(game.map) then + return + end + return CounterstrikeMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) + }, MatchSummaryWidgets.MapVeto(MatchSummary.preProcessMapVeto(match.extradata.mapveto, {game = match.game})), MatchSummaryWidgets.MatchComment{children = matchStatusText} or nil ) @@ -182,49 +195,25 @@ function CustomMatchSummary._createFooter(match, vods, secondVods) return footer end ----@param game MatchGroupUtilGame ----@return Widget? -function CustomMatchSummary._createMap(game) - if not game.map then - return - end - - local function score(oppIdx) - return DisplayHelper.MapScore(game.opponents[oppIdx], game.status) - end - - -- Teams scores - local extradata = game.extradata or {} - local t1sides = extradata.t1sides or {} - local t2sides = extradata.t2sides or {} - local t1halfs = extradata.t1halfs or {} - local t2halfs = extradata.t2halfs or {} - - local team1Scores = {} - local team2Scores = {} - for sideIndex in ipairs(t1sides) do - local side1, side2 = t1sides[sideIndex], t2sides[sideIndex] - local score1, score2 = t1halfs[sideIndex], t2halfs[sideIndex] - table.insert(team1Scores, {style = side1 and ('brkts-cs-score-color-'.. side1) or nil, score = score1}) - table.insert(team2Scores, {style = side2 and ('brkts-cs-score-color-'.. side2) or nil, score = score2}) - end - - local mapInfo = { - mapDisplayName = game.map, - map = game.game and (game.map .. '/' .. game.game) or game.map, - status = game.status, - } +---@return string +function CounterstrikeMatchSummaryGameRow:createGameOverview() + return self:mapDisplay() +end - return MatchSummaryWidgets.Row{ - classes = {'brkts-popup-body-game'}, - children = WidgetUtil.collect( - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 1}, - MatchSummaryWidgets.DetailedScore{score = score(1), partialScores = team1Scores, flipped = false}, - MatchSummaryWidgets.GameCenter{children = DisplayHelper.Map(mapInfo), css = {['flex-grow'] = '1'}}, - MatchSummaryWidgets.DetailedScore{score = score(2), partialScores = team2Scores, flipped = true}, - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 2}, - MatchSummaryWidgets.GameComment{children = game.comment} - ) +---@param opponentIndex integer +---@return Widget +function CounterstrikeMatchSummaryGameRow:createGameOpponentView(opponentIndex) + local game = self.props.game + + local sides = game.extradata['t' .. opponentIndex .. 'sides'] + local halfs = game.extradata['t' .. opponentIndex .. 'halfs'] + local scores = Array.map(sides, function (side, sideIndex) + return {style = side and ('brkts-cs-score-color-'.. side) or nil, score = halfs[sideIndex]} + end) + + return MatchSummaryWidgets.DetailedScore{ + score = self:scoreDisplay(opponentIndex), + partialScores = scores, } end From 631d50c73bf55c1f7ed58badeeafbfa5f157fbc6 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:52:02 +0900 Subject: [PATCH 4/5] kick unused param --- lua/wikis/counterstrike/MatchSummary.lua | 1 - lua/wikis/honorofkings/MatchSummary.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/lua/wikis/counterstrike/MatchSummary.lua b/lua/wikis/counterstrike/MatchSummary.lua index d5182ba22f4..39eea20d4fb 100644 --- a/lua/wikis/counterstrike/MatchSummary.lua +++ b/lua/wikis/counterstrike/MatchSummary.lua @@ -69,7 +69,6 @@ function CustomMatchSummary.createBody(match) end return WidgetUtil.collect( MatchSummaryWidgets.GamesContainer{ - gridLayout = 'standard', children = Array.map(match.games, function (game, gameIndex) if Logic.isEmpty(game.map) then return diff --git a/lua/wikis/honorofkings/MatchSummary.lua b/lua/wikis/honorofkings/MatchSummary.lua index 676bfcb8650..76c1db1b785 100644 --- a/lua/wikis/honorofkings/MatchSummary.lua +++ b/lua/wikis/honorofkings/MatchSummary.lua @@ -48,7 +48,6 @@ function CustomMatchSummary.createBody(match) return WidgetUtil.collect( MatchSummaryWidgets.GamesContainer{ - gridLayout = 'standard', children = Array.map(match.games, function (game, gameIndex) if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and not hasCharacterData(game) then return From 6153eb91a76554f97b66b66a46fb23581bd2b892 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:53:38 +0900 Subject: [PATCH 5/5] use grid layout in mobilelegends --- lua/wikis/mobilelegends/MatchSummary.lua | 82 +++++++++++++----------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/lua/wikis/mobilelegends/MatchSummary.lua b/lua/wikis/mobilelegends/MatchSummary.lua index 294ca996f4c..15b9f917407 100644 --- a/lua/wikis/mobilelegends/MatchSummary.lua +++ b/lua/wikis/mobilelegends/MatchSummary.lua @@ -5,12 +5,10 @@ -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- -local CustomMatchSummary = {} - local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') +local Class = Lua.import('Module:Class') local Logic = Lua.import('Module:Logic') local MatchSummary = Lua.import('Module:MatchSummary/Base') @@ -20,6 +18,13 @@ local WidgetUtil = Lua.import('Module:Widget/Util') local MAX_NUM_BANS = 5 local NUM_CHAMPIONS_PICK = 5 +---@class MobileLegendsCustomMatchSummary: CustomMatchSummaryInterface +local CustomMatchSummary = {} + +---@class MobileLegendsMatchSummaryGameRow: MatchSummaryGameRow +---@operator call(MatchSummaryGameRowProps): MobileLegendsMatchSummaryGameRow +local MobileLegendsMatchSummaryGameRow = Class.new(MatchSummaryWidgets.GameRow) + ---@param args table ---@return Widget function CustomMatchSummary.getByMatchId(args) @@ -31,50 +36,49 @@ end function CustomMatchSummary.createBody(match) local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) + ---@param game MatchGroupUtilGame + ---@return boolean + local function hasCharacterData(game) + local extradata = game.extradata or {} + return Array.any(Array.range(1, NUM_CHAMPIONS_PICK), function (index) + return Logic.isNotEmpty(extradata['team1champion' .. index]) + or Logic.isNotEmpty(extradata['team2champion' .. index]) + end) + end + return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(CustomMatchSummary._createGame, match.date)), + MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and not hasCharacterData(game) then + return + end + return MobileLegendsMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) + }, MatchSummaryWidgets.Mvp(match.extradata.mvp), MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} ) end ----@param date string ----@param game MatchGroupUtilGame ----@param gameIndex integer ----@return MatchSummaryRow? -function CustomMatchSummary._createGame(date, game, gameIndex) - local extradata = game.extradata or {} - - -- TODO: Change to use participant data - local characterData = { - MatchSummary.buildCharacterList(extradata, 'team1champion', NUM_CHAMPIONS_PICK), - MatchSummary.buildCharacterList(extradata, 'team2champion', NUM_CHAMPIONS_PICK), - } +---@return Renderable? +function MobileLegendsMatchSummaryGameRow:createGameOverview() + return self:lengthDisplay() +end - if Logic.isEmpty(game.length) and Logic.isEmpty(game.winner) and Logic.isDeepEmpty(characterData) then - return nil - end +---@param opponentIndex integer +---@return Widget +function MobileLegendsMatchSummaryGameRow:createGameOpponentView(opponentIndex) + local props = self.props + local game = props.game + local extradata = game.extradata or {} - return MatchSummaryWidgets.Row{ - classes = {'brkts-popup-body-game'}, - children = WidgetUtil.collect( - MatchSummaryWidgets.Characters{ - flipped = false, - characters = characterData[1], - bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata.team1side or ''), - date = date, - }, - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 1}, - MatchSummaryWidgets.GameCenter{children = Logic.nilIfEmpty(game.length) or ('Game ' .. gameIndex)}, - MatchSummaryWidgets.GameWinLossIndicator{winner = game.winner, opponentIndex = 2}, - MatchSummaryWidgets.Characters{ - flipped = true, - characters = characterData[2], - bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata.team2side or ''), - date = date, - }, - MatchSummaryWidgets.GameComment{children = game.comment} - ) + return MatchSummaryWidgets.Characters{ + flipped = opponentIndex == 2, + characters = MatchSummary.buildCharacterList( + extradata, 'team' .. opponentIndex .. 'champion', NUM_CHAMPIONS_PICK + ), + bg = 'brkts-popup-side-color brkts-popup-side-color--' .. (extradata['team' .. opponentIndex .. 'side'] or ''), + date = game.date, } end