Skip to content

Commit

Permalink
feat(match2): add support for pubg mobile (#5143)
Browse files Browse the repository at this point in the history
* copy of apex with fixed headers and classes

* 5141

* remove match point stuff

* update with correct default point setup

* nuke remaining parts of summary util

* helps to commit all files

* Update components/match2/wikis/pubgmobile/match_legacy.lua

Co-authored-by: hjpalpha <[email protected]>

* copy paste tweaks

* show column filter

---------

Co-authored-by: hjpalpha <[email protected]>
  • Loading branch information
Rathoz and hjpalpha authored Nov 28, 2024
1 parent e0cbaf3 commit 52f970c
Show file tree
Hide file tree
Showing 9 changed files with 927 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
-- @Liquipedia
-- wiki=apexlegends
-- page=Module:Summary/Util
-- wiki=commons
-- page=Module:MatchSummary/Ffa
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--
Expand All @@ -13,13 +13,13 @@ local Table = require('Module:Table')
local Timezone = require('Module:Timezone')
local VodLink = require('Module:VodLink')

local CustomSummaryHelper = {}
local MatchSummaryFfa = {}

---Creates a countdown block for a given game
---Attaches any VODs of the game as well
---@param game table
---@return Html?
function CustomSummaryHelper.gameCountdown(game)
function MatchSummaryFfa.gameCountdown(game)
local timestamp = Date.readTimestamp(game.date)
if not timestamp then
return
Expand All @@ -40,7 +40,7 @@ end
---@param opponent1 table
---@param opponent2 table
---@return boolean
function CustomSummaryHelper.placementSortFunction(opponent1, opponent2)
function MatchSummaryFfa.placementSortFunction(opponent1, opponent2)
if opponent1.placement and opponent2.placement and opponent1.placement ~= opponent2.placement then
return opponent1.placement < opponent2.placement
end
Expand All @@ -58,7 +58,7 @@ end

---@param match table
---@return {kill: number, placement: {rangeStart: integer, rangeEnd: integer, score:number}[]}
function CustomSummaryHelper.createScoringData(match)
function MatchSummaryFfa.createScoringData(match)
local scoreSettings = match.extradata.scoring

local scorePlacement = {}
Expand All @@ -84,4 +84,4 @@ function CustomSummaryHelper.createScoringData(match)
}
end

return CustomSummaryHelper
return MatchSummaryFfa
2 changes: 1 addition & 1 deletion components/match2/wikis/apexlegends/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')
local OpponentLibraries = require('Module:OpponentLibraries')
local OpponentDisplay = OpponentLibraries.OpponentDisplay

local SummaryHelper = Lua.import('Module:Summary/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')
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/apexlegends/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ local Lua = require('Module:Lua')
local Table = require('Module:Table')

local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')
local SummaryHelper = Lua.import('Module:Summary/Util')
local SummaryHelper = Lua.import('Module:MatchSummary/Ffa')
local OpponentLibraries = require('Module:OpponentLibraries')
local OpponentDisplay = OpponentLibraries.OpponentDisplay

Expand Down
24 changes: 24 additions & 0 deletions components/match2/wikis/pubgmobile/brkts_wiki_specific.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
-- @Liquipedia
-- wiki=pubgmobile
-- page=Module:Brkts/WikiSpecific
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local Lua = require('Module:Lua')
local Table = require('Module:Table')

local BaseWikiSpecific = Lua.import('Module:Brkts/WikiSpecific/Base')

---@class PubgmobileBrktsWikiSpecific: BrktsWikiSpecific
local WikiSpecific = Table.copy(BaseWikiSpecific)

---@param matchGroupType string
---@return function
function WikiSpecific.getMatchGroupContainer(matchGroupType)
local Horizontallist = Lua.import('Module:MatchGroup/Display/Horizontallist')
return Horizontallist.BracketContainer
end

return WikiSpecific
254 changes: 254 additions & 0 deletions components/match2/wikis/pubgmobile/game_summary.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
---
-- @Liquipedia
-- wiki=pubgmobile
-- page=Module:GameSummary
--
-- Please see https://github.com/Liquipedia/Lua-Modules to contribute
--

local CustomGameSummary = {}

local Array = require('Module:Array')
local FnUtil = require('Module:FnUtil')
local Lua = require('Module:Lua')
local Page = require('Module:Page')
local Table = require('Module:Table')

local MatchGroupUtil = Lua.import('Module:MatchGroup/Util')
local OpponentLibraries = require('Module:OpponentLibraries')
local OpponentDisplay = OpponentLibraries.OpponentDisplay

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

local GAME_STANDINGS_COLUMNS = {
{
sortable = true,
sortType = 'rank',
class = 'cell--rank',
icon = 'rank',
header = {
value = 'Rank',
},
sortVal = {
value = function (opponent, idx)
if opponent.placement == -1 or opponent.status ~= 'S' then
return idx
end
return opponent.placement
end,
},
row = {
value = function (opponent, idx)
local place = opponent.placement ~= -1 and opponent.placement or idx
local placementDisplay
if opponent.status and opponent.status ~= 'S' then
placementDisplay = '-'
else
placementDisplay = tostring(MatchSummaryWidgets.RankRange{rankStart = place})
end
return HtmlWidgets.Fragment{children = {
MatchSummaryWidgets.Trophy{place = place, additionalClasses = {'panel-table__cell-icon'}},
HtmlWidgets.Span{children = placementDisplay},
}}
end,
},
},
{
sortable = true,
sortType = 'team',
class = 'cell--team',
icon = 'team',
header = {
value = 'Team',
},
sortVal = {
value = function (opponent, idx)
return opponent.name
end,
},
row = {
value = function (opponent, idx)
return OpponentDisplay.BlockOpponent{
opponent = opponent,
showLink = true,
overflow = 'ellipsis',
teamStyle = 'hybrid',
}
end,
},
},
{
sortable = true,
sortType = 'total-points',
class = 'cell--total-points',
icon = 'points',
header = {
value = 'Total Points',
mobileValue = 'Pts.',
},
sortVal = {
value = function (opponent, idx)
return opponent.score
end,
},
row = {
value = function (opponent, idx)
return opponent.score
end,
},
},
{
sortable = true,
sortType = 'placements',
class = 'cell--placements',
icon = 'placement',
header = {
value = 'Placement Points',
},
sortVal = {
value = function (opponent, idx)
return opponent.scoreBreakdown.placePoints
end,
},
row = {
value = function (opponent, idx)
return opponent.scoreBreakdown.placePoints
end,
},
},
{
sortable = true,
sortType = 'kills',
class = 'cell--kills',
icon = 'kills',
header = {
value = 'Kill Points',
},
sortVal = {
value = function (opponent, idx)
return opponent.scoreBreakdown.killPoints
end,
},
row = {
value = function (opponent, idx)
return opponent.scoreBreakdown.killPoints
end,
},
},
}
---@param props {bracketId: string, matchId: string, gameIdx: integer}
---@return Html
function CustomGameSummary.getGameByMatchId(props)
---@class ApexMatchGroupUtilMatch
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

CustomGameSummary._opponents(match)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
matchId = match.matchId,
idx = props.gameIdx,
children = {
CustomGameSummary._createGameDetails(game),
MatchSummaryWidgets.PointsDistribution{killScore = scoringData.kill, placementScore = scoringData.placement},
CustomGameSummary._createGameStandings(game)
}
}
end

---@param game table
---@return Widget
function CustomGameSummary._createGameDetails(game)
return MatchSummaryWidgets.ContentItemContainer{children = {
HtmlWidgets.Ul{
classes = {'panel-content__game-schedule'},
children = {
HtmlWidgets.Li{children =
HtmlWidgets.Div{
classes = {'panel-content__game-schedule__container'},
children = {
MatchSummaryWidgets.CountdownIcon{game = game, additionalClasses = {'panel-content__game-schedule__icon'}},
SummaryHelper.gameCountdown(game),
},
},
},
game.map and HtmlWidgets.Li{children = {
IconWidget{iconName = 'map', additionalClasses = {'panel-content__game-schedule__icon'}},
HtmlWidgets.Span{children = Page.makeInternalLink(game.map)},
}}} or nil,
}
}
}
end

---@param game table
---@return Html
function CustomGameSummary._createGameStandings(game)
local rows = Array.map(game.opponents, function (opponent, index)
local children = Array.map(GAME_STANDINGS_COLUMNS, function(column)
if column.show and not column.show(game) then
return
end
return MatchSummaryWidgets.TableRowCell{
class = column.class,
sortable = column.sortable,
sortType = column.sortType,
sortValue = column.sortVal and column.sortVal.value(opponent, index) or nil,
value = column.row.value(opponent, index),
}
end)
return MatchSummaryWidgets.TableRow{children = children}
end)

return MatchSummaryWidgets.Table{children = {
MatchSummaryWidgets.TableHeader{children = Array.map(GAME_STANDINGS_COLUMNS, function(column)
if column.show and not column.show(game) then
return
end
return MatchSummaryWidgets.TableHeaderCell{
class = column.class,
icon = column.icon,
mobileValue = column.header.mobileValue,
sortable = column.sortable,
sortType = column.sortType,
value = column.header.value,
}
end)},
unpack(rows)
}}
end

function CustomGameSummary._opponents(match)
-- Add match opponent data to game opponent
Array.forEach(match.games, function (game)
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = match.opponents[opponentIdx]
local newGameOpponent = Table.merge(matchOpponent, gameOpponent)
-- These values are only allowed to come from Game and not Match
newGameOpponent.placement = gameOpponent.placement
newGameOpponent.score = gameOpponent.score
newGameOpponent.status = gameOpponent.status
return newGameOpponent
end
)
end)

-- Sort game level based on placement
Array.forEach(match.games, function (game)
Array.sortInPlaceBy(game.opponents, FnUtil.identity, SummaryHelper.placementSortFunction)
end)
end

return CustomGameSummary
Loading

0 comments on commit 52f970c

Please sign in to comment.