Skip to content

Commit

Permalink
feat(match2): standardize br-map opponent enrichment (#5189)
Browse files Browse the repository at this point in the history
* feat(match2): standardize map opponent enrichment

* lint

* incorrectly merged

* review comment
  • Loading branch information
Rathoz authored Dec 10, 2024
1 parent ee78a94 commit ab4695d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 169 deletions.
22 changes: 21 additions & 1 deletion components/match2/commons/match_summary_ffa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function MatchSummaryFfa.placementSortFunction(opponent1, opponent2)
if opponent1.score and opponent2.score and opponent1.score ~= opponent2.score then
return opponent1.score > opponent2.score
end
return (opponent1.name or '') < (opponent2.name or '')
return (opponent1.name or ''):lower() < (opponent2.name or ''):lower()
end

---@param match table
Expand Down Expand Up @@ -571,4 +571,24 @@ function MatchSummaryFfa.updateMatchOpponents(match)
Array.sortInPlaceBy(match.opponents, FnUtil.identity, MatchSummaryFfa.placementSortFunction)
end

---@param game table
---@param matchOpponents table[]
function MatchSummaryFfa.updateGameOpponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

-- Sort game level based on placement
Array.sortInPlaceBy(game.opponents, FnUtil.identity, MatchSummaryFfa.placementSortFunction)
end

return MatchSummaryFfa
25 changes: 1 addition & 24 deletions components/match2/wikis/apexlegends/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/fortnite/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/freefire/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/naraka/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/pubg/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/pubgmobile/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary
25 changes: 1 addition & 24 deletions components/match2/wikis/underlords/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@

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')

Expand All @@ -35,7 +32,7 @@ function CustomGameSummary.getGameByMatchId(props)

game.stream = match.stream

CustomGameSummary._opponents(game, match.opponents)
SummaryHelper.updateGameOpponents(game, match.opponents)
local scoringData = SummaryHelper.createScoringData(match)

return MatchSummaryWidgets.Tab{
Expand Down Expand Up @@ -66,24 +63,4 @@ function CustomGameSummary._createGameDetails(game)
}
end

---@param game table
---@param matchOpponents table[]
function CustomGameSummary._opponents(game, matchOpponents)
-- Add match opponent data to game opponent
game.opponents = Array.map(game.opponents,
function(gameOpponent, opponentIdx)
local matchOpponent = matchOpponents[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
)

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

return CustomGameSummary

0 comments on commit ab4695d

Please sign in to comment.