diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 5072c64e13..e8bb68d6e5 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -1210,6 +1210,10 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser) map.map = Parser.getMapName(map, mapIndex, match) end + if Parser.getMapBestOf then + map.bestof = Parser.getMapBestOf(map) + end + if Parser.mapIsFinished then map.finished = Parser.mapIsFinished(map, opponents, finishedInput, winnerInput) else @@ -1220,10 +1224,6 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser) map.patch = Parser.getPatch(map) end - if Parser.getMapBestOf then - map.bestof = Parser.getMapBestOf(map) - end - map.opponents = Array.map(opponents, function(opponent, opponentIndex) local computeOpponentScore = Parser.computeOpponentScore or MatchGroupInputUtil.computeOpponentScore local score, status = computeOpponentScore({ diff --git a/components/match2/wikis/brawlstars/match_group_input_custom.lua b/components/match2/wikis/brawlstars/match_group_input_custom.lua index ac79ae9ace..b83407e0b8 100644 --- a/components/match2/wikis/brawlstars/match_group_input_custom.lua +++ b/components/match2/wikis/brawlstars/match_group_input_custom.lua @@ -100,10 +100,11 @@ function MapFunctions.getMapBestOf(map) return bestof or DEFAULT_BESTOF_MAP end +---@param match table ---@param map table ----@param opponentCount integer +---@param opponents table[] ---@return table -function MapFunctions.getExtraData(map, opponentCount) +function MapFunctions.getExtraData(match, map, opponents) local extradata = { bestof = map.bestof, comment = map.comment, @@ -113,7 +114,7 @@ function MapFunctions.getExtraData(map, opponentCount) local bans = {} local getCharacterName = FnUtil.curry(MatchGroupInputUtil.getCharacterName, BrawlerNames) - for opponentIndex = 1, opponentCount do + for opponentIndex = 1, #opponents do bans['team' .. opponentIndex] = {} for _, ban in Table.iter.pairsByPrefix(map, 't' .. opponentIndex .. 'b') do ban = getCharacterName(ban) diff --git a/components/match2/wikis/clashroyale/match_group_input_custom.lua b/components/match2/wikis/clashroyale/match_group_input_custom.lua index d4983badcd..8f08c45bde 100644 --- a/components/match2/wikis/clashroyale/match_group_input_custom.lua +++ b/components/match2/wikis/clashroyale/match_group_input_custom.lua @@ -87,14 +87,13 @@ function MatchFunctions.getExtraData(match, games, opponents) return extradata end ----@param mapInput table ----@param finished boolean +---@param map table ---@return fun(opponentIndex: integer): integer? -function MapFunctions.calculateMapScore(mapInput, finished) - local winner = tonumber(mapInput.winner) +function MapFunctions.calculateMapScore(map) + local winner = tonumber(map.winner) return function(opponentIndex) -- TODO Better to check if map has started, rather than finished, for a more correct handling - if not winner and not finished then + if not winner and not map.finished then return end @@ -164,15 +163,15 @@ function MapFunctions.getPartyParticipants(mapInput, opponent, opponentIndex) end ---@param match table ----@param mapInput table ----@param mapOpponents {players: {player: string, played: boolean, cards: table}[]}[] +---@param map table +---@param opponents table[] ---@return table -function MapFunctions.getExtraData(match, mapInput, mapOpponents) +function MapFunctions.getExtraData(match, map, opponents) local extradata = { - comment = mapInput.comment, + comment = map.comment, } - return Table.merge(extradata, MapFunctions.getCardsExtradata(mapOpponents)) + return Table.merge(extradata, MapFunctions.getCardsExtradata(map.opponents)) end --- additionally store cards info in extradata so we can condition on them diff --git a/components/match2/wikis/magic/match_group_input_custom.lua b/components/match2/wikis/magic/match_group_input_custom.lua index 5647101df5..db4d71b335 100644 --- a/components/match2/wikis/magic/match_group_input_custom.lua +++ b/components/match2/wikis/magic/match_group_input_custom.lua @@ -79,14 +79,13 @@ function CustomMatchGroupInput._hasTeamOpponent(match) return match.opponent1.type == Opponent.team or match.opponent2.type == Opponent.team end ----@param winnerInput string|integer|nil ----@param finished boolean +---@param map table ---@return fun(opponentIndex: integer): integer? -function MapFunctions.calculateMapScore(winnerInput, finished) - local winner = tonumber(winnerInput) +function MapFunctions.calculateMapScore(map) + local winner = tonumber(map.winner) return function(opponentIndex) -- TODO Better to check if map has started, rather than finished, for a more correct handling - if not winner and not finished then + if not winner and not map.finished then return end return winner == opponentIndex and 1 or 0 diff --git a/components/match2/wikis/smite/match_group_input_custom.lua b/components/match2/wikis/smite/match_group_input_custom.lua index 38b946f5b0..09a843998f 100644 --- a/components/match2/wikis/smite/match_group_input_custom.lua +++ b/components/match2/wikis/smite/match_group_input_custom.lua @@ -6,12 +6,9 @@ -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- -local Array = require('Module:Array') local FnUtil = require('Module:FnUtil') local GodNames = mw.loadData('Module:GodNames') -local Logic = require('Module:Logic') local Lua = require('Module:Lua') -local Operator = require('Module:Operator') local Table = require('Module:Table') local Variables = require('Module:Variables') diff --git a/components/match2/wikis/splatoon/match_group_input_custom.lua b/components/match2/wikis/splatoon/match_group_input_custom.lua index 8e79ba1cb6..4582d00610 100644 --- a/components/match2/wikis/splatoon/match_group_input_custom.lua +++ b/components/match2/wikis/splatoon/match_group_input_custom.lua @@ -7,10 +7,7 @@ -- local Array = require('Module:Array') -local Logic = require('Module:Logic') local Lua = require('Module:Lua') -local Operator = require('Module:Operator') -local Table = require('Module:Table') local WeaponNames = mw.loadData('Module:WeaponNames') local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util') diff --git a/components/match2/wikis/tetris/match_group_input_custom.lua b/components/match2/wikis/tetris/match_group_input_custom.lua index 6ab201330b..e3906fa62a 100644 --- a/components/match2/wikis/tetris/match_group_input_custom.lua +++ b/components/match2/wikis/tetris/match_group_input_custom.lua @@ -92,8 +92,10 @@ function MapFunctions.calculateMapScore(map) end ---@param map table +---@param mapIndex integer +---@param match table ---@return string? -function MapFunctions.getMapName(map) +function MapFunctions.getMapName(map, mapIndex, match) return nil end diff --git a/components/match2/wikis/valorant/match_group_input_custom.lua b/components/match2/wikis/valorant/match_group_input_custom.lua index 5afa5f8995..a9a9d87081 100644 --- a/components/match2/wikis/valorant/match_group_input_custom.lua +++ b/components/match2/wikis/valorant/match_group_input_custom.lua @@ -11,8 +11,6 @@ local AgentNames = require('Module:AgentNames') local FnUtil = require('Module:FnUtil') local Json = require('Module:Json') local Lua = require('Module:Lua') -local Operator = require('Module:Operator') -local Table = require('Module:Table') local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')