Skip to content

Commit

Permalink
feat(match2) Add map points input to Halo (#4793)
Browse files Browse the repository at this point in the history
* Add map points to halo

* catch nil

* Extract to function as per review

* Flip scores

* Update components/match2/wikis/halo/match_summary.lua

Co-authored-by: Rikard Blixt <[email protected]>

* Apply suggestions from code review

Co-authored-by: Rikard Blixt <[email protected]>

* linelength

---------

Co-authored-by: Rikard Blixt <[email protected]>
  • Loading branch information
mbergen and Rathoz authored Oct 14, 2024
1 parent 4daa460 commit 94d053b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions components/match2/wikis/halo/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ end
function MapFunctions.getExtraData(map, opponentCount)
return {
comment = map.comment,
points1 = map.points1,
points2 = map.points2,
}
end

Expand Down
23 changes: 21 additions & 2 deletions components/match2/wikis/halo/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,33 @@ function CustomMatchSummary._createMapRow(game)
centerNode:addClass('brkts-popup-spaced-map-skip')
end

local displayScore = function(opponentIndex)
local score = DisplayHelper.MapScore(
game.scores[opponentIndex],
opponentIndex,
game.resultType,
game.walkover,
game.winner
)
local points = game.extradata['points' .. opponentIndex]
if not points then
return score
end
local flipped = opponentIndex == 2
if flipped then
return '(' .. points .. ') ' .. score
end
return score .. ' (' .. points .. ')'
end

local leftNode = mw.html.create('div')
:addClass('brkts-popup-spaced')
:node(CustomMatchSummary._addCheckmark(game.winner == 1))
:node(DisplayHelper.MapScore(game.scores[1], 1, game.resultType, game.walkover, game.winner))
:node(displayScore(1))

local rightNode = mw.html.create('div')
:addClass('brkts-popup-spaced')
:node(DisplayHelper.MapScore(game.scores[2], 2, game.resultType, game.walkover, game.winner))
:node(displayScore(2))
:node(CustomMatchSummary._addCheckmark(game.winner == 2))

row:addElement(leftNode)
Expand Down

0 comments on commit 94d053b

Please sign in to comment.