diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index e4beac714d..7c2570375f 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -1453,8 +1453,48 @@ function MatchGroupInputUtil.parseSettings(match, opponentCount) status = statusSettings, settings = { showGameDetails = Logic.nilOr(Logic.readBoolOrNil(match.showgamedetails), true), + matchPointThreshold = tonumber(match.matchpoint), } } end +---@param scoreDataInput table? +---@param scoreSettings {kill: integer[], placement: integer[]} +---@return table +function MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(scoreDataInput, scoreSettings) + if not scoreDataInput then + return {} + end + + local scoreBreakdown = {} + + local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) + local manualPoints = tonumber(scoreDataInput.p) + if placement or kills then + local minimumKillPoints = Array.reduce(scoreSettings.kill, math.min, math.huge) + if placement then + scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 + end + if kills then + scoreBreakdown.killPoints = kills * (scoreSettings.kill[placement] or minimumKillPoints) + scoreBreakdown.kills = kills + end + scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) + end + + local opponent = { + status = MatchGroupInputUtil.STATUS.SCORE, + scoreBreakdown = scoreBreakdown, + placement = placement, + score = manualPoints or scoreBreakdown.totalPoints, + } + + if scoreDataInput[1] == '-' then + opponent.status = MatchGroupInputUtil.STATUS.FORFEIT + opponent.score = 0 + end + + return opponent +end + return MatchGroupInputUtil diff --git a/components/match2/commons/match_summary_ffa.lua b/components/match2/commons/match_summary_ffa.lua index 204ca218ec..aeeb7f7a5c 100644 --- a/components/match2/commons/match_summary_ffa.lua +++ b/components/match2/commons/match_summary_ffa.lua @@ -7,6 +7,7 @@ -- local Array = require('Module:Array') +local FnUtil = require('Module:FnUtil') local Logic = require('Module:Logic') local Lua = require('Module:Lua') local Table = require('Module:Table') @@ -140,7 +141,7 @@ local MATCH_OVERVIEW_COLUMNS = { class = 'cell--match-points', icon = 'matchpoint', show = function(match) - return match.matchPointThreshold + return match.extradata.settings.matchPointThreshold end, header = { value = 'MPe Game', @@ -537,5 +538,39 @@ function MatchSummaryFfa.standardGame(game) }} end +---@param match table +function MatchSummaryFfa.updateMatchOpponents(match) + -- Add games opponent data to the match opponent + Array.forEach(match.opponents, function (opponent, idx) + opponent.games = Array.map(match.games, function (game) + return game.opponents[idx] + end) + end) + + local matchPointThreshold = match.extradata.settings.matchPointThreshold + if matchPointThreshold then + Array.forEach(match.opponents, function(opponent) + local matchPointReachedIn + local sum = opponent.extradata.startingpoints or 0 + for gameIdx, game in ipairs(opponent.games) do + if sum >= matchPointThreshold then + matchPointReachedIn = gameIdx + break + end + sum = sum + (game.score or 0) + end + opponent.matchPointReachedIn = matchPointReachedIn + end) + end + + -- Sort match level based on final placement & score + Array.sortInPlaceBy(match.opponents, FnUtil.identity, MatchSummaryFfa.placementSortFunction) + + -- Set the status of the current placement + Array.forEach(match.opponents, function(opponent, idx) + opponent.placementStatus = match.extradata.status[idx] + end) + +end return MatchSummaryFfa diff --git a/components/match2/wikis/apexlegends/match_group_input_custom.lua b/components/match2/wikis/apexlegends/match_group_input_custom.lua index a102c3e827..28ad6b1485 100644 --- a/components/match2/wikis/apexlegends/match_group_input_custom.lua +++ b/components/match2/wikis/apexlegends/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,40 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - if placement or kills then - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * scoreSettings.kill - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/apexlegends/match_summary.lua b/components/match2/wikis/apexlegends/match_summary.lua index 14f1aff72f..d832a22444 100644 --- a/components/match2/wikis/apexlegends/match_summary.lua +++ b/components/match2/wikis/apexlegends/match_summary.lua @@ -8,10 +8,7 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') -local Table = require('Module:Table') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local SummaryHelper = Lua.import('Module:MatchSummary/Ffa') @@ -27,8 +24,7 @@ local HtmlWidgets = Lua.import('Module:Widget/Html/All') function CustomMatchSummary.getByMatchId(props) ---@class ApexMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - match.matchPointThreshold = Table.extract(match.extradata.scoring, 'matchPointThreshold') - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -45,36 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - if match.matchPointThreshold then - Array.forEach(match.opponents, function(opponent) - local matchPointReachedIn - local sum = opponent.extradata.startingpoints or 0 - for gameIdx, game in ipairs(opponent.games) do - if sum >= match.matchPointThreshold then - matchPointReachedIn = gameIdx - break - end - sum = sum + (game.score or 0) - end - opponent.matchPointReachedIn = matchPointReachedIn - end) - end - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary diff --git a/components/match2/wikis/fortnite/match_group_input_custom.lua b/components/match2/wikis/fortnite/match_group_input_custom.lua index 22bd0ddb1d..cf01b626d1 100644 --- a/components/match2/wikis/fortnite/match_group_input_custom.lua +++ b/components/match2/wikis/fortnite/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,42 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - local points = tonumber(scoreDataInput.p) - if placement or kills then - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * scoreSettings.kill - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = points or scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/fortnite/match_summary.lua b/components/match2/wikis/fortnite/match_summary.lua index 7817d1f947..fdfa2de1b7 100644 --- a/components/match2/wikis/fortnite/match_summary.lua +++ b/components/match2/wikis/fortnite/match_summary.lua @@ -8,8 +8,6 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') @@ -19,14 +17,14 @@ local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') ---@class FortniteMatchGroupUtilMatch: MatchGroupUtilMatch ----@field games ApexMatchGroupUtilGame[] +---@field games FortniteMatchGroupUtilGame[] ---@param props {bracketId: string, matchId: string} ---@return Widget function CustomMatchSummary.getByMatchId(props) - ---@class ApexMatchGroupUtilMatch + ---@class FortniteMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -43,22 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end ----@param match table -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary diff --git a/components/match2/wikis/freefire/match_group_input_custom.lua b/components/match2/wikis/freefire/match_group_input_custom.lua index 21ef4235bc..9c41bd03dc 100644 --- a/components/match2/wikis/freefire/match_group_input_custom.lua +++ b/components/match2/wikis/freefire/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,42 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - local points = tonumber(scoreDataInput.p) - if placement or kills then - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * scoreSettings.kill - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = points or scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/freefire/match_summary.lua b/components/match2/wikis/freefire/match_summary.lua index da95e3d1c1..d0e93b647c 100644 --- a/components/match2/wikis/freefire/match_summary.lua +++ b/components/match2/wikis/freefire/match_summary.lua @@ -8,8 +8,6 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') @@ -19,14 +17,14 @@ local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') ---@class FreefireMatchGroupUtilMatch: MatchGroupUtilMatch ----@field games ApexMatchGroupUtilGame[] +---@field games FreefireMatchGroupUtilGame[] ---@param props {bracketId: string, matchId: string} ---@return Widget function CustomMatchSummary.getByMatchId(props) - ---@class ApexMatchGroupUtilMatch + ---@class FreefireMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -43,22 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end ----@param match table -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary diff --git a/components/match2/wikis/naraka/match_group_input_custom.lua b/components/match2/wikis/naraka/match_group_input_custom.lua index 00a43acdd8..e95fd71dc6 100644 --- a/components/match2/wikis/naraka/match_group_input_custom.lua +++ b/components/match2/wikis/naraka/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,43 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - local points = tonumber(scoreDataInput.p) - if placement or kills then - local minimumKillPoints = Array.reduce(scoreSettings.kill, math.min, math.huge) - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * (scoreSettings.kill[placement] or minimumKillPoints) - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = points or scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/naraka/match_summary.lua b/components/match2/wikis/naraka/match_summary.lua index 1e035b26b6..7d4c50b7b6 100644 --- a/components/match2/wikis/naraka/match_summary.lua +++ b/components/match2/wikis/naraka/match_summary.lua @@ -8,8 +8,6 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') @@ -26,7 +24,7 @@ local HtmlWidgets = Lua.import('Module:Widget/Html/All') function CustomMatchSummary.getByMatchId(props) ---@class NarakaMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -43,22 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end ----@param match table -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary diff --git a/components/match2/wikis/pubg/match_group_input_custom.lua b/components/match2/wikis/pubg/match_group_input_custom.lua index 778ea637ff..9d09777e07 100644 --- a/components/match2/wikis/pubg/match_group_input_custom.lua +++ b/components/match2/wikis/pubg/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,41 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - if placement or kills then - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * scoreSettings.kill - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/pubg/match_summary.lua b/components/match2/wikis/pubg/match_summary.lua index 4eabb75dcf..bde3b460b8 100644 --- a/components/match2/wikis/pubg/match_summary.lua +++ b/components/match2/wikis/pubg/match_summary.lua @@ -8,8 +8,6 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') @@ -19,14 +17,14 @@ local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') ---@class PubgMatchGroupUtilMatch: MatchGroupUtilMatch ----@field games ApexMatchGroupUtilGame[] +---@field games PubgMatchGroupUtilGame[] ---@param props {bracketId: string, matchId: string} ---@return Widget function CustomMatchSummary.getByMatchId(props) - ---@class ApexMatchGroupUtilMatch + ---@class PubgMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -43,22 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end ----@param match table -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary diff --git a/components/match2/wikis/pubgmobile/match_group_input_custom.lua b/components/match2/wikis/pubgmobile/match_group_input_custom.lua index 7a11159501..c5b154583c 100644 --- a/components/match2/wikis/pubgmobile/match_group_input_custom.lua +++ b/components/match2/wikis/pubgmobile/match_group_input_custom.lua @@ -51,7 +51,7 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) - return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) + return MatchGroupInputUtil.makeBattleRoyaleMapOpponentDetails(opponentMapInput, scoreSettings) end) map.scores = Array.map(map.opponents, Operator.property('score')) @@ -106,41 +106,4 @@ function MapFunctions.getExtraData(map) } end ----@param scoreDataInput table? ----@param scoreSettings table ----@return table -function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings) - if not scoreDataInput then - return {} - end - - local scoreBreakdown = {} - - local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2]) - if placement or kills then - if placement then - scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0 - end - if kills then - scoreBreakdown.killPoints = kills * scoreSettings.kill - scoreBreakdown.kills = kills - end - scoreBreakdown.totalPoints = (scoreBreakdown.placePoints or 0) + (scoreBreakdown.killPoints or 0) - end - - local opponent = { - status = MatchGroupInputUtil.STATUS.SCORE, - scoreBreakdown = scoreBreakdown, - placement = placement, - score = scoreBreakdown.totalPoints, - } - - if scoreDataInput[1] == '-' then - opponent.status = MatchGroupInputUtil.STATUS.FORFEIT - opponent.score = 0 - end - - return opponent -end - return CustomMatchGroupInput diff --git a/components/match2/wikis/pubgmobile/match_summary.lua b/components/match2/wikis/pubgmobile/match_summary.lua index 958267567d..b399cf8659 100644 --- a/components/match2/wikis/pubgmobile/match_summary.lua +++ b/components/match2/wikis/pubgmobile/match_summary.lua @@ -8,8 +8,6 @@ local CustomMatchSummary = {} -local Array = require('Module:Array') -local FnUtil = require('Module:FnUtil') local Lua = require('Module:Lua') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') @@ -19,14 +17,14 @@ local MatchSummaryWidgets = Lua.import('Module:Widget/Match/Summary/Ffa/All') local HtmlWidgets = Lua.import('Module:Widget/Html/All') ---@class PubgmMatchGroupUtilMatch: MatchGroupUtilMatch ----@field games ApexMatchGroupUtilGame[] +---@field games PubgmMatchGroupUtilGame[] ---@param props {bracketId: string, matchId: string} ---@return Widget function CustomMatchSummary.getByMatchId(props) - ---@class ApexMatchGroupUtilMatch + ---@class PubgmMatchGroupUtilMatch local match = MatchGroupUtil.fetchMatchForBracketDisplay(props.bracketId, props.matchId) - CustomMatchSummary._opponents(match) + SummaryHelper.updateMatchOpponents(match) local scoringData = SummaryHelper.createScoringData(match) return HtmlWidgets.Fragment{children = { @@ -43,22 +41,4 @@ function CustomMatchSummary.getByMatchId(props) }} end ----@param match table -function CustomMatchSummary._opponents(match) - -- Add games opponent data to the match opponent - Array.forEach(match.opponents, function (opponent, idx) - opponent.games = Array.map(match.games, function (game) - return game.opponents[idx] - end) - end) - - -- Sort match level based on final placement & score - Array.sortInPlaceBy(match.opponents, FnUtil.identity, SummaryHelper.placementSortFunction) - - -- Set the status of the current placement - Array.forEach(match.opponents, function(opponent, idx) - opponent.placementStatus = match.extradata.status[idx] - end) -end - return CustomMatchSummary