Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/wikis/commons/Array.lua
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ end
---@generic T
---@param from integer
---@param to integer
---@param funct fun(index: integer): T
---@param funct fun(index: integer): T?
---@return T[]
---@nodiscard
function Array.mapRange(from, to, funct)
Expand Down
18 changes: 7 additions & 11 deletions lua/wikis/leagueoflegends/MatchGroup/Input/Custom/Normal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ end
---@param opponentIndex integer
---@return table[]?
function CustomMatchGroupInputNormal.getParticipants(map, opponentIndex)
return Logic.nilIfEmpty(Array.map(Array.range(1, MAX_NUM_PICKS), function (playerIndex)
return Logic.nilIfEmpty(Array.mapRange(1, MAX_NUM_PICKS, function (playerIndex)
local playerData = Json.parseIfTable(map['t' .. opponentIndex .. 'p' .. playerIndex])
if Logic.isEmpty(playerData) then
return
Expand All @@ -71,24 +71,20 @@ function CustomMatchGroupInputNormal.getChampionPicks(map, opponentIndex)
---@cast participants -nil
return Array.map(participants, Operator.property('character'))
end
local picks = {}
local teamPrefix = 't' .. opponentIndex
for playerIndex = 1, MAX_NUM_PICKS do
table.insert(picks, map[teamPrefix .. 'c' .. playerIndex])
end
return picks
return Array.mapRange(1, MAX_NUM_PICKS, function (playerIndex)
return map[teamPrefix .. 'c' .. playerIndex]
end)
end

---@param map table
---@param opponentIndex integer
---@return string[]
function CustomMatchGroupInputNormal.getChampionBans(map, opponentIndex)
local bans = {}
local teamPrefix = 't' .. opponentIndex
for playerIndex = 1, MAX_NUM_BANS do
table.insert(bans, map[teamPrefix .. 'b' .. playerIndex])
end
return bans
return Array.mapRange(1, MAX_NUM_BANS, function (playerIndex)
return map[teamPrefix .. 'b' .. playerIndex]
end)
end

---@param map table
Expand Down
Loading