Skip to content

Commit

Permalink
feat(match2): on BRs, improve the score display when partial results …
Browse files Browse the repository at this point in the history
…are entered (#5150)
  • Loading branch information
Rathoz authored Nov 28, 2024
1 parent dd718dc commit d983ce9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
4 changes: 3 additions & 1 deletion components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ end
---@param opponents {score: number}[]
---@return integer
function MatchGroupInputUtil.getHighestScoringOpponent(opponents)
local scores = Array.map(opponents, Operator.property('score'))
local scores = Array.map(opponents, function (opponent)
return opponent.score or 0
end)
local maxScore = Array.max(scores)
return Array.indexOf(scores, FnUtil.curry(Operator.eq, maxScore))
end
Expand Down
16 changes: 10 additions & 6 deletions components/match2/wikis/apexlegends/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
function MatchFunctions.calculateMatchScore(opponents, maps)
return function(opponentIndex)
return Array.reduce(Array.map(maps, function(map)
return map.scores[opponentIndex] or 0
return map.opponents[opponentIndex].score or 0
end), Operator.add, 0) + (opponents[opponentIndex].extradata.startingpoints or 0)
end
end
Expand Down Expand Up @@ -145,11 +145,15 @@ function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings)
local scoreBreakdown = {}

local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2])
if placement and kills then
scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0
scoreBreakdown.killPoints = kills * scoreSettings.kill
scoreBreakdown.kills = kills
scoreBreakdown.totalPoints = scoreBreakdown.placePoints + scoreBreakdown.killPoints
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,
Expand Down
17 changes: 11 additions & 6 deletions components/match2/wikis/pubg/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
function MatchFunctions.calculateMatchScore(opponents, maps)
return function(opponentIndex)
return Array.reduce(Array.map(maps, function(map)
return map.scores[opponentIndex] or 0
return map.opponents[opponentIndex].score or 0
end), Operator.add, 0)
end
end
Expand Down Expand Up @@ -144,12 +144,17 @@ function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings)
local scoreBreakdown = {}

local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2])
if placement and kills then
scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0
scoreBreakdown.killPoints = kills * scoreSettings.kill
scoreBreakdown.kills = kills
scoreBreakdown.totalPoints = scoreBreakdown.placePoints + scoreBreakdown.killPoints
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,
Expand Down
17 changes: 11 additions & 6 deletions components/match2/wikis/pubgmobile/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
function MatchFunctions.calculateMatchScore(opponents, maps)
return function(opponentIndex)
return Array.reduce(Array.map(maps, function(map)
return map.scores[opponentIndex] or 0
return map.opponents[opponentIndex].score or 0
end), Operator.add, 0)
end
end
Expand Down Expand Up @@ -144,12 +144,17 @@ function MapFunctions.makeMapOpponentDetails(scoreDataInput, scoreSettings)
local scoreBreakdown = {}

local placement, kills = tonumber(scoreDataInput[1]), tonumber(scoreDataInput[2])
if placement and kills then
scoreBreakdown.placePoints = scoreSettings.placement[placement] or 0
scoreBreakdown.killPoints = kills * scoreSettings.kill
scoreBreakdown.kills = kills
scoreBreakdown.totalPoints = scoreBreakdown.placePoints + scoreBreakdown.killPoints
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,
Expand Down

0 comments on commit d983ce9

Please sign in to comment.