From 19caa4eddde3c992e4296bffdb780e6ab94b0a78 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Tue, 10 Dec 2024 13:50:14 +0100 Subject: [PATCH] feat(match2): standardize BR game details --- .../match2/wikis/apexlegends/game_summary.lua | 22 +--------- .../match2/wikis/fortnite/game_summary.lua | 22 +--------- .../match2/wikis/freefire/game_summary.lua | 22 +--------- .../match2/wikis/naraka/game_summary.lua | 22 +--------- components/match2/wikis/pubg/game_summary.lua | 22 +--------- .../match2/wikis/pubgmobile/game_summary.lua | 22 +--------- .../match2/wikis/underlords/game_summary.lua | 22 +--------- .../ffa/widget_match_summary_ffa_all.lua | 1 + ...get_match_summary_ffa_game_details.lua.lua | 41 +++++++++++++++++++ 9 files changed, 49 insertions(+), 147 deletions(-) create mode 100644 components/widget/match/summary/ffa/widget_match_summary_ffa_game_details.lua.lua diff --git a/components/match2/wikis/apexlegends/game_summary.lua b/components/match2/wikis/apexlegends/game_summary.lua index cacc964114..441cacf423 100644 --- a/components/match2/wikis/apexlegends/game_summary.lua +++ b/components/match2/wikis/apexlegends/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class ApexMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/fortnite/game_summary.lua b/components/match2/wikis/fortnite/game_summary.lua index 15596b5a0e..f23c57c094 100644 --- a/components/match2/wikis/fortnite/game_summary.lua +++ b/components/match2/wikis/fortnite/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class FortniteMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/freefire/game_summary.lua b/components/match2/wikis/freefire/game_summary.lua index a532577f33..6f5278e646 100644 --- a/components/match2/wikis/freefire/game_summary.lua +++ b/components/match2/wikis/freefire/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class FreefireMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/naraka/game_summary.lua b/components/match2/wikis/naraka/game_summary.lua index 5d68def207..fed798b637 100644 --- a/components/match2/wikis/naraka/game_summary.lua +++ b/components/match2/wikis/naraka/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class NarakaMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/pubg/game_summary.lua b/components/match2/wikis/pubg/game_summary.lua index cc0e6e617f..7a1d41908f 100644 --- a/components/match2/wikis/pubg/game_summary.lua +++ b/components/match2/wikis/pubg/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class PubgMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/pubgmobile/game_summary.lua b/components/match2/wikis/pubgmobile/game_summary.lua index 76233faebe..9e85ef2e65 100644 --- a/components/match2/wikis/pubgmobile/game_summary.lua +++ b/components/match2/wikis/pubgmobile/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class PubgmMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary diff --git a/components/match2/wikis/underlords/game_summary.lua b/components/match2/wikis/underlords/game_summary.lua index a204cbd2e9..788d5f452e 100644 --- a/components/match2/wikis/underlords/game_summary.lua +++ b/components/match2/wikis/underlords/game_summary.lua @@ -9,14 +9,11 @@ local CustomGameSummary = {} local Lua = require('Module:Lua') -local Page = require('Module:Page') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') -local HtmlWidgets = Lua.import('Module:Widget/Html/All') -local IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') ---@class UnderlordsMatchGroupUtilGame: MatchGroupUtilGame ---@field stream table @@ -39,28 +36,11 @@ function CustomGameSummary.getGameByMatchId(props) matchId = match.matchId, idx = props.gameIdx, children = { - CustomGameSummary._createGameDetails(game), + MatchSummaryWidgets.GameDetails{game = game}, MatchSummaryWidgets.PointsDistribution{scores = scoringData}, SummaryHelper.standardGame(game) } } end ----@param game table ----@return Widget -function CustomGameSummary._createGameDetails(game) - return MatchSummaryWidgets.ContentItemContainer{contentClass = 'panel-content__game-schedule', - items = { - { - icon = MatchSummaryWidgets.CountdownIcon{game = game}, - content = MatchSummaryWidgets.GameCountdown{game = game}, - }, - game.map and { - icon = IconWidget{iconName = 'map'}, - content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, - } or nil, - } - } -end - return CustomGameSummary 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 f5ebac74b5..1490c26d34 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 @@ -13,6 +13,7 @@ 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.GameDetails = Lua.import('Module:Widget/Match/Summary/Ffa/GameDetails') 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') diff --git a/components/widget/match/summary/ffa/widget_match_summary_ffa_game_details.lua.lua b/components/widget/match/summary/ffa/widget_match_summary_ffa_game_details.lua.lua new file mode 100644 index 0000000000..c5137a0391 --- /dev/null +++ b/components/widget/match/summary/ffa/widget_match_summary_ffa_game_details.lua.lua @@ -0,0 +1,41 @@ +--- +-- @Liquipedia +-- wiki=commons +-- page=Module:Widget/Match/Summary/Ffa/GameDetails +-- +-- Please see https://github.com/Liquipedia/Lua-Modules to contribute +-- + +local Class = require('Module:Class') +local Lua = require('Module:Lua') +local Page = require('Module:Page') + +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 IconWidget = Lua.import('Module:Widget/Image/Icon/Fontawesome') +local CountdownIcon = Lua.import('Module:Widget/Match/Summary/Ffa/CountdownIcon') +local GameCountdown = Lua.import('Module:Widget/Match/Summary/Ffa/GameCountdown') + +---@class MatchSummaryFfaGameDetails: Widget +---@operator call(table): MatchSummaryFfaGameDetails +local MatchSummaryFfaGameDetails = Class.new(Widget) + +---@return Widget +function MatchSummaryFfaGameDetails:render() + local game = self.props.game + assert(game, 'No game provided') + + return ContentItemContainer{contentClass = 'panel-content__game-schedule', items = { + { + icon = CountdownIcon{game = game}, + content = GameCountdown{game = game}, + }, + game.map and { + icon = IconWidget{iconName = 'map'}, + content = HtmlWidgets.Span{children = Page.makeInternalLink(game.map)}, + } or nil, + }} +end + +return MatchSummaryFfaGameDetails