diff --git a/components/match2/commons/match_summary_base_ffa.lua b/components/match2/commons/match_summary_base_ffa.lua index 67165f58156..5589badbfe7 100644 --- a/components/match2/commons/match_summary_base_ffa.lua +++ b/components/match2/commons/match_summary_base_ffa.lua @@ -9,6 +9,7 @@ local Array = require('Module:Array') local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') +local Operator = require('Module:Operator') local Table = require('Module:Table') local OpponentLibraries = require('Module:OpponentLibraries') @@ -42,6 +43,7 @@ local STATUS_ICONS = { local MATCH_OVERVIEW_COLUMNS = { { + id = 'status', class = 'cell--status', show = function(match) return Table.any(match.extradata.placementinfo or {}, function(_, value) @@ -66,6 +68,7 @@ local MATCH_OVERVIEW_COLUMNS = { }, }, { + id = 'rank', sortable = true, sortType = 'rank', class = 'cell--rank', @@ -90,12 +93,13 @@ local MATCH_OVERVIEW_COLUMNS = { }, }, { + id = 'opponent', sortable = true, sortType = 'team', class = 'cell--team', icon = 'team', header = { - value = 'Team', + value = 'Participant', }, sortVal = { value = function (opponent, idx) @@ -115,6 +119,7 @@ local MATCH_OVERVIEW_COLUMNS = { }, }, { + id = 'totalPoints', sortable = true, sortType = 'total-points', class = 'cell--total-points', @@ -135,6 +140,7 @@ local MATCH_OVERVIEW_COLUMNS = { }, }, { + id = 'matchPoints', sortable = true, sortType = 'match-points', class = 'cell--match-points', @@ -153,13 +159,14 @@ local MATCH_OVERVIEW_COLUMNS = { }, row = { value = function (opponent, idx) - return opponent.matchPointReachedIn and "Game " .. opponent.matchPointReachedIn or nil + return opponent.matchPointReachedIn and 'Game ' .. opponent.matchPointReachedIn or nil end, }, }, } local GAME_OVERVIEW_COLUMNS = { { + id = 'placement', show = function(match) return (match.extradata.settings or {}).showGameDetails end, @@ -190,6 +197,7 @@ local GAME_OVERVIEW_COLUMNS = { }, }, { + id = 'kills', show = function(match) if (match.extradata.settings or {}).showGameDetails == false then return false @@ -205,11 +213,12 @@ local GAME_OVERVIEW_COLUMNS = { }, row = { value = function (opponent) - return opponent.scoreBreakdown.kills + return (opponent.scoreBreakdown or {}).kills end, }, }, { + id = 'points', show = function(match) return not (match.extradata.settings or {}).showGameDetails end, @@ -227,6 +236,7 @@ local GAME_OVERVIEW_COLUMNS = { } local GAME_STANDINGS_COLUMNS = { { + id = 'rank', sortable = true, sortType = 'rank', class = 'cell--rank', @@ -259,6 +269,7 @@ local GAME_STANDINGS_COLUMNS = { }, }, { + id = 'opponent', sortable = true, sortType = 'team', class = 'cell--team', @@ -284,6 +295,7 @@ local GAME_STANDINGS_COLUMNS = { }, }, { + id = 'totalPoints', sortable = true, sortType = 'total-points', class = 'cell--total-points', @@ -304,6 +316,7 @@ local GAME_STANDINGS_COLUMNS = { }, }, { + id = 'placements', sortable = true, sortType = 'placements', class = 'cell--placements', @@ -313,16 +326,17 @@ local GAME_STANDINGS_COLUMNS = { }, sortVal = { value = function (opponent, idx) - return opponent.scoreBreakdown.placePoints + return (opponent.scoreBreakdown or {}).placePoints end, }, row = { value = function (opponent, idx) - return opponent.scoreBreakdown.placePoints + return (opponent.scoreBreakdown or {}).placePoints end, }, }, { + id = 'kills', sortable = true, sortType = 'kills', class = 'cell--kills', @@ -332,12 +346,12 @@ local GAME_STANDINGS_COLUMNS = { }, sortVal = { value = function (opponent, idx) - return opponent.scoreBreakdown.killPoints + return (opponent.scoreBreakdown or {}).killPoints end, }, row = { value = function (opponent, idx) - return opponent.scoreBreakdown.killPoints + return (opponent.scoreBreakdown or {}).killPoints end, }, }, @@ -389,11 +403,25 @@ function MatchSummaryFfa.createScoringData(match) return newScores end +---@class FfaMatchSummaryParser +---@field adjustMatchColumns? fun(defaultColumns: table[]): table[] +---@field adjustGameOverviewColumns? fun(defaultColumns: table[]): table[] +---@field gameHeader? fun(match: table, game: table, gameIndex: integer): Widget[] + ---@param match table +---@param Parser FfaMatchSummaryParser? ---@return MatchSummaryFfaTable -function MatchSummaryFfa.standardMatch(match) +function MatchSummaryFfa.standardMatch(match, Parser) + Parser = Parser or {} + local matchColumns = Parser.adjustMatchColumns + and Parser.adjustMatchColumns(MATCH_OVERVIEW_COLUMNS) + or MATCH_OVERVIEW_COLUMNS + local gameOverviewColumns = Parser.adjustGameOverviewColumns + and Parser.adjustGameOverviewColumns(GAME_OVERVIEW_COLUMNS) + or GAME_OVERVIEW_COLUMNS + local rows = Array.map(match.opponents, function (opponent, index) - local children = Array.map(MATCH_OVERVIEW_COLUMNS, function(column) + local children = Array.map(matchColumns, function(column) if column.show and not column.show(match) then return end @@ -414,7 +442,7 @@ function MatchSummaryFfa.standardMatch(match) children = Array.map(opponent.games, function(gameOpponent) local gameRow = HtmlWidgets.Div{ classes = {'panel-table__cell', 'cell--game'}, - children = Array.map(GAME_OVERVIEW_COLUMNS, function(column) + children = Array.map(gameOverviewColumns, function(column) if column.show and not column.show(match) then return end @@ -431,7 +459,7 @@ function MatchSummaryFfa.standardMatch(match) return MatchSummaryWidgets.TableRow{children = children} end) - local cells = Array.map(MATCH_OVERVIEW_COLUMNS, function(column) + local cells = Array.map(matchColumns, function(column) if column.show and not column.show(match) then return end @@ -446,6 +474,9 @@ function MatchSummaryFfa.standardMatch(match) } end) + local dates = Array.map(match.games, Operator.property('date')) + local gamesHaveDifferentDates = Array.any(dates, function(date) return date ~= match.date end) + table.insert(cells, HtmlWidgets.Div{ classes = {'panel-table__cell', 'cell--game-container-nav-holder'}, attributes = { @@ -474,12 +505,12 @@ function MatchSummaryFfa.standardMatch(match) } } }, - MatchSummaryWidgets.GameCountdown{game = game}, + gamesHaveDifferentDates and MatchSummaryWidgets.GameCountdown{game = game} or nil, } }, HtmlWidgets.Div{ classes = {'panel-table__cell__game-details'}, - children = Array.map(GAME_OVERVIEW_COLUMNS, function(column) + children = Array.map(gameOverviewColumns, function(column) if column.show and not column.show(match) then return end @@ -505,11 +536,19 @@ function MatchSummaryFfa.standardMatch(match) }} end +---@class FfaGameSummaryParser +---@field adjustGameStandingsColumns? fun(defaultColumns: table[], game: table): table[] + ---@param game table +---@param Parser FfaGameSummaryParser? ---@return MatchSummaryFfaTable -function MatchSummaryFfa.standardGame(game) +function MatchSummaryFfa.standardGame(game, Parser) + Parser = Parser or {} + local gameStandingsColumns = Parser.adjustGameStandingsColumns + and Parser.adjustGameStandingsColumns(GAME_STANDINGS_COLUMNS, game) + or GAME_STANDINGS_COLUMNS local rows = Array.map(game.opponents, function (opponent, index) - local children = Array.map(GAME_STANDINGS_COLUMNS, function(column) + local children = Array.map(gameStandingsColumns, function(column) if column.show and not column.show(game) then return end @@ -525,7 +564,7 @@ function MatchSummaryFfa.standardGame(game) end) return MatchSummaryWidgets.Table{children = { - MatchSummaryWidgets.TableHeader{children = Array.map(GAME_STANDINGS_COLUMNS, function(column) + MatchSummaryWidgets.TableHeader{children = Array.map(gameStandingsColumns, function(column) if column.show and not column.show(game) then return end diff --git a/components/match2/commons/starcraft_starcraft2/game_summary_starcraft_ffa.lua b/components/match2/commons/starcraft_starcraft2/game_summary_starcraft_ffa.lua new file mode 100644 index 00000000000..42cc73415b9 --- /dev/null +++ b/components/match2/commons/starcraft_starcraft2/game_summary_starcraft_ffa.lua @@ -0,0 +1,56 @@ +--- +-- @Liquipedia +-- wiki=commons +-- page=Module:GameSummary/Starcraft/FFa +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local CustomGameSummary = {} + +local Array = require('Module:Array') +local Lua = require('Module:Lua') + +local MatchGroupUtil = Lua.import('Module:MatchGroup/Util/Starcraft') + +local SummaryHelper = Lua.import('Module:MatchSummary/Base/Ffa') +local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') + +---@param props {bracketId: string, matchId: string, gameIdx: integer} +---@return Html +function CustomGameSummary.getGameByMatchId(props) + local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) + + local game = match.games[props.gameIdx] + assert(game, 'Error Game ID ' .. tostring(props.gameIdx) .. ' not found') + + game.stream = match.stream + + SummaryHelper.updateGameOpponents(game, match.opponents) + + return MatchSummaryWidgets.Tab{ + matchId = match.matchId, + idx = props.gameIdx, + children = { + MatchSummaryWidgets.GameDetails{game = game}, + SummaryHelper.standardGame(game, CustomGameSummary) + } + } +end + +---@param columns table[] +---@param game table +---@return table[] +function CustomGameSummary.adjustGameStandingsColumns(columns, game) + return Array.map(columns, function(column) + if column.id == 'totalPoints' and game.extradata.settings.noscore then + return + elseif column.id == 'placements' or column.id == 'kills' then + return + end + + return column + end) +end + +return CustomGameSummary diff --git a/components/match2/commons/starcraft_starcraft2/match_group_display_single_match_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_group_display_single_match_starcraft.lua deleted file mode 100644 index 7c3131512d4..00000000000 --- a/components/match2/commons/starcraft_starcraft2/match_group_display_single_match_starcraft.lua +++ /dev/null @@ -1,61 +0,0 @@ ---- --- @Liquipedia --- wiki=commons --- page=Module:MatchGroup/Display/SingleMatch/Starcraft --- --- Please see https://github.com/Liquipedia/Lua-Modules to contribute --- - -local Class = require('Module:Class') -local Lua = require('Module:Lua') -local DisplayUtil = require('Module:DisplayUtil') -local Table = require('Module:Table') - -local SingleMatchDisplay = Lua.import('Module:MatchGroup/Display/SingleMatch') -local StarcraftMatchSummary = Lua.import('Module:MatchSummary/Starcraft') -local StarcraftMatchGroupUtil = Lua.import('Module:MatchGroup/Util/Starcraft') - -local StarcraftSingleMatchDisplay = Class.new(SingleMatchDisplay) - ----@param props {matchId: string, config: SingleMatchConfigOptions} ----@return Html -function StarcraftSingleMatchDisplay.SingleMatchContainer(props) - local bracketId, _ = StarcraftMatchGroupUtil.splitMatchId(props.matchId) - - assert(bracketId, 'Missing or invalid matchId') - - local match = StarcraftMatchGroupUtil.fetchMatchForBracketDisplay(bracketId, props.matchId) - - return match - and StarcraftSingleMatchDisplay.SingleMatch{ - match = match, - config = Table.merge(props.config, { - MatchSummaryContainer = StarcraftMatchSummary.MatchSummaryContainer, - }) - } - or '' -end - ----@param props {config: SingleMatchConfigOptions, match: StarcraftMatchGroupUtilMatch} ----@return Html -function StarcraftSingleMatchDisplay.SingleMatch(props) - local singleMatchNode = SingleMatchDisplay.SingleMatch(props) - - return singleMatchNode - :css('width', props.match.isFfa and 'unset' or nil) - :css('background-color', props.match.isFfa and 'unset' or nil) -end - ----Display component for a match in a singleMatch. Consists of the match summary. ----@param props {MatchSummaryContainer: function, match: StarcraftMatchGroupUtilMatch} ----@return Html -function StarcraftSingleMatchDisplay.Match(props) - local bracketId = StarcraftMatchGroupUtil.splitMatchId(props.match.matchId) - return DisplayUtil.TryPureComponent(props.MatchSummaryContainer, { - bracketId = bracketId, - matchId = props.match.matchId, - config = {showScore = not props.match.noScore}, - }, require('Module:Error/Display').ErrorDetails) -end - -return StarcraftSingleMatchDisplay diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua index 64809a50953..34d5d0ea1e8 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua @@ -55,9 +55,10 @@ function StarcraftFfaMatchGroupInput.processMatch(matchInput, options) end ---@param match table +---@param numberOfOpponents integer ---@return table -function MatchFunctions.parseSettings(match) - return {} +function MatchFunctions.parseSettings(match, numberOfOpponents) + return {noscore = Logic.readBool(match.noscore)} end ---@param opponent table @@ -65,10 +66,8 @@ end ---@param match table function MatchFunctions.adjustOpponent(opponent, opponentIndex, match) BaseMatchFunctions.adjustOpponent(opponent, opponentIndex) - opponent.extradata = opponent.extradata or {} - opponent.extradata.noscore = Logic.readBool(match.noscore) -- set score to 0 for all opponents if it is a match without scores - if opponent.extradata.noscore then + if Logic.readBool(match.noscore) then opponent.score = 0 end end @@ -135,8 +134,8 @@ function MatchFunctions.getExtraData(match, games, opponents, settings) local extradata = { casters = MatchGroupInputUtil.readCasters(match, {noSort = true}), ffa = 'true', - noscore = tostring(Logic.readBool(match.noscore)), showplacement = Logic.readBoolOrNil(match.showplacement), + settings = settings, } for prefix, vetoMap, vetoIndex in Table.iter.pairsByPrefix(match, 'veto') do @@ -187,11 +186,13 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores) extradata = { comment = mapInput.comment, displayname = mapInput.mapDisplayName, + settings = {noscore = not hasScores}, } } if mapInput.date then - Table.mergeInto(map, MatchGroupInputUtil.readDate(map.date)) + Table.mergeInto(map, MatchGroupInputUtil.readDate(mapInput.date)) + map.extradata.dateexact = map.dateexact end if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then diff --git a/components/match2/commons/starcraft_starcraft2/match_group_util_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_group_util_starcraft.lua index 9099b744ef8..596b0de8789 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_util_starcraft.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_util_starcraft.lua @@ -54,7 +54,6 @@ local StarcraftMatchGroupUtil = Table.deepCopy(MatchGroupUtil) ---@class StarcraftMatchGroupUtilMatch: MatchGroupUtilMatch ---@field games StarcraftMatchGroupUtilGame[] ---@field isFfa boolean ----@field noScore boolean? ---@field opponentMode 'uniform'|'team' ---@field opponents StarcraftStandardOpponent[] ---@field vetoes StarcraftMatchGroupUtilVeto[] @@ -109,7 +108,6 @@ function StarcraftMatchGroupUtil.matchFromRecord(record) -- Misc match.isFfa = Logic.readBool(Table.extract(extradata, 'ffa')) - match.noScore = Logic.readBoolOrNil(Table.extract(extradata, 'noscore')) match.casters = String.nilIfEmpty(Table.extract(extradata, 'casters')) return match diff --git a/components/match2/commons/starcraft_starcraft2/match_summary_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_summary_starcraft.lua index 1d9003123f7..3ad09fac2fd 100644 --- a/components/match2/commons/starcraft_starcraft2/match_summary_starcraft.lua +++ b/components/match2/commons/starcraft_starcraft2/match_summary_starcraft.lua @@ -18,7 +18,6 @@ local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') local HtmlWidgets = Lua.import('Module:Widget/Html/All') local MatchSummary = Lua.import('Module:MatchSummary/Base') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/All') -local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local MatchGroupUtilStarcraft = Lua.import('Module:MatchGroup/Util/Starcraft') local WidgetUtil = Lua.import('Module:Widget/Util') @@ -39,16 +38,6 @@ local StarcraftMatchSummary = {} ---@param args {bracketId: string, matchId: string, config: table?} ---@return Html function StarcraftMatchSummary.getByMatchId(args) - local match = MatchGroupUtil.fetchMatchForBracketDisplay(args.bracketId, args.matchId) - ---@cast match StarcraftMatchGroupUtilMatch - - if match.isFfa then - return Lua.import('Module:MatchSummary/Starcraft/Ffa').getByMatchId{ - match = match, - config = args.config - } - end - return MatchSummary.defaultGetByMatchId(StarcraftMatchSummary, args):addClass('brkts-popup-sc') end diff --git a/components/match2/commons/starcraft_starcraft2/match_summary_starcraft_ffa.lua b/components/match2/commons/starcraft_starcraft2/match_summary_starcraft_ffa.lua index f446f463f53..edd3e7a8863 100644 --- a/components/match2/commons/starcraft_starcraft2/match_summary_starcraft_ffa.lua +++ b/components/match2/commons/starcraft_starcraft2/match_summary_starcraft_ffa.lua @@ -9,471 +9,76 @@ local StarcraftMatchSummaryFfa = {} local Array = require('Module:Array') -local Date = require('Module:Date/Ext') -local FnUtil = require('Module:FnUtil') -local Icon = require('Module:Icon') -local Logic = require('Module:Logic') local Lua = require('Module:Lua') -local Ordinal = require('Module:Ordinal') local Table = require('Module:Table') -local Timezone = require('Module:Timezone') -local VodLink = require('Module:VodLink') -local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper') -local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local OpponentLibraries = require('Module:OpponentLibraries') local OpponentDisplay = OpponentLibraries.OpponentDisplay -local TBD = 'TBD' -local UTC = Timezone.getTimezoneString('UTC') - -local PHASE_ICONS = { - finished = {iconName = 'concluded', color = 'icon--green'}, - ongoing = {iconName = 'live', color = 'icon--red'}, - upcoming = {iconName = 'upcomingandongoing'}, -} - -local PLACEMENT_BG = { - 'cell--gold', - 'cell--silver', - 'cell--bronze', - 'cell--copper', -} - -local TROPHY_COLOR = { - 'icon--gold', - 'icon--silver', - 'icon--bronze', - 'icon--copper', -} +local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') +local BaseMatchSummary = Lua.import('Module:MatchSummary/Base/Ffa') -local STATUS_ICONS = { - advances = 'fas fa-chevron-double-up', - eliminated = 'fas fa-skull', -} +local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') +local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local MATCH_STANDING_COLUMNS = { - { - class = 'cell--status', - --iconClass = 'fas fa-hashtag', - show = { - value = function(match) - return match.finished and #Array.filter(match.opponents, function(opponent) - return Logic.readBool(opponent.advances) - end) > 1 - end - }, - row = { - value = function (opponent, idx) - local statusIcon = Logic.readBool(opponent.advances) and STATUS_ICONS.advances or STATUS_ICONS.eliminated - return mw.html.create('i') - :addClass(statusIcon) - end, - }, - }, - { - class = 'cell--rank', - iconClass = 'fas fa-hashtag', - header = { - value = 'Rank', - }, - row = { - value = function (opponent, idx) - local place = opponent.placement ~= -1 and opponent.placement or idx - local worstPlace = opponent.extradata.worstPlace - local icon, color = StarcraftMatchSummaryFfa._getTrophy(place) - return mw.html.create() - :tag('i'):addClass('panel-table__cell-icon'):addClass(icon):addClass(color):done() - :tag('span'):wikitext(StarcraftMatchSummaryFfa._displayRank(place, worstPlace)):done() - end, - }, - }, - { - class = 'cell--team', - iconClass = 'fas fa-users', - header = { - value = 'Participant', - }, - row = { - value = function (opponent, idx) - return StarcraftMatchSummaryFfa._displayOpponent(opponent) - end, - }, - }, - { - class = 'cell--total-points', - iconClass = 'fas fa-star', - header = { - value = 'Total Points', - mobileValue = 'Pts.', - }, - show = { - value = function(match) - return not Logic.readBool(match.noScore) - end - }, - row = { - value = function (opponent, idx) - return OpponentDisplay.InlineScore(opponent) - end, - }, - }, - game = { - { - class = 'panel-table__cell__game-placement', - iconClass = 'fas fa-trophy-alt', - header = { - value = 'Place', - mobileValue = 'P.', - }, - row = { - class = function (opponent) - return PLACEMENT_BG[opponent.placement] - end, - value = function (opponent) - local placementDisplay - if opponent.status and opponent.status ~= 'S' then - placementDisplay = opponent.status or '-' - else - placementDisplay = StarcraftMatchSummaryFfa._displayRank(opponent.placement) - end - local icon, color = StarcraftMatchSummaryFfa._getTrophy(opponent.placement) - return mw.html.create() - :tag('i') - :addClass('panel-table__cell-icon') - :addClass(icon) - :addClass(color) - :done() - :tag('span'):addClass('panel-table__cell-game__text') - :wikitext(placementDisplay):done() - end, - }, - }, - { - class = 'panel-table__cell__game-kills', - iconClass = 'fas fa-star', - show = { - value = function(match) - return not Logic.readBool(match.noScore) - end - }, - header = { - value = 'Points', - mobileValue = 'Pts.', - }, - row = { - value = function (opponent) - return OpponentDisplay.InlineScore(Table.merge({extradata = {}, score = ''}, opponent)) - end, - }, - }, - } -} +---@type FfaMatchSummaryParser +local Parser = {} ----@param props {match: StarcraftMatchGroupUtilMatch, bracketResetMatch: StarcraftMatchGroupUtilMatch?, config: table?} ----@return Html +---@param props {bracketId: string, matchId: string} +---@return Widget function StarcraftMatchSummaryFfa.getByMatchId(props) - local match = StarcraftMatchSummaryFfa._opponents(props.match) - - return StarcraftMatchSummaryFfa._createOverallPage(match) + local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) + ---@cast match StarcraftMatchGroupUtilMatch + + BaseMatchSummary.updateMatchOpponents(match) + + return HtmlWidgets.Fragment{children = { + MatchSummaryWidgets.Header{matchId = match.matchId, games = match.games}, + MatchSummaryWidgets.Tab{ + matchId = match.matchId, + idx = 0, + children = { + MatchSummaryWidgets.GamesSchedule{match = match}, + BaseMatchSummary.standardMatch(match, Parser), + } + } + }} end -function StarcraftMatchSummaryFfa._opponents(match) - -- Add match opponent data to game opponent and the other way around - Array.forEach(match.games, function (game) - game.extradata.opponents = Array.map(game.opponents, function (opponent, opponentIdx) - return Table.merge(opponent, { - placement = opponent.placement, - status = opponent.status or 'S', - score = opponent.score or (game.scores or {})[opponentIdx], - }) - end) - end) - - Array.forEach(match.opponents, function (opponent, opponentIdx) - opponent.games = Array.map(match.games, function (game) - return game.extradata.opponents[opponentIdx] - end) - end) - - local placementSortFunction = function(opponent1, opponent2) - local place1 = opponent1.placement or math.huge - local place2 = opponent2.placement or math.huge - if place1 ~= place2 then - return place1 < place2 - end - if opponent1.status ~= 'S' and opponent2.status == 'S' then - return false - end - if opponent2.status ~= 'S' and opponent1.status == 'S' then - return true +---@param columns table[] +---@return table[] +function Parser.adjustMatchColumns(columns) + return Array.map(columns, function(column) + if column.id == 'totalPoints' then + column.show = function(match) return not match.extradata.settings.noscore end end - if opponent1.score and opponent2.score and opponent1.score ~= opponent2.score then - return opponent1.score > opponent2.score - end - return (opponent1.name or ''):lower() < (opponent2.name or ''):lower() - end - - -- Sort match level based on placement - Array.sortInPlaceBy(match.opponents, FnUtil.identity, placementSortFunction) - - if not match.finished then - return match - end - local cache = { - index = #match.opponents, - currentWorst = #match.opponents - } - Array.forEach(Array.reverse(match.opponents), function(opponent) - local place = opponent.placement - opponent.extradata.worstPlace = cache.currentWorst - if place == cache.index then - cache.currentWorst = place - 1 - end - cache.index = cache.index - 1 + return column end) - - return match -end - ----@param match table ----@return Html -function StarcraftMatchSummaryFfa._createOverallPage(match) - local page = mw.html.create('div') - :addClass('brkts-match-info-popup-sc-ffa') - :addClass('panel-content') - :attr('data-js-battle-royale', 'panel-content'):attr('id', 'panel0') - - local schedule = page:tag('div') - - local scheduleList = schedule:tag('div') - :addClass('panel-content__container') - :attr('role', 'tabpanel') - :tag('ul') - :addClass('panel-content__game-schedule') - - scheduleList:tag('li') - :node(StarcraftMatchSummaryFfa._countdownIcon(match, 'panel-content__game-schedule__icon')) - :tag('span') - :addClass('panel-content__game-schedule__title') - :wikitext('Match:') - :done() - :tag('div') - :addClass('panel-content__game-schedule__container') - :node(StarcraftMatchSummaryFfa._countdown(match)) - - return page:node(StarcraftMatchSummaryFfa._createMatchStandings(match)) end +---@param columns table[] +---@return table[] +function Parser.adjustGameOverviewColumns(columns) + return Array.map(columns, function(column) + if column.id == 'placement' then + column.show = function(match) return true end ----@param match table ----@return Html -function StarcraftMatchSummaryFfa._createMatchStandings(match) - local wrapper = mw.html.create('div') - :addClass('panel-table') - :attr('data-js-battle-royale', 'table') - - local header = wrapper:tag('div') - :addClass('panel-table__row') - :addClass('row--header') - :attr('data-js-battle-royale', 'header-row') - - Array.forEach(MATCH_STANDING_COLUMNS, function(column) - if column.show and not column.show.value(match) then + -- css for points shifts it to the next line and expects kills to be present + elseif column.id == 'points' then return - end - local cell = header:tag('div') - :addClass('panel-table__cell') - :addClass(column.class) - local groupedCell = cell:tag('div'):addClass('panel-table__cell-grouped') - :tag('i') - :addClass('panel-table__cell-icon') - :addClass(column.iconClass) - :done() - local span = groupedCell:tag('span') - :wikitext((column.header or {}).value) - if (column.header or {}).mobileValue then - span:addClass('d-none d-md-block') - groupedCell:tag('span') - :wikitext((column.header or {}).mobileValue) - :addClass('d-block d-md-none') + -- css for kills works just fine for our purposes + elseif column.id == 'kills' then + column.show = function(match) return not match.extradata.settings.noscore end + column.row = {value = function(opponent) + return OpponentDisplay.InlineScore(Table.merge({extradata = {}, score = ''}, opponent)) + end} + column.icon = 'points' + column.header = {value = 'Pts.'} end - span:done() - end) - - local gameCollectionContainerNavHolder = header:tag('div') - :addClass('panel-table__cell') - :addClass('cell--game-container-nav-holder') - :attr('data-js-battle-royale', 'game-nav-holder') - :css('overflow', 'visible') - local gameCollectionContainer = gameCollectionContainerNavHolder:tag('div') - :addClass('panel-table__cell') - :addClass('cell--game-container') - :attr('data-js-battle-royale', 'game-container') - :css('overflow-x', 'visible') - - Array.forEach(match.games, function (game, idx) - local gameContainer = gameCollectionContainer:tag('div') - :addClass('panel-table__cell') - :addClass('cell--game') - gameContainer:tag('div') - :addClass('panel-table__cell__game-head') - :css('text-align', 'left') - :tag('div') - :addClass('panel-table__cell__game-title') - :css('justify-content', 'flex-start') - :node(StarcraftMatchSummaryFfa._countdownIcon(game, 'panel-table__cell-icon')) - :tag('span') - :addClass('panel-table__cell-text') - :wikitext('Game ', idx) - :done() - :done() - :node(StarcraftMatchSummaryFfa._countdown(game)) - :node(StarcraftMatchSummaryFfa._map(game)) - :done() - - local gameDetails = gameContainer:tag('div'):addClass('panel-table__cell__game-details') - Array.forEach(MATCH_STANDING_COLUMNS.game, function(column) - if column.show and not column.show.value(match) then - return - end - gameDetails:tag('div') - :addClass(column.class) - :tag('i') - :addClass('panel-table__cell-icon') - :addClass(column.iconClass) - :done() - :tag('span') - :wikitext(column.header.value) - :done() - end) - end) - - Array.forEach(match.opponents, function (opponentMatch, index) - local row = wrapper:tag('div'):addClass('panel-table__row'):attr('data-js-battle-royale', 'row') - - Array.forEach(MATCH_STANDING_COLUMNS, function(column) - if column.show and not column.show.value(match) then - return - end - - row:tag('div') - :addClass('panel-table__cell') - :addClass(column.class) - :node(column.row.value(opponentMatch, index)) - end) - - local gameRowContainer = row:tag('div') - :addClass('panel-table__cell') - :addClass('cell--game-container') - :css('overflow-x', 'unset') - :attr('data-js-battle-royale', 'game-container') - - Array.forEach(opponentMatch.games, function(opponent) - local gameRow = gameRowContainer:tag('div'):addClass('panel-table__cell'):addClass('cell--game') - - Array.forEach(MATCH_STANDING_COLUMNS.game, function(column) - if column.show and not column.show.value(match) then - return - end - gameRow:tag('div') - :node(column.row.value(opponent)) - :addClass(column.class) - :addClass(column.row.class and column.row.class(opponent) or nil) - end) - end) + return column end) - - return mw.html.create('div') - :css('overflow-x', 'auto') - :node(wrapper) -end - ----@param game table ----@return Html -function StarcraftMatchSummaryFfa._map(game) - return mw.html.create() - :tag('i') - :addClass('far fa-map') - :addClass('panel-content__game-schedule__icon') - :done() - :node(DisplayHelper.Map(game, {noLink = (game.map or ''):upper() == TBD})) -end - ----@param game table ----@return boolean -function StarcraftMatchSummaryFfa._isFinished(game) - return game.winner ~= nil -end - ----@param game table ----@param additionalClass string ----@return string? -function StarcraftMatchSummaryFfa._countdownIcon(game, additionalClass) - local iconData = PHASE_ICONS[MatchGroupUtil.computeMatchPhase(game)] or {} - return Icon.makeIcon{iconName = iconData.iconName, color = iconData.color, additionalClasses = {additionalClass}} -end - ----Creates a countdown block for a given game ----Attaches any VODs of the game as well ----@param game table ----@return Html? -function StarcraftMatchSummaryFfa._countdown(game) - if not game.extradata.timezoneid then - return - end - - local timestamp = Date.readTimestamp(game.date) + (Timezone.getOffset(game.extradata.timezoneid) or 0) - local dateString = Date.formatTimestamp('F j, Y - H:i', timestamp) .. ' ' - .. (Timezone.getTimezoneString(game.extradata.timezoneid) or UTC) - - local stream = Table.merge(game.stream, { - date = dateString, - finished = StarcraftMatchSummaryFfa._isFinished(game) and 'true' or nil, - }) - - return mw.html.create('div'):addClass('match-countdown-block') - :node(require('Module:Countdown')._create(stream)) - :node(game.vod and VodLink.display{vod = game.vod} or nil) -end - ----@param placementStart string|number|nil ----@param placementEnd string|number|nil ----@return string -function StarcraftMatchSummaryFfa._displayRank(placementStart, placementEnd) - local places = {} - - if placementStart then - table.insert(places, Ordinal.toOrdinal(placementStart)) - end - - if placementStart and placementEnd and placementEnd > placementStart then - table.insert(places, Ordinal.toOrdinal(placementEnd)) - end - - return table.concat(places, ' - ') -end - ----@param place integer ----@return string? icon ----@return string? iconColor -function StarcraftMatchSummaryFfa._getTrophy(place) - if TROPHY_COLOR[place] then - return 'fas fa-trophy', TROPHY_COLOR[place] - end -end - ----@param opponent standardOpponent ----@return Html -function StarcraftMatchSummaryFfa._displayOpponent(opponent) - return OpponentDisplay.BlockOpponent{ - opponent = opponent, - showLink = true, - overflow = 'ellipsis', - teamStyle = 'hybrid', - } end return StarcraftMatchSummaryFfa diff --git a/components/match2/wikis/apexlegends/match_summary_ffa.lua b/components/match2/wikis/apexlegends/match_summary_ffa.lua index 1cd5c98a4ea..d2e2010e279 100644 --- a/components/match2/wikis/apexlegends/match_summary_ffa.lua +++ b/components/match2/wikis/apexlegends/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/arenafps/match_summary_ffa.lua b/components/match2/wikis/arenafps/match_summary_ffa.lua index 773b9d3d410..84655ab0dfd 100644 --- a/components/match2/wikis/arenafps/match_summary_ffa.lua +++ b/components/match2/wikis/arenafps/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/autochess/match_summary_ffa.lua b/components/match2/wikis/autochess/match_summary_ffa.lua index 1ee274b2d04..8c50fa55391 100644 --- a/components/match2/wikis/autochess/match_summary_ffa.lua +++ b/components/match2/wikis/autochess/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/callofduty/match_summary_ffa.lua b/components/match2/wikis/callofduty/match_summary_ffa.lua index 402023ac242..2bc6d3d8068 100644 --- a/components/match2/wikis/callofduty/match_summary_ffa.lua +++ b/components/match2/wikis/callofduty/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/fortnite/match_summary_ffa.lua b/components/match2/wikis/fortnite/match_summary_ffa.lua index c365ee0b444..a0340907fd1 100644 --- a/components/match2/wikis/fortnite/match_summary_ffa.lua +++ b/components/match2/wikis/fortnite/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/freefire/match_summary_ffa.lua b/components/match2/wikis/freefire/match_summary_ffa.lua index 8198aa21746..a3d2264db0f 100644 --- a/components/match2/wikis/freefire/match_summary_ffa.lua +++ b/components/match2/wikis/freefire/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/halo/match_summary_ffa.lua b/components/match2/wikis/halo/match_summary_ffa.lua index b3a0773bb6e..507f38188ed 100644 --- a/components/match2/wikis/halo/match_summary_ffa.lua +++ b/components/match2/wikis/halo/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/naraka/match_summary_ffa.lua b/components/match2/wikis/naraka/match_summary_ffa.lua index e29818df9ce..d5c18142d01 100644 --- a/components/match2/wikis/naraka/match_summary_ffa.lua +++ b/components/match2/wikis/naraka/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/pubg/match_summary_ffa.lua b/components/match2/wikis/pubg/match_summary_ffa.lua index 2fd9a40021a..dd77c7110e0 100644 --- a/components/match2/wikis/pubg/match_summary_ffa.lua +++ b/components/match2/wikis/pubg/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/pubgmobile/match_summary_ffa.lua b/components/match2/wikis/pubgmobile/match_summary_ffa.lua index ddc7a14820b..39772a4cccd 100644 --- a/components/match2/wikis/pubgmobile/match_summary_ffa.lua +++ b/components/match2/wikis/pubgmobile/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/starcraft/brkts_wiki_specific.lua b/components/match2/wikis/starcraft/brkts_wiki_specific.lua index 784a259fb5c..048d6d0adf9 100644 --- a/components/match2/wikis/starcraft/brkts_wiki_specific.lua +++ b/components/match2/wikis/starcraft/brkts_wiki_specific.lua @@ -29,7 +29,10 @@ end) ---@param maxOpponentCount integer ---@return function function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) - if matchGroupType == 'matchlist' then + if maxOpponentCount > 2 then + local Horizontallist = Lua.import('Module:MatchGroup/Display/Horizontallist') + return Horizontallist.BracketContainer + elseif matchGroupType == 'matchlist' then local MatchList = Lua.import('Module:MatchGroup/Display/Matchlist') return WikiSpecific.adjustMatchGroupContainerConfig(MatchList.MatchlistContainer) end @@ -53,7 +56,7 @@ end function WikiSpecific.getMatchContainer(displayMode) if displayMode == 'singleMatch' then -- Single match, displayed flat on a page (no popup) - local SingleMatch = Lua.import('Module:MatchGroup/Display/SingleMatch/Starcraft') + local SingleMatch = Lua.import('Module:MatchGroup/Display/SingleMatch') return WikiSpecific.adjustMatchGroupContainerConfig(SingleMatch.SingleMatchContainer) end end diff --git a/components/match2/wikis/starcraft/game_summary.lua b/components/match2/wikis/starcraft/game_summary.lua new file mode 100644 index 00000000000..4cc8ad3b883 --- /dev/null +++ b/components/match2/wikis/starcraft/game_summary.lua @@ -0,0 +1,13 @@ +--- +-- @Liquipedia +-- wiki=starcraft +-- page=Module:GameSummary +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local StarcraftFfaGameSummary = Lua.import('Module:GameSummary/Starcraft/FFa') + +return StarcraftFfaGameSummary diff --git a/components/match2/wikis/starcraft/match_summary_ffa.lua b/components/match2/wikis/starcraft/match_summary_ffa.lua new file mode 100644 index 00000000000..4393aabcca8 --- /dev/null +++ b/components/match2/wikis/starcraft/match_summary_ffa.lua @@ -0,0 +1,13 @@ +--- +-- @Liquipedia +-- wiki=starcraft +-- page=Module:MatchSummary/Ffa +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local StarcraftFfaMatchSummary = Lua.import('Module:MatchSummary/Starcraft/Ffa') + +return StarcraftFfaMatchSummary diff --git a/components/match2/wikis/starcraft2/brkts_wiki_specific.lua b/components/match2/wikis/starcraft2/brkts_wiki_specific.lua index a79315ad4af..e2dd5595695 100644 --- a/components/match2/wikis/starcraft2/brkts_wiki_specific.lua +++ b/components/match2/wikis/starcraft2/brkts_wiki_specific.lua @@ -29,7 +29,10 @@ end) ---@param maxOpponentCount integer ---@return function function WikiSpecific.getMatchGroupContainer(matchGroupType, maxOpponentCount) - if matchGroupType == 'matchlist' then + if maxOpponentCount > 2 then + local Horizontallist = Lua.import('Module:MatchGroup/Display/Horizontallist') + return Horizontallist.BracketContainer + elseif matchGroupType == 'matchlist' then local MatchList = Lua.import('Module:MatchGroup/Display/Matchlist') return WikiSpecific.adjustMatchGroupContainerConfig(MatchList.MatchlistContainer) end @@ -53,7 +56,7 @@ end function WikiSpecific.getMatchContainer(displayMode) if displayMode == 'singleMatch' then -- Single match, displayed flat on a page (no popup) - local SingleMatch = Lua.import('Module:MatchGroup/Display/SingleMatch/Starcraft') + local SingleMatch = Lua.import('Module:MatchGroup/Display/SingleMatch') return WikiSpecific.adjustMatchGroupContainerConfig(SingleMatch.SingleMatchContainer) end end diff --git a/components/match2/wikis/starcraft2/game_summary.lua b/components/match2/wikis/starcraft2/game_summary.lua new file mode 100644 index 00000000000..b583816db76 --- /dev/null +++ b/components/match2/wikis/starcraft2/game_summary.lua @@ -0,0 +1,13 @@ +--- +-- @Liquipedia +-- wiki=starcraft2 +-- page=Module:GameSummary +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local StarcraftFfaGameSummary = Lua.import('Module:GameSummary/Starcraft/FFa') + +return StarcraftFfaGameSummary diff --git a/components/match2/wikis/starcraft2/match_summary_ffa.lua b/components/match2/wikis/starcraft2/match_summary_ffa.lua new file mode 100644 index 00000000000..a3f6defb55e --- /dev/null +++ b/components/match2/wikis/starcraft2/match_summary_ffa.lua @@ -0,0 +1,13 @@ +--- +-- @Liquipedia +-- wiki=starcraft2 +-- page=Module:MatchSummary/Ffa +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Lua = require('Module:Lua') + +local StarcraftFfaMatchSummary = Lua.import('Module:MatchSummary/Starcraft/Ffa') + +return StarcraftFfaMatchSummary diff --git a/components/match2/wikis/stormgate/match_group_util_custom.lua b/components/match2/wikis/stormgate/match_group_util_custom.lua index 0a9681a5f6e..9baa28a4c50 100644 --- a/components/match2/wikis/stormgate/match_group_util_custom.lua +++ b/components/match2/wikis/stormgate/match_group_util_custom.lua @@ -68,8 +68,6 @@ CustomMatchGroupUtil.types.GameOpponent = TypeUtil.struct({ ---@class StormgateMatchGroupUtilMatch: MatchGroupUtilMatch ---@field games StormgateMatchGroupUtilGame[] ----@field isFfa boolean ----@field noScore boolean? ---@field opponents StormgateStandardOpponent[] ---@field vetoes StormgateMatchGroupUtilVeto[] ---@field submatches StormgateMatchGroupUtilSubmatch[]? @@ -117,7 +115,6 @@ function CustomMatchGroupUtil.matchFromRecord(record) end -- Misc - match.isFfa = Logic.readBool(Table.extract(extradata, 'ffa')) match.casters = Table.extract(extradata, 'casters') return match diff --git a/components/match2/wikis/tft/match_summary_ffa.lua b/components/match2/wikis/tft/match_summary_ffa.lua index 580f915ec23..41786578604 100644 --- a/components/match2/wikis/tft/match_summary_ffa.lua +++ b/components/match2/wikis/tft/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/underlords/match_summary_ffa.lua b/components/match2/wikis/underlords/match_summary_ffa.lua index 675474773c9..ac407e8a02c 100644 --- a/components/match2/wikis/underlords/match_summary_ffa.lua +++ b/components/match2/wikis/underlords/match_summary_ffa.lua @@ -33,7 +33,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - MatchSummaryWidgets.GamesSchedule{games = match.games}, + MatchSummaryWidgets.GamesSchedule{match = match}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardMatch(match), } diff --git a/components/match2/wikis/warcraft/match_group_util_custom.lua b/components/match2/wikis/warcraft/match_group_util_custom.lua index e241445b8db..a14594e0e4c 100644 --- a/components/match2/wikis/warcraft/match_group_util_custom.lua +++ b/components/match2/wikis/warcraft/match_group_util_custom.lua @@ -56,8 +56,6 @@ local CustomMatchGroupUtil = Table.deepCopy(MatchGroupUtil) ---@class WarcraftMatchGroupUtilMatch: MatchGroupUtilMatch ---@field games WarcraftMatchGroupUtilGame[] ----@field isFfa boolean ----@field noScore boolean? ---@field opponentMode 'uniform'|'team' ---@field opponents WarcraftStandardOpponent[] ---@field vetoes WarcraftMatchGroupUtilVeto[] @@ -107,7 +105,6 @@ function CustomMatchGroupUtil.matchFromRecord(record) end -- Misc - match.isFfa = Logic.readBool(Table.extract(extradata, 'ffa')) match.casters = Table.extract(extradata, 'casters') return match diff --git a/components/widget/match/summary/ffa/widget_match_summary_ffa_games_schedule.lua b/components/widget/match/summary/ffa/widget_match_summary_ffa_games_schedule.lua index 977626e7825..09d7795ee53 100644 --- a/components/widget/match/summary/ffa/widget_match_summary_ffa_games_schedule.lua +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_games_schedule.lua @@ -8,7 +8,9 @@ local Array = require('Module:Array') local Class = require('Module:Class') +local DateExt = require('Module:Date/Ext') local Lua = require('Module:Lua') +local Operator = require('Module:Operator') local Widget = Lua.import('Module:Widget') local ContentItemContainer = Lua.import('Module:Widget/Match/Summary/Ffa/ContentItemContainer') @@ -21,20 +23,34 @@ local MatchSummaryFfaGamesSchedule = Class.new(Widget) ---@return Widget? function MatchSummaryFfaGamesSchedule:render() - if not self.props.games or #self.props.games == 0 then + local scheduleItems = self.props.match.games or {} + local showMatch = self:gamesHaveDifferentDates() + if showMatch and DateExt.isDefaultTimestamp(self.props.match.date) then + return nil + elseif showMatch then + scheduleItems = {self.props.match} + end + + if #scheduleItems == 0 then return nil end return ContentItemContainer{collapsed = true, collapsible = true, title = 'Schedule', contentClass = 'panel-content__game-schedule', - items = Array.map(self.props.games, function (game, idx) + items = Array.map(scheduleItems, function (game, idx) return { icon = CountdownIcon{game = game}, - title = 'Game ' .. idx .. ':', + title = showMatch and 'Match:' or ('Game ' .. idx .. ':'), content = GameCountdown{game = game}, } end) } end +---@return boolean +function MatchSummaryFfaGamesSchedule:gamesHaveDifferentDates() + local dates = Array.map(self.props.match.games or {}, Operator.property('date')) + return Array.all(dates, function(date) return date == self.props.match.date end) +end + return MatchSummaryFfaGamesSchedule diff --git a/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt b/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt index e8ff79291bc..a82b95fa445 100644 --- a/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt +++ b/spec/golden_masters/match2_matchlist_smoke_apexlegends.txt @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file