Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/wikis/ageofempires/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -53,7 +53,7 @@

---@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
Expand Down
8 changes: 4 additions & 4 deletions lua/wikis/brawlhalla/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand All @@ -20,14 +20,14 @@
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
)
Expand All @@ -43,7 +43,7 @@
end

---@param game MatchGroupUtilGame
---@return Widget?
---@return Renderable?
function CustomMatchSummary._createGame(game)
if not game.map and not game.winner then return end

Expand Down
35 changes: 25 additions & 10 deletions lua/wikis/commons/MatchSummary/Base.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary/Base
Expand Down Expand Up @@ -30,7 +30,8 @@
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[]

Expand Down Expand Up @@ -59,13 +60,22 @@

-- 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[]
Comment thread
Rathoz marked this conversation as resolved.
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

Expand Down Expand Up @@ -167,7 +177,7 @@
---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
Expand All @@ -181,7 +191,7 @@
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},
Expand All @@ -203,12 +213,17 @@
---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 {}
Expand Down
26 changes: 11 additions & 15 deletions lua/wikis/deadlock/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -35,24 +35,20 @@
---@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

Expand Down
27 changes: 11 additions & 16 deletions lua/wikis/dota2/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -29,25 +29,20 @@
---@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

Expand Down
28 changes: 13 additions & 15 deletions lua/wikis/easportsfc/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand All @@ -23,30 +23,28 @@
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'},
Expand All @@ -63,7 +61,7 @@

---@param game MatchGroupUtilGame
---@param match MatchGroupUtilMatch
---@return MatchSummaryRow
---@return Renderable
function CustomMatchSummary._createSubMatch(game, match)
local players = CustomMatchSummary._extractPlayersFromGame(game, match)

Expand Down Expand Up @@ -110,7 +108,7 @@

---@param game MatchGroupUtilGame
---@param opponentIndex integer
---@return string
---@return string?
function CustomMatchSummary._subMatchPenaltyScore(game, opponentIndex)
local scores = (game.extradata or {}).penaltyscores

Expand All @@ -137,7 +135,7 @@
: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,
})
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/fighters/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -59,7 +59,7 @@

---@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
Expand Down
1 change: 1 addition & 0 deletions lua/wikis/heroes/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand All @@ -13,6 +13,7 @@

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
Expand Down
27 changes: 11 additions & 16 deletions lua/wikis/honorofkings/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -29,14 +29,13 @@
---@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)
Expand All @@ -47,17 +46,13 @@
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

Expand Down
16 changes: 6 additions & 10 deletions lua/wikis/lab/MatchSummary.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
-- @Liquipedia
-- page=Module:MatchSummary
Expand Down Expand Up @@ -29,16 +29,12 @@
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

Expand Down
26 changes: 10 additions & 16 deletions lua/wikis/leagueoflegends/MatchSummary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading
Loading