diff --git a/components/match2/commons/match_summary_ffa.lua b/components/match2/commons/match_summary_ffa.lua index 9c901ce376..311d16a23b 100644 --- a/components/match2/commons/match_summary_ffa.lua +++ b/components/match2/commons/match_summary_ffa.lua @@ -7,12 +7,9 @@ -- local Array = require('Module:Array') -local Date = require('Module:Date/Ext') local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local Table = require('Module:Table') -local Timezone = require('Module:Timezone') -local VodLink = require('Module:VodLink') local OpponentLibraries = require('Module:OpponentLibraries') local OpponentDisplay = OpponentLibraries.OpponentDisplay @@ -290,29 +287,6 @@ local GAME_STANDINGS_COLUMNS = { }, } - ----Creates a countdown block for a given game ----Attaches any VODs of the game as well ----@param game table ----@return Html? -function MatchSummaryFfa.gameCountdown(game) - local timestamp = Date.readTimestamp(game.date) - if not timestamp then - return - end - -- TODO Use local TZ - local dateString = Date.formatTimestamp('F j, Y - H:i', timestamp) .. ' ' .. Timezone.getTimezoneString('UTC') - - local stream = Table.merge(game.stream, { - date = dateString, - finished = game.winner ~= nil 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 opponent1 table ---@param opponent2 table ---@return boolean @@ -445,7 +419,7 @@ function MatchSummaryFfa.standardMatch(match) } } }, - MatchSummaryFfa.gameCountdown(game), + MatchSummaryWidgets.GameCountdown{game = game}, } }, HtmlWidgets.Div{ diff --git a/components/match2/wikis/apexlegends/game_summary.lua b/components/match2/wikis/apexlegends/game_summary.lua index 33e1a324ec..1088465a43 100644 --- a/components/match2/wikis/apexlegends/game_summary.lua +++ b/components/match2/wikis/apexlegends/game_summary.lua @@ -61,7 +61,7 @@ function CustomGameSummary._createGameDetails(game) classes = {'panel-content__game-schedule__container'}, children = { MatchSummaryWidgets.CountdownIcon{game = game, additionalClasses = {'panel-content__game-schedule__icon'}}, - SummaryHelper.gameCountdown(game), + MatchSummaryWidgets.GameCountdown{game = game}, }, }, }, diff --git a/components/match2/wikis/apexlegends/match_summary.lua b/components/match2/wikis/apexlegends/match_summary.lua index 4c7e947a75..f3c74fe920 100644 --- a/components/match2/wikis/apexlegends/match_summary.lua +++ b/components/match2/wikis/apexlegends/match_summary.lua @@ -217,7 +217,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - CustomMatchSummary._createSchedule(match), + MatchSummaryWidgets.GamesSchedule{games = match.games}, MatchSummaryWidgets.PointsDistribution{killScore = scoringData.kill, placementScore = scoringData.placement}, CustomMatchSummary._createMatchStandings(match) } @@ -257,36 +257,6 @@ function CustomMatchSummary._opponents(match) end) end ----@param match table ----@return Widget -function CustomMatchSummary._createSchedule(match) - return MatchSummaryWidgets.ContentItemContainer{collapsed = true, collapsible = true, title = 'Schedule', children = { - HtmlWidgets.Ul{ - classes = {'panel-content__game-schedule'}, - children = Array.map(match.games, function (game, idx) - return HtmlWidgets.Li{ - children = { - HtmlWidgets.Span{ - children = MatchSummaryWidgets.CountdownIcon{ - game = game, - additionalClasses = {'panel-content__game-schedule__icon'} - }, - }, - HtmlWidgets.Span{ - classes = {'panel-content__game-schedule__title'}, - children = 'Game ' .. idx .. ':', - }, - HtmlWidgets.Div{ - classes = {'panel-content__game-schedule__container'}, - children = SummaryHelper.gameCountdown(game), - }, - }, - } - end) - } - }} -end - ---@param match table ---@return Html function CustomMatchSummary._createMatchStandings(match) @@ -372,7 +342,7 @@ function CustomMatchSummary._createMatchStandings(match) } } }, - SummaryHelper.gameCountdown(game), + MatchSummaryWidgets.GameCountdown{game = game}, } }, HtmlWidgets.Div{ diff --git a/components/match2/wikis/pubg/game_summary.lua b/components/match2/wikis/pubg/game_summary.lua index 35713e81bc..d4edbebf11 100644 --- a/components/match2/wikis/pubg/game_summary.lua +++ b/components/match2/wikis/pubg/game_summary.lua @@ -61,7 +61,7 @@ function CustomGameSummary._createGameDetails(game) classes = {'panel-content__game-schedule__container'}, children = { MatchSummaryWidgets.CountdownIcon{game = game, additionalClasses = {'panel-content__game-schedule__icon'}}, - SummaryHelper.gameCountdown(game), + MatchSummaryWidgets.GameCountdown{game = game}, }, }, }, diff --git a/components/match2/wikis/pubg/match_summary.lua b/components/match2/wikis/pubg/match_summary.lua index 77063739ca..858a143a97 100644 --- a/components/match2/wikis/pubg/match_summary.lua +++ b/components/match2/wikis/pubg/match_summary.lua @@ -35,7 +35,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - CustomMatchSummary._createSchedule(match), + MatchSummaryWidgets.GamesSchedule{games = match.games}, MatchSummaryWidgets.PointsDistribution{killScore = scoringData.kill, placementScore = scoringData.placement}, SummaryHelper.standardMatch(match), } @@ -61,34 +61,4 @@ function CustomMatchSummary._opponents(match) end) end ----@param match table ----@return Widget -function CustomMatchSummary._createSchedule(match) - return MatchSummaryWidgets.ContentItemContainer{collapsed = true, collapsible = true, title = 'Schedule', children = { - HtmlWidgets.Ul{ - classes = {'panel-content__game-schedule'}, - children = Array.map(match.games, function (game, idx) - return HtmlWidgets.Li{ - children = { - HtmlWidgets.Span{ - children = MatchSummaryWidgets.CountdownIcon{ - game = game, - additionalClasses = {'panel-content__game-schedule__icon'} - }, - }, - HtmlWidgets.Span{ - classes = {'panel-content__game-schedule__title'}, - children = 'Game ' .. idx .. ':', - }, - HtmlWidgets.Div{ - classes = {'panel-content__game-schedule__container'}, - children = SummaryHelper.gameCountdown(game), - }, - }, - } - end) - } - }} -end - return CustomMatchSummary diff --git a/components/match2/wikis/pubgmobile/game_summary.lua b/components/match2/wikis/pubgmobile/game_summary.lua index 3d3840b8ca..a61a972a91 100644 --- a/components/match2/wikis/pubgmobile/game_summary.lua +++ b/components/match2/wikis/pubgmobile/game_summary.lua @@ -61,7 +61,7 @@ function CustomGameSummary._createGameDetails(game) classes = {'panel-content__game-schedule__container'}, children = { MatchSummaryWidgets.CountdownIcon{game = game, additionalClasses = {'panel-content__game-schedule__icon'}}, - SummaryHelper.gameCountdown(game), + MatchSummaryWidgets.GameCountdown{game = game}, }, }, }, diff --git a/components/match2/wikis/pubgmobile/match_summary.lua b/components/match2/wikis/pubgmobile/match_summary.lua index c613b0a2d2..27d8e018b9 100644 --- a/components/match2/wikis/pubgmobile/match_summary.lua +++ b/components/match2/wikis/pubgmobile/match_summary.lua @@ -35,7 +35,7 @@ function CustomMatchSummary.getByMatchId(props) matchId = match.matchId, idx = 0, children = { - CustomMatchSummary._createSchedule(match), + MatchSummaryWidgets.GamesSchedule{games = match.games}, MatchSummaryWidgets.PointsDistribution{killScore = scoringData.kill, placementScore = scoringData.placement}, SummaryHelper.standardMatch(match), } @@ -61,34 +61,4 @@ function CustomMatchSummary._opponents(match) end) end ----@param match table ----@return Widget -function CustomMatchSummary._createSchedule(match) - return MatchSummaryWidgets.ContentItemContainer{collapsed = true, collapsible = true, title = 'Schedule', children = { - HtmlWidgets.Ul{ - classes = {'panel-content__game-schedule'}, - children = Array.map(match.games, function (game, idx) - return HtmlWidgets.Li{ - children = { - HtmlWidgets.Span{ - children = MatchSummaryWidgets.CountdownIcon{ - game = game, - additionalClasses = {'panel-content__game-schedule__icon'} - }, - }, - HtmlWidgets.Span{ - classes = {'panel-content__game-schedule__title'}, - children = 'Game ' .. idx .. ':', - }, - HtmlWidgets.Div{ - classes = {'panel-content__game-schedule__container'}, - children = SummaryHelper.gameCountdown(game), - }, - }, - } - end) - } - }} -end - return CustomMatchSummary diff --git a/components/widget/match/summary/ffa/widget_match_summary_ffa_all.lua b/components/widget/match/summary/ffa/widget_match_summary_ffa_all.lua index b22800d7fc..f5ebac74b5 100644 --- a/components/widget/match/summary/ffa/widget_match_summary_ffa_all.lua +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_all.lua @@ -12,6 +12,8 @@ local Lua = require('Module:Lua') Widgets.ContentItemContainer = Lua.import('Module:Widget/Match/Summary/Ffa/ContentItemContainer') Widgets.CountdownIcon = Lua.import('Module:Widget/Match/Summary/Ffa/CountdownIcon') +Widgets.GameCountdown = Lua.import('Module:Widget/Match/Summary/Ffa/GameCountdown') +Widgets.GamesSchedule = Lua.import('Module:Widget/Match/Summary/Ffa/GamesSchedule') Widgets.Header = Lua.import('Module:Widget/Match/Summary/Ffa/Header') Widgets.PointsDistribution = Lua.import('Module:Widget/Match/Summary/Ffa/PointsDistribution') Widgets.RankRange = Lua.import('Module:Widget/Match/Summary/Ffa/RankRange') diff --git a/components/widget/match/summary/ffa/widget_match_summary_ffa_game_countdown.lua b/components/widget/match/summary/ffa/widget_match_summary_ffa_game_countdown.lua new file mode 100644 index 0000000000..d1f0ac3605 --- /dev/null +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_game_countdown.lua @@ -0,0 +1,51 @@ +--- +-- @Liquipedia +-- wiki=commons +-- page=Module:Widget/Match/Summary/Ffa/GameCountdown +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Class = require('Module:Class') +local Date = require('Module:Date/Ext') +local Lua = require('Module:Lua') +local Table = require('Module:Table') +local Timezone = require('Module:Timezone') +local VodLink = require('Module:VodLink') + +local Widget = Lua.import('Module:Widget') +local HtmlWidgets = Lua.import('Module:Widget/Html/All') + +---@class MatchSummaryFfaGameCountdown: Widget +---@operator call(table): MatchSummaryFfaGameCountdown +local MatchSummaryFfaGameCountdown = Class.new(Widget) + +---@return Widget? +function MatchSummaryFfaGameCountdown:render() + local game = self.props.game + if not game then + return nil + end + + local timestamp = Date.readTimestamp(game.date) + if not timestamp then + return + end + -- TODO Use local TZ + local dateString = Date.formatTimestamp('F j, Y - H:i', timestamp) .. ' ' .. Timezone.getTimezoneString('UTC') + + local streamParameters = Table.merge(game.stream, { + date = dateString, + finished = game.winner ~= nil and 'true' or nil, + }) + + return HtmlWidgets.Div{ + classes = {'match-countdown-block'}, + children = { + require('Module:Countdown')._create(streamParameters), + game.vod and VodLink.display{vod = game.vod} or nil, + }, + } +end + +return MatchSummaryFfaGameCountdown 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 new file mode 100644 index 0000000000..a16002f282 --- /dev/null +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_games_schedule.lua @@ -0,0 +1,56 @@ +--- +-- @Liquipedia +-- wiki=commons +-- page=Module:Widget/Match/Summary/Ffa/GamesSchedule +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Array = require('Module:Array') +local Class = require('Module:Class') +local Lua = require('Module:Lua') + +local Widget = Lua.import('Module:Widget') +local HtmlWidgets = Lua.import('Module:Widget/Html/All') +local ContentItemContainer = Lua.import('Module:Widget/Match/Summary/Ffa/ContentItemContainer') +local CountdownIcon = Lua.import('Module:Widget/Match/Summary/Ffa/CountdownIcon') +local GameCountdown = Lua.import('Module:Widget/Match/Summary/Ffa/GameCountdown') + +---@class MatchSummaryFfaGamesSchedule: Widget +---@operator call(table): MatchSummaryFfaGamesSchedule +local MatchSummaryFfaGamesSchedule = Class.new(Widget) + +---@return Widget? +function MatchSummaryFfaGamesSchedule:render() + if not self.props.games or #self.props.games == 0 then + return nil + end + + return ContentItemContainer{collapsed = true, collapsible = true, title = 'Schedule', children = { + HtmlWidgets.Ul{ + classes = {'panel-content__game-schedule'}, + children = Array.map(self.props.games, function (game, idx) + return HtmlWidgets.Li{ + children = { + HtmlWidgets.Span{ + children = CountdownIcon{ + game = game, + additionalClasses = {'panel-content__game-schedule__icon'} + }, + }, + HtmlWidgets.Span{ + classes = {'panel-content__game-schedule__title'}, + children = 'Game ' .. idx .. ':', + }, + HtmlWidgets.Div{ + classes = {'panel-content__game-schedule__container'}, + children = GameCountdown{game = game}, + }, + }, + } + 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 dac94f9a81..37c7b4e306 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