@@ -30,7 +30,8 @@ local MATCH_LINK_PRIORITY = Lua.import('Module:Links/MatchPriorityGroups', {load
3030local TBD = Abbreviation .make {text = ' TBD' , title = ' To Be Determined' }
3131
3232--- @class CustomMatchSummaryInterface
33- --- @field createBody ? fun ( match : MatchGroupUtilMatch ): Renderable | Renderable[]
33+ --- @field createBody ? fun ( match : MatchGroupUtilMatch ): Renderable | Renderable[] @deprecated
34+ --- @field createGames ? fun ( match : MatchGroupUtilMatch ): Renderable | Renderable[]
3435--- @field createGame ? fun ( date : string , game : table , gameIndex : integer ): Renderable | Renderable[]
3536--- @field createFooter ? fun ( match : MatchGroupUtilMatch ): Renderable | Renderable[]
3637
5960
6061-- Default body function
6162--- @param match MatchGroupUtilMatch
62- --- @param createGame fun ( date : string , game : table , gameIndex : integer ): Renderable | Renderable[]
63+ --- @param createGames ? fun ( match : MatchGroupUtilMatch ): Renderable | Renderable[] ?
64+ --- @param createGame ? fun ( date : string , game : table , gameIndex : integer ): Renderable | Renderable[]
65+ --- @param options { maxBans : integer ?}?
6366--- @return Renderable[]
64- function MatchSummary .createDefaultBody (match , createGame )
67+ function MatchSummary .createDefaultBody (match , createGames , createGame , options )
68+ options = options or {}
69+
70+ local characterBansData = MatchSummary .buildCharacterBanData (match .games , options .maxBans or 0 )
71+
6572 return WidgetUtil .collect (
66- Array .map (match .games , FnUtil .curry (createGame , match .date )),
73+ --- we assume that createGames and createGame are mutually exclusive, so we can safely call one or the other
74+ --- @diagnostic disable-next-line : param-type-mismatch
75+ createGames and createGames (match ) or Array .map (match .games , FnUtil .curry (createGame , match .date )),
6776 MatchSummaryWidgets .Mvp (match .extradata .mvp ),
68- MatchSummaryWidgets .MapVeto (MatchSummary .preProcessMapVeto (match .extradata .mapveto , {game = match .game }))
77+ MatchSummaryWidgets .MapVeto (MatchSummary .preProcessMapVeto (match .extradata .mapveto , {game = match .game })),
78+ MatchSummaryWidgets .CharacterBanTable {bans = characterBansData , date = match .date }
6979 )
7080end
7181
167177--- Default createMatch function for usage in Custom MatchSummary
168178--- @param matchData MatchGroupUtilMatch ?
169179--- @param CustomMatchSummary CustomMatchSummaryInterface
170- --- @param options { teamStyle : teamStyle ?, noScore : boolean ?}?
180+ --- @param options { teamStyle : teamStyle ?, noScore : boolean ?, maxBans : integer ? }?
171181--- @return VNode ?
172182function MatchSummary .createMatch (matchData , CustomMatchSummary , options )
173183 if not matchData then
@@ -181,7 +191,7 @@ function MatchSummary.createMatch(matchData, CustomMatchSummary, options)
181191 MatchSummary .createHeader (matchData , options ),
182192 MatchSummaryWidgets .Body {
183193 children = WidgetUtil .collect (
184- createBody (matchData , CustomMatchSummary .createGame ),
194+ createBody (matchData , CustomMatchSummary .createGames , CustomMatchSummary . createGame , options ),
185195 Html .Fragment {
186196 children = {
187197 MatchSummaryWidgets .Casters {casters = matchData .extradata .casters },
@@ -203,12 +213,17 @@ end
203213--- Default getByMatchId function for usage in Custom MatchSummary
204214--- @param CustomMatchSummary CustomMatchSummaryInterface
205215--- @param args table
206- --- @param options { teamStyle : teamStyle ?, width : (fun ( match : MatchGroupUtilMatch ): string ?)| string ?, noScore : boolean ?}?
216+ --- @param options { teamStyle : teamStyle ?, width : (fun ( match : MatchGroupUtilMatch ): string ?)| string ?,
217+ --- noScore:boolean?, maxBans: integer?}?
207218--- @return VNode
208219function MatchSummary .defaultGetByMatchId (CustomMatchSummary , args , options )
209220 assert (
210- (type (CustomMatchSummary .createBody ) == ' function' or type (CustomMatchSummary .createGame ) == ' function' ),
211- ' createBody(match) or createGame(date, game, gameIndex) must be implemented in Module:MatchSummary'
221+ (
222+ type (CustomMatchSummary .createBody ) == ' function' or
223+ type (CustomMatchSummary .createGame ) == ' function' or
224+ type (CustomMatchSummary .createGames ) == ' function'
225+ ),
226+ ' One of createBody or createGame or createGames must be implemented in Module:MatchSummary'
212227 )
213228
214229 options = options or {}
0 commit comments