Skip to content
Open
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
19 changes: 13 additions & 6 deletions lua/wikis/brawlstars/MatchSummary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
local WidgetUtil = Lua.import('Module:Widget/Util')

local MAX_NUM_BANS = 3

local CustomMatchSummary = {}

---@param args table
Expand All @@ -32,14 +34,19 @@ end
---@return Renderable[]
function CustomMatchSummary.createBody(match)
local globalBans = (match.extradata or {}).globalbans

local gameBansData = MatchSummary.buildCharacterBanData(match.games, MAX_NUM_BANS)

-- To make the Global Bans doesn't get count as Game 1
Array.forEach(gameBansData, function(banData, gameIndex)
if Logic.isNotDeepEmpty(banData) then
banData.label = 'Game ' .. gameIndex
end
end)

local characterBansData = Array.extend(
Logic.isNotDeepEmpty(globalBans) and {globalBans.team1 or {}, globalBans.team2 or {}, label = 'Global Bans'} or nil,
Array.map(match.games, function(game, gameIndex)
local extradata = game.extradata or {}
local bans = extradata.bans or {}
if Logic.isDeepEmpty(bans) then return end
return {bans.team1 or {}, bans.team2 or {}, label = 'Game ' .. gameIndex}
end)
gameBansData
)
Comment thread
steve020607 marked this conversation as resolved.

return WidgetUtil.collect(
Expand Down
2 changes: 1 addition & 1 deletion lua/wikis/commons/MatchSummary/Base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ end

---@param games table[]
---@param maxNumberOfBans integer
---@return {[1]: string[], [2]: string[], start: integer?}[]
---@return {[1]: string[], [2]: string[], start: integer?, label: string?}[]
function MatchSummary.buildCharacterBanData(games, maxNumberOfBans)
return Array.map(games, function(game)
local extradata = game.extradata or {}
Expand Down
Loading