Skip to content

Commit

Permalink
feat(match2): standardize map opponent enrichment
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Dec 10, 2024
1 parent 61efb80 commit 9da2afc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 165 deletions.
19 changes: 19 additions & 0 deletions components/match2/commons/match_summary_ffa.lua
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,26 @@ function MatchSummaryFfa.updateMatchOpponents(match)
Array.forEach(match.opponents, function(opponent, idx)
opponent.placementStatus = match.extradata.status[idx]
end)
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
22 changes: 1 addition & 21 deletions components/match2/wikis/apexlegends/game_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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 +66,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 9da2afc

Please sign in to comment.