diff --git a/lua/wikis/ageofempires/MatchSummary.lua b/lua/wikis/ageofempires/MatchSummary.lua index 883805f05f1..c9d08236366 100644 --- a/lua/wikis/ageofempires/MatchSummary.lua +++ b/lua/wikis/ageofempires/MatchSummary.lua @@ -53,7 +53,7 @@ end ---@param match MatchGroupUtilMatch ---@return VNode -function CustomMatchSummary.createBody(match) +function CustomMatchSummary.createGames(match) return MatchSummaryWidgets.GamesContainer{ children = Array.map(match.games, function (game, gameIndex) if (not game.map) and (not game.winner) and Logic.isEmpty(game.status) and Logic.isDeepEmpty(game.opponents) then diff --git a/lua/wikis/brawlhalla/MatchSummary.lua b/lua/wikis/brawlhalla/MatchSummary.lua index 473d5451e49..4e220ed58ab 100644 --- a/lua/wikis/brawlhalla/MatchSummary.lua +++ b/lua/wikis/brawlhalla/MatchSummary.lua @@ -20,14 +20,14 @@ local Opponent = Lua.import('Module:Opponent/Custom') local CustomMatchSummary = {} ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '350px', teamStyle = 'bracket'}) end ---@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) +---@return Renderable[] +function CustomMatchSummary.createGames(match) return WidgetUtil.collect( CustomMatchSummary._isSolo(match) and Array.map(match.games, CustomMatchSummary._createGame) or nil ) @@ -43,7 +43,7 @@ function CustomMatchSummary._isSolo(match) end ---@param game MatchGroupUtilGame ----@return Widget? +---@return Renderable? function CustomMatchSummary._createGame(game) if not game.map and not game.winner then return end diff --git a/lua/wikis/commons/MatchSummary/Base.lua b/lua/wikis/commons/MatchSummary/Base.lua index 687a2911b2f..db7f49d43e9 100644 --- a/lua/wikis/commons/MatchSummary/Base.lua +++ b/lua/wikis/commons/MatchSummary/Base.lua @@ -30,7 +30,8 @@ local MATCH_LINK_PRIORITY = Lua.import('Module:Links/MatchPriorityGroups', {load local TBD = Abbreviation.make{text = 'TBD', title = 'To Be Determined'} ---@class CustomMatchSummaryInterface ----@field createBody? fun(match: MatchGroupUtilMatch): Renderable|Renderable[] +---@field createBody? fun(match: MatchGroupUtilMatch): Renderable|Renderable[] @deprecated +---@field createGames? fun(match: MatchGroupUtilMatch): Renderable|Renderable[] ---@field createGame? fun(date: string, game: table, gameIndex: integer): Renderable|Renderable[] ---@field createFooter? fun(match: MatchGroupUtilMatch): Renderable|Renderable[] @@ -59,13 +60,22 @@ end -- Default body function ---@param match MatchGroupUtilMatch ----@param createGame fun(date: string, game: table, gameIndex: integer): Renderable|Renderable[] +---@param createGames? fun(match: MatchGroupUtilMatch): Renderable|Renderable[]? +---@param createGame? fun(date: string, game: table, gameIndex: integer): Renderable|Renderable[] +---@param options {maxBans: integer?}? ---@return Renderable[] -function MatchSummary.createDefaultBody(match, createGame) +function MatchSummary.createDefaultBody(match, createGames, createGame, options) + options = options or {} + + local characterBansData = MatchSummary.buildCharacterBanData(match.games, options.maxBans or 0) + return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(createGame, match.date)), + --- we assume that createGames and createGame are mutually exclusive, so we can safely call one or the other + ---@diagnostic disable-next-line: param-type-mismatch + createGames and createGames(match) or Array.map(match.games, FnUtil.curry(createGame, match.date)), MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.MapVeto(MatchSummary.preProcessMapVeto(match.extradata.mapveto, {game = match.game})) + MatchSummaryWidgets.MapVeto(MatchSummary.preProcessMapVeto(match.extradata.mapveto, {game = match.game})), + MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} ) end @@ -167,7 +177,7 @@ end ---Default createMatch function for usage in Custom MatchSummary ---@param matchData MatchGroupUtilMatch? ---@param CustomMatchSummary CustomMatchSummaryInterface ----@param options {teamStyle: teamStyle?, noScore: boolean?}? +---@param options {teamStyle: teamStyle?, noScore: boolean?, maxBans: integer?}? ---@return VNode? function MatchSummary.createMatch(matchData, CustomMatchSummary, options) if not matchData then @@ -181,7 +191,7 @@ function MatchSummary.createMatch(matchData, CustomMatchSummary, options) MatchSummary.createHeader(matchData, options), MatchSummaryWidgets.Body{ children = WidgetUtil.collect( - createBody(matchData, CustomMatchSummary.createGame), + createBody(matchData, CustomMatchSummary.createGames, CustomMatchSummary.createGame, options), Html.Fragment{ children = { MatchSummaryWidgets.Casters{casters = matchData.extradata.casters}, @@ -203,12 +213,17 @@ end ---Default getByMatchId function for usage in Custom MatchSummary ---@param CustomMatchSummary CustomMatchSummaryInterface ---@param args table ----@param options {teamStyle:teamStyle?, width: (fun(match: MatchGroupUtilMatch):string?)|string?, noScore:boolean?}? +---@param options {teamStyle:teamStyle?, width: (fun(match: MatchGroupUtilMatch):string?)|string?, +---noScore:boolean?, maxBans: integer?}? ---@return VNode function MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) assert( - (type(CustomMatchSummary.createBody) == 'function' or type(CustomMatchSummary.createGame) == 'function'), - 'createBody(match) or createGame(date, game, gameIndex) must be implemented in Module:MatchSummary' + ( + type(CustomMatchSummary.createBody) == 'function' or + type(CustomMatchSummary.createGame) == 'function' or + type(CustomMatchSummary.createGames) == 'function' + ), + 'One of createBody or createGame or createGames must be implemented in Module:MatchSummary' ) options = options or {} diff --git a/lua/wikis/deadlock/MatchSummary.lua b/lua/wikis/deadlock/MatchSummary.lua index e26bdd9d413..d2800492545 100644 --- a/lua/wikis/deadlock/MatchSummary.lua +++ b/lua/wikis/deadlock/MatchSummary.lua @@ -35,24 +35,20 @@ local DeadlockMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent( ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '480px', teamStyle = 'bracket'}) + local options = {width = '480px', teamStyle = 'bracket', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return { - MatchSummaryWidgets.GamesContainer{ - children = Array.map(match.games, function (game, gameIndex) - if game.status == STATUS_NOT_PLAYED then - return - end - return DeadlockMatchSummaryGameRow{game = game, gameIndex = gameIndex} - end) - }, - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} +---@return VNode +function CustomMatchSummary.createGames(match) + return MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + if game.status == STATUS_NOT_PLAYED then + return + end + return DeadlockMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) } end diff --git a/lua/wikis/dota2/MatchSummary.lua b/lua/wikis/dota2/MatchSummary.lua index 34a112829b9..a52e152842c 100644 --- a/lua/wikis/dota2/MatchSummary.lua +++ b/lua/wikis/dota2/MatchSummary.lua @@ -29,25 +29,20 @@ local Dota2MatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent(Gam ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px', teamStyle = 'bracket'}) + local options = {width = '400px', teamStyle = 'bracket', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return { - MatchSummaryWidgets.GamesContainer{ - children = Array.map(match.games, function (game, gameIndex) - if game.status == STATUS_NOT_PLAYED then - return - end - return Dota2MatchSummaryGameRow{game = game, gameIndex = gameIndex} - end) - }, - MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} +---@return VNode +function CustomMatchSummary.createGames(match) + return MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + if game.status == STATUS_NOT_PLAYED then + return + end + return Dota2MatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) } end diff --git a/lua/wikis/easportsfc/MatchSummary.lua b/lua/wikis/easportsfc/MatchSummary.lua index 1d1a508a3d0..5e7ff2db6cf 100644 --- a/lua/wikis/easportsfc/MatchSummary.lua +++ b/lua/wikis/easportsfc/MatchSummary.lua @@ -23,30 +23,28 @@ local NO_CHECK = '[[File:NoCheck.png|link=]]' local CustomMatchSummary = {} ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args) end ---@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) +---@return Renderable[] +function CustomMatchSummary.createGames(match) local hasSubMatches = Logic.readBool((match.extradata or {}).hassubmatches) - local games = Array.map(match.games, function(game) - if hasSubMatches then - return CustomMatchSummary._createSubMatch(game, match) - end - return CustomMatchSummary._createGame(game) - end) - return WidgetUtil.collect( - games + Array.map(match.games, function(game) + if hasSubMatches then + return CustomMatchSummary._createSubMatch(game, match) + end + return CustomMatchSummary._createGame(game) + end) ) end ---@param game MatchGroupUtilGame ----@return MatchSummaryRow +---@return Renderable function CustomMatchSummary._createGame(game) return MatchSummaryWidgets.Row{ classes = {'brkts-popup-body-game'}, @@ -63,7 +61,7 @@ end ---@param game MatchGroupUtilGame ---@param match MatchGroupUtilMatch ----@return MatchSummaryRow +---@return Renderable function CustomMatchSummary._createSubMatch(game, match) local players = CustomMatchSummary._extractPlayersFromGame(game, match) @@ -110,7 +108,7 @@ end ---@param game MatchGroupUtilGame ---@param opponentIndex integer ----@return string +---@return string? function CustomMatchSummary._subMatchPenaltyScore(game, opponentIndex) local scores = (game.extradata or {}).penaltyscores @@ -137,7 +135,7 @@ function CustomMatchSummary._players(players, opponentIndex, winner) :css('text-align', flip and 'right' or 'left') :css('width', '35%') :node(OpponentDisplay.BlockPlayers{ - opponent = {players = players}, + opponent = {players = players, type = 'solo', extradata = {}}, overflow = 'ellipsis', showLink = true, }) diff --git a/lua/wikis/fighters/MatchSummary.lua b/lua/wikis/fighters/MatchSummary.lua index 3d3d0fd2f47..85f3cb8cbda 100644 --- a/lua/wikis/fighters/MatchSummary.lua +++ b/lua/wikis/fighters/MatchSummary.lua @@ -59,7 +59,7 @@ end ---@param match MatchGroupUtilMatch ---@return VNode -function CustomMatchSummary.createBody(match) +function CustomMatchSummary.createGames(match) return MatchSummaryWidgets.GamesContainer{ children = Array.map(match.games, function (game, gameIndex) if Array.all(game.opponents, function(opponent) return Logic.isDeepEmpty(opponent.players) end) then diff --git a/lua/wikis/heroes/MatchSummary.lua b/lua/wikis/heroes/MatchSummary.lua index 5f9c7108649..bfee7e5da1a 100644 --- a/lua/wikis/heroes/MatchSummary.lua +++ b/lua/wikis/heroes/MatchSummary.lua @@ -13,6 +13,7 @@ local Logic = Lua.import('Module:Logic') local MatchSummary = Lua.import('Module:MatchSummary/Base') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All') + local WidgetUtil = Lua.import('Module:Widget/Util') local MAX_NUM_BANS = 3 diff --git a/lua/wikis/honorofkings/MatchSummary.lua b/lua/wikis/honorofkings/MatchSummary.lua index 82e7b61e119..b10e7395cf2 100644 --- a/lua/wikis/honorofkings/MatchSummary.lua +++ b/lua/wikis/honorofkings/MatchSummary.lua @@ -29,14 +29,13 @@ local HoKMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent(GameR ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'bracket'}) + local options = {width = '420px', teamStyle = 'bracket', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - +---@return VNode +function CustomMatchSummary.createGames(match) ---@param game MatchGroupUtilGame ---@return boolean local function hasCharacterData(game) @@ -47,17 +46,13 @@ function CustomMatchSummary.createBody(match) end) end - return { - 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 HoKMatchSummaryGameRow{game = game, gameIndex = gameIndex} - end) - }, - MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} + return 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 HoKMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) } end diff --git a/lua/wikis/lab/MatchSummary.lua b/lua/wikis/lab/MatchSummary.lua index ac65375a433..7dafcc42372 100644 --- a/lua/wikis/lab/MatchSummary.lua +++ b/lua/wikis/lab/MatchSummary.lua @@ -29,16 +29,12 @@ function CustomMatchSummary.getByMatchId(args) end ---@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})) +---@return VNode +function CustomMatchSummary.createGames(match) + return MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + return LabMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) } end diff --git a/lua/wikis/leagueoflegends/MatchSummary.lua b/lua/wikis/leagueoflegends/MatchSummary.lua index cbfc1418da0..1b2ceb4a096 100644 --- a/lua/wikis/leagueoflegends/MatchSummary.lua +++ b/lua/wikis/leagueoflegends/MatchSummary.lua @@ -29,25 +29,19 @@ local LoLMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent(GameR ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px'}) + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px', maxBans = MAX_NUM_BANS}) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return { - MatchSummaryWidgets.GamesContainer{ - children = Array.map(match.games, function (game, gameIndex) - if game.status == STATUS_NOT_PLAYED then - return - end - return LoLMatchSummaryGameRow{game = game, gameIndex = gameIndex} - end) - }, - MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} +---@return Renderable +function CustomMatchSummary.createGames(match) + return MatchSummaryWidgets.GamesContainer{ + children = Array.map(match.games, function (game, gameIndex) + if game.status == STATUS_NOT_PLAYED then + return + end + return LoLMatchSummaryGameRow{game = game, gameIndex = gameIndex} + end) } end diff --git a/lua/wikis/mobilelegends/MatchSummary.lua b/lua/wikis/mobilelegends/MatchSummary.lua index 6e2fbcd2a74..8c0c349056d 100644 --- a/lua/wikis/mobilelegends/MatchSummary.lua +++ b/lua/wikis/mobilelegends/MatchSummary.lua @@ -29,14 +29,13 @@ local MobileLegendsMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createCompo ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'hybrid'}) + local options = {width = '420px', teamStyle = 'hybrid', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - +---@return VNode +function CustomMatchSummary.createGames(match) ---@param game MatchGroupUtilGame ---@return boolean local function hasCharacterData(game) @@ -47,17 +46,13 @@ function CustomMatchSummary.createBody(match) end) end - return { - 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} + return 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) } end diff --git a/lua/wikis/overwatch/MatchSummary.lua b/lua/wikis/overwatch/MatchSummary.lua index 864a83af87a..0d1cc939a89 100644 --- a/lua/wikis/overwatch/MatchSummary.lua +++ b/lua/wikis/overwatch/MatchSummary.lua @@ -28,25 +28,19 @@ local OverwatchMatchSummaryGameRow = MatchSummaryWidgets.GameRow.createComponent ---@param args table ---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args) + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {maxBans = MAX_NUM_BANS}) end ---@param match MatchGroupUtilMatch ----@return VNode[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return { - 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} +---@return VNode +function CustomMatchSummary.createGames(match) + return 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) } end @@ -63,6 +57,7 @@ function GameRowComponentProps.createGameOpponentView(props, opponentIndex) local game = props.game local opponentCopy = Table.deepCopy(game.opponents[opponentIndex]) if opponentCopy.score and game.mode == 'Push' then + ---@diagnostic disable-next-line: assign-type-mismatch opponentCopy.score = opponentCopy.score .. 'm' end diff --git a/lua/wikis/pokemon/MatchSummary.lua b/lua/wikis/pokemon/MatchSummary.lua index a2c90221eb9..f4762e12ffc 100644 --- a/lua/wikis/pokemon/MatchSummary.lua +++ b/lua/wikis/pokemon/MatchSummary.lua @@ -10,7 +10,6 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') local Logic = Lua.import('Module:Logic') local Operator = Lua.import('Module:Operator') @@ -22,28 +21,17 @@ local MAX_NUM_BANS = 5 local NUM_CHAMPIONS_PICK = 5 ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', teamStyle = 'bracket'}) -end - ----@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(CustomMatchSummary._createGame, match.date)), - MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} - ) + local options = {width = '420px', teamStyle = 'bracket', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param date string ---@param game MatchGroupUtilGame ---@param gameIndex integer ----@return MatchSummaryRow? -function CustomMatchSummary._createGame(date, game, gameIndex) +---@return Renderable? +function CustomMatchSummary.createGame(date, game, gameIndex) local extradata = game.extradata or {} -- TODO: Change to use participant data diff --git a/lua/wikis/smash/MatchSummary.lua b/lua/wikis/smash/MatchSummary.lua index 0648c51025f..07ad26318c2 100644 --- a/lua/wikis/smash/MatchSummary.lua +++ b/lua/wikis/smash/MatchSummary.lua @@ -22,7 +22,7 @@ local PlayerDisplay = Lua.import('Module:Player/Display') local CustomMatchSummary = {} ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, { width = '350px', @@ -40,19 +40,15 @@ function CustomMatchSummary.isTeam(match) end ---@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) - local games = Array.map(match.games, function(game) +---@return Renderable[] +function CustomMatchSummary.createGames(match) + return Array.map(match.games, function(game) return CustomMatchSummary._createStandardGame(game, { opponents = match.opponents, game = match.game, teamMode = CustomMatchSummary.isTeam(match), }) end) - - return WidgetUtil.collect( - games - ) end ---@param game MatchGroupUtilGame @@ -67,7 +63,7 @@ end ---@param game MatchGroupUtilGame ---@param props {game: string?, teamMode: boolean, opponents: table[]} ----@return Widget? +---@return Renderable? function CustomMatchSummary._createStandardGame(game, props) if not game or Logic.isDeepEmpty(game.opponents) then return @@ -101,7 +97,7 @@ end ---@param game string? ---@param reverse boolean? ---@param displayPlayerNames boolean ----@return Html +---@return Renderable function CustomMatchSummary._createCharacterDisplay(players, game, reverse, displayPlayerNames) local CharacterIcons = Lua.import('Module:CharacterIcons/' .. (game or ''), {loadData = true}) local wrapper = mw.html.create('div'):css{ diff --git a/lua/wikis/smite/MatchSummary.lua b/lua/wikis/smite/MatchSummary.lua index 8e3fde587c2..8710d939f1a 100644 --- a/lua/wikis/smite/MatchSummary.lua +++ b/lua/wikis/smite/MatchSummary.lua @@ -9,8 +9,6 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') -local Array = Lua.import('Module:Array') -local FnUtil = Lua.import('Module:FnUtil') local Logic = Lua.import('Module:Logic') local MatchSummary = Lua.import('Module:MatchSummary/Base') @@ -21,27 +19,17 @@ local MAX_NUM_BANS = 5 local NUM_GODS_PICK = 5 ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '400px', teamStyle = 'bracket'}) -end - ----@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return WidgetUtil.collect( - Array.map(match.games, FnUtil.curry(CustomMatchSummary._createGame, match.date)), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} - ) + local options = {width = '400px', teamStyle = 'bracket', maxBans = MAX_NUM_BANS} + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, options) end ---@param date string ---@param game MatchGroupUtilGame ---@param gameIndex integer ----@return MatchSummaryRow -function CustomMatchSummary._createGame(date, game, gameIndex) +---@return Renderable +function CustomMatchSummary.createGame(date, game, gameIndex) local extradata = game.extradata or {} -- TODO: Change to use participant data diff --git a/lua/wikis/wildrift/MatchSummary.lua b/lua/wikis/wildrift/MatchSummary.lua index c1f0af1369e..aa089971d98 100644 --- a/lua/wikis/wildrift/MatchSummary.lua +++ b/lua/wikis/wildrift/MatchSummary.lua @@ -9,7 +9,6 @@ local CustomMatchSummary = {} local Lua = require('Module:Lua') -local Array = Lua.import('Module:Array') local Logic = Lua.import('Module:Logic') local MatchSummary = Lua.import('Module:MatchSummary/Base') @@ -20,27 +19,16 @@ local MAX_NUM_BANS = 5 local NUM_CHAMPIONS_PICK = 5 ---@param args table ----@return Widget +---@return Renderable function CustomMatchSummary.getByMatchId(args) - return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px'}) -end - ----@param match MatchGroupUtilMatch ----@return Widget[] -function CustomMatchSummary.createBody(match) - local characterBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS) - - return WidgetUtil.collect( - Array.map(match.games, CustomMatchSummary._createGame), - MatchSummaryWidgets.Mvp(match.extradata.mvp), - MatchSummaryWidgets.CharacterBanTable{bans = characterBansData, date = match.date} - ) + return MatchSummary.defaultGetByMatchId(CustomMatchSummary, args, {width = '420px', maxBans = MAX_NUM_BANS}) end +---@param date string ---@param game MatchGroupUtilGame ---@param gameIndex integer ----@return MatchSummaryRow? -function CustomMatchSummary._createGame(game, gameIndex) +---@return Renderable? +function CustomMatchSummary.createGame(date, game, gameIndex) local extradata = game.extradata or {} -- TODO: Change to use participant data