Skip to content

Commit

Permalink
feat(match2): Use parseMapPlayers on AoE (#5176)
Browse files Browse the repository at this point in the history
* Switch AoE to parseMapPlayers

* Prevent nil concat/comparison in match summary and legacy

* Direct return

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

---------

Co-authored-by: Rikard Blixt <[email protected]>
  • Loading branch information
mbergen and Rathoz authored Dec 6, 2024
1 parent 1d6d573 commit 3114687
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function CustomMatchGroupInput.getPlayersOfMapOpponent(map, opponent, opponentIn
end
local civs = Array.parseCommaSeparatedString(map['civs' .. opponentIndex])

local participants, unattachedParticipants = MatchGroupInputUtil.parseParticipants(
return MatchGroupInputUtil.parseMapPlayers(
opponent.match2players,
players,
function(playerIndex)
Expand All @@ -322,11 +322,7 @@ function CustomMatchGroupInput.getPlayersOfMapOpponent(map, opponent, opponentIn
}
end
)
Array.forEach(unattachedParticipants, function(participant)
table.insert(participants, participant)
end)

return participants
end

---@param winnerInput string|integer|nil
Expand Down
1 change: 1 addition & 0 deletions components/match2/wikis/ageofempires/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function MatchLegacy.storeGames(match, match2)
Array.forEach(opponents, function(opponent, opponentIndex)
-- opponent.players can have gaps
for _, player in pairs(opponent.players) do
if Table.isEmpty(player) then return end
local prefix = 'o' .. opponentIndex .. 'p' .. player.index
game.extradata[prefix] = player.pageName
game.extradata[prefix .. 'faction'] = player.civ
Expand Down
6 changes: 5 additions & 1 deletion components/match2/wikis/ageofempires/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local Lua = require('Module:Lua')
local MapMode = require('Module:MapMode')
local Operator = require('Module:Operator')
local String = require('Module:StringUtils')
local Table = require('Module:Table')

local DisplayHelper = Lua.import('Module:MatchGroup/Display/Helper')
local MatchSummary = Lua.import('Module:MatchSummary/Base')
Expand Down Expand Up @@ -112,7 +113,10 @@ function CustomMatchSummary._createGame(game, props)
:css('flex-direction', 'column')
:css('overflow', 'hidden')
Array.forEach(
Array.sortBy(game.opponents[opponentId].players, Operator.property('index')),
Array.sortBy(
Array.filter(game.opponents[opponentId].players, Table.isNotEmpty),
Operator.property('index')
),
function(player)
display:node(createParticipant(player, opponentId == 1))
end
Expand Down

0 comments on commit 3114687

Please sign in to comment.