diff --git a/components/match2/commons/match.lua b/components/match2/commons/match.lua index efdc52ef1b5..8132e97cda5 100644 --- a/components/match2/commons/match.lua +++ b/components/match2/commons/match.lua @@ -322,6 +322,8 @@ end ---@param match table function Match._prepareMatchRecordForStore(match) + Match._commonBackwardsCompatabilityForV3API(match) + match.dateexact = Logic.readBool(match.dateexact) and 1 or 0 match.finished = Logic.readBool(match.finished) and 1 or 0 match.match2bracketdata = match.match2bracketdata or match.bracketdata @@ -364,12 +366,17 @@ end ---@param matchRecord table ---@param gameRecord table function Match._prepareGameRecordForStore(matchRecord, gameRecord) + -- Backwards compatibility for API v3 + gameRecord.opponents = gameRecord.opponents or {} + Match._commonBackwardsCompatabilityForV3API(gameRecord) + gameRecord.parent = matchRecord.parent gameRecord.tournament = matchRecord.tournament + if not gameRecord.participants then gameRecord.participants = {} for opponentId, opponent in ipairs(gameRecord.opponents or {}) do - for playerId, player in pairs(opponent.players) do + for playerId, player in pairs(opponent.players or {}) do -- Deep copy have to be used here, otherwise a json.stringify complains about circular references -- between participants and opponents gameRecord.participants[opponentId .. '_' .. playerId] = Table.deepCopy(player) @@ -379,6 +386,35 @@ function Match._prepareGameRecordForStore(matchRecord, gameRecord) Match.clampFields(gameRecord, Match.gameFields) end +---Adds fields needed for backwards compatibility with API v3. +---walkover and resulttype are added to record. +---@param record table #game or match record +function Match._commonBackwardsCompatabilityForV3API(record) + if record.finished then + if not record.walkover then + local opponents = record.opponents or {} + local function calculateWalkover() + local walkoverOpponent = Array.find(opponents, function(opponent) + return opponent.status == 'FF' or opponent.status == 'DQ' or opponent.status == 'L' + end) + return walkoverOpponent and walkoverOpponent.status:lower() or '' + end + record.walkover = calculateWalkover() + end + + if not record.resulttype then + if record.status == 'notplayed' then + record.resulttype = 'np' + elseif record.winner == 0 then + record.resulttype = 'draw' + elseif record.walkover ~= '' then + record.resulttype = record.walkover:upper() + else + record.resulttype = '' + end + end + end +end Match.matchFields = Table.map({ 'bestof', @@ -400,7 +436,7 @@ Match.matchFields = Table.map({ 'parentname', 'patch', 'publishertier', - 'resulttype', + 'resulttype', -- LPDB API v3: backwards compatibility 'series', 'shortname', 'status', @@ -409,7 +445,7 @@ Match.matchFields = Table.map({ 'tournament', 'type', 'vod', - 'walkover', + 'walkover', -- LPDB API v3: backwards compatibility 'winner', 'section', }, function(_, field) return field, true end) @@ -443,15 +479,16 @@ Match.gameFields = Table.map({ 'parent', 'participants', 'patch', - 'opponents', -- Not a real field yet, but will be in the future. Also for use in Match/Legacy - 'resulttype', + 'opponents', + 'resulttype', -- LPDB API v3: backwards compatibility 'rounds', 'scores', + 'status', 'subgroup', 'tournament', 'type', 'vod', - 'walkover', + 'walkover', -- LPDB API v3: backwards compatibility 'winner', }, function(_, field) return field, true end) diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 42d4ab46490..3ab46eca57a 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -76,11 +76,10 @@ MatchGroupInputUtil.STATUS_INPUTS = { MatchGroupInputUtil.STATUS = Table.copy(MatchGroupInputUtil.STATUS_INPUTS) MatchGroupInputUtil.STATUS.SCORE = 'S' -MatchGroupInputUtil.RESULT_TYPE = { - DEFAULT = 'default', - NOT_PLAYED = 'np', - DRAW = 'draw', +MatchGroupInputUtil.MATCH_STATUS = { + NOT_PLAYED = 'notplayed', } + MatchGroupInputUtil.WALKOVER = { FORFIET = 'ff', DISQUALIFIED = 'dq', @@ -613,37 +612,27 @@ function MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput) or (type(finishedInput) == 'string' and MatchGroupInputUtil.isNotPlayedInput(finishedInput)) end ----Should only be called on finished matches or maps ---@param winnerInput integer|string|nil ---@param finishedInput string? ----@param opponents {score: number?, status: string}[] ----@return string? #Result Type -function MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) +---@return string? #Match Status +function MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) if MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput) then - return MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED - end - - if MatchGroupInputUtil.isDraw(opponents, winnerInput) then - return MatchGroupInputUtil.RESULT_TYPE.DRAW - end - - if MatchGroupInputUtil.hasSpecialStatus(opponents) then - return MatchGroupInputUtil.RESULT_TYPE.DEFAULT + return MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED end end ----@param resultType string? +---@param status string? ---@param winnerInput integer|string|nil ---@param opponents {score: number, status: string, placement: integer?}[] ---@return integer? # Winner -function MatchGroupInputUtil.getWinner(resultType, winnerInput, opponents) - if resultType == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED then +function MatchGroupInputUtil.getWinner(status, winnerInput, opponents) + if status == MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED then return nil elseif Logic.isNumeric(winnerInput) then return tonumber(winnerInput) - elseif resultType == MatchGroupInputUtil.RESULT_TYPE.DRAW then + elseif MatchGroupInputUtil.isDraw(opponents, winnerInput) then return MatchGroupInputUtil.WINNER_DRAW - elseif resultType == MatchGroupInputUtil.RESULT_TYPE.DEFAULT then + elseif MatchGroupInputUtil.hasSpecialStatus(opponents) then return MatchGroupInputUtil.getDefaultWinner(opponents) elseif MatchGroupInputUtil.findOpponentWithFirstPlace(opponents) then return MatchGroupInputUtil.findOpponentWithFirstPlace(opponents) @@ -675,27 +664,6 @@ function MatchGroupInputUtil.getHighestScoringOpponent(opponents) return Array.indexOf(scores, FnUtil.curry(Operator.eq, maxScore)) end ----@param resultType string? ----@param opponents {status: string}[] ----@return string? # Walkover Type -function MatchGroupInputUtil.getWalkover(resultType, opponents) - if resultType == MatchGroupInputUtil.RESULT_TYPE.DEFAULT then - return MatchGroupInputUtil.getWalkoverType(opponents) - end -end - ----@param opponents {status: string}[] ----@return string? -function MatchGroupInputUtil.getWalkoverType(opponents) - if MatchGroupInputUtil.hasForfeit(opponents) then - return MatchGroupInputUtil.WALKOVER.FORFIET - elseif MatchGroupInputUtil.hasDisqualified(opponents) then - return MatchGroupInputUtil.WALKOVER.DISQUALIFIED - elseif MatchGroupInputUtil.hasDefaultWinLoss(opponents) then - return MatchGroupInputUtil.WALKOVER.NO_SCORE - end -end - ---@param match table ---@param maps {scores: integer[]?, winner: integer?}[] ---@return boolean @@ -810,27 +778,6 @@ function MatchGroupInputUtil._opponentWithStatus(opponents, status) return Array.indexOf(opponents, function (opponent) return opponent.status == status end) end --- function to check for forfeits ----@param opponents {status: string?}[] ----@return boolean -function MatchGroupInputUtil.hasForfeit(opponents) - return MatchGroupInputUtil._opponentWithStatus(opponents, MatchGroupInputUtil.STATUS.FORFIET) ~= 0 -end - --- function to check for DQ's ----@param opponents {status: string?}[] ----@return boolean -function MatchGroupInputUtil.hasDisqualified(opponents) - return MatchGroupInputUtil._opponentWithStatus(opponents, MatchGroupInputUtil.STATUS.DISQUALIFIED) ~= 0 -end - --- function to check for W/L ----@param opponents {status: string?}[] ----@return boolean -function MatchGroupInputUtil.hasDefaultWinLoss(opponents) - return MatchGroupInputUtil._opponentWithStatus(opponents, MatchGroupInputUtil.STATUS.DEFAULT_LOSS) ~= 0 -end - -- function to check for Normal Scores ---@param opponents {status: string?}[] ---@return boolean @@ -838,7 +785,7 @@ function MatchGroupInputUtil.hasScore(opponents) return MatchGroupInputUtil._opponentWithStatus(opponents, MatchGroupInputUtil.STATUS.SCORE) ~= 0 end --- Get the winner when resulttype=default +-- Get the winner with letter results ---@param opponents {status: string?}[] ---@return integer function MatchGroupInputUtil.getDefaultWinner(opponents) @@ -846,19 +793,18 @@ function MatchGroupInputUtil.getDefaultWinner(opponents) return idx > 0 and idx or -1 end - --- Calculate the correct value of the 'placement' for the two-opponent matches/games. --- Cases: --- If Winner = OpponentIndex, return 1 --- If Winner = 0, means it was a draw, return 1 --- If Winner = -1, means that mean no team won, returns 2 --- Otherwise return 2 ----@param resultType string? +---@param status string? ---@param winner integer? ---@param opponentIndex integer ---@return integer? -function MatchGroupInputUtil.placementFromWinner(resultType, winner, opponentIndex) - if resultType == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED then +function MatchGroupInputUtil.placementFromWinner(status, winner, opponentIndex) + if status == MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED then return nil end if winner == 0 or winner == opponentIndex then diff --git a/components/match2/commons/match_group_util.lua b/components/match2/commons/match_group_util.lua index 39ffb965d7a..3aa82988f94 100644 --- a/components/match2/commons/match_group_util.lua +++ b/components/match2/commons/match_group_util.lua @@ -192,6 +192,8 @@ MatchGroupUtil.types.GameOpponent = TypeUtil.struct({ type = 'string', }) +---@alias MatchStatus 'notplayed'|''|nil +MatchGroupUtil.types.Status = TypeUtil.optional(TypeUtil.literalUnion('notplayed', '')) ---@alias ResultType 'default'|'draw'|'np' MatchGroupUtil.types.ResultType = TypeUtil.literalUnion('default', 'draw', 'np') ---@alias WalkoverType 'l'|'ff'|'dq' @@ -210,6 +212,7 @@ MatchGroupUtil.types.Walkover = TypeUtil.literalUnion('l', 'ff', 'dq') ---@field participants table ---@field resultType ResultType? ---@field scores number[] +---@field status MatchStatus ---@field subgroup number? ---@field type string? ---@field vod string? @@ -228,6 +231,7 @@ MatchGroupUtil.types.Game = TypeUtil.struct({ participants = 'table', resultType = TypeUtil.optional(MatchGroupUtil.types.ResultType), scores = TypeUtil.array('number'), + status = MatchGroupUtil.types.Status, subgroup = 'number?', type = 'string?', vod = 'string?', @@ -249,6 +253,7 @@ MatchGroupUtil.types.Game = TypeUtil.struct({ ---@field mode string? ---@field opponents standardOpponent[] ---@field resultType ResultType? +---@field status MatchStatus ---@field stream table ---@field tickername string? ---@field tournament string? @@ -272,6 +277,7 @@ MatchGroupUtil.types.Match = TypeUtil.struct({ mode = 'string', opponents = TypeUtil.array(MatchGroupUtil.types.Opponent), resultType = 'string?', + status = MatchGroupUtil.types.Status, stream = 'table', tickername = 'string?', tournament = 'string?', @@ -530,6 +536,7 @@ function MatchGroupUtil.matchFromRecord(record) parent = record.parent, patch = record.patch, resultType = nilIfEmpty(record.resulttype), + status = nilIfEmpty(record.status), stream = Json.parseIfString(record.stream) or {}, tickername = record.tickername, timestamp = tonumber(Table.extract(extradata, 'timestamp')), @@ -725,6 +732,7 @@ function MatchGroupUtil.gameFromRecord(record, opponentCount) participants = participants, resultType = nilIfEmpty(record.resulttype), scores = Json.parseIfString(record.scores) or {}, + status = nilIfEmpty(record.status), subgroup = tonumber(record.subgroup), type = nilIfEmpty(record.type), vod = nilIfEmpty(record.vod), diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua index 14feb3c18bb..5f2e2277c1b 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua @@ -80,11 +80,10 @@ function StarcraftMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -292,7 +291,7 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) } map.finished = MapFunctions.isFinished(mapInput, opponentCount) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = mapInput.walkover, winner = mapInput.winner, @@ -302,12 +301,11 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(mapInput.winner, mapInput.finished, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, mapInput.winner, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(mapInput.winner, mapInput.finished) + map.winner = MatchGroupInputUtil.getWinner(map.status, mapInput.winner, map.opponents) end return map, subGroup diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua index 974356de116..d543631f99d 100644 --- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua +++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft_ffa.lua @@ -64,7 +64,7 @@ function StarcraftFfaMatchGroupInput.processMatch(match, options) if MatchGroupInputUtil.isNotPlayed(match.winner, finishedInput) then match.finished = true - match.resulttype = MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED + match.status = MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED match.extradata = {ffa = 'true'} return match end @@ -90,10 +90,9 @@ function StarcraftFfaMatchGroupInput.processMatch(match, options) end) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(match.winner, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(match.winner, finishedInput) StarcraftFfaMatchGroupInput._setPlacements(opponents) - match.winner = StarcraftFfaMatchGroupInput._getWinner(opponents, match.winner, match.resulttype) + match.winner = StarcraftFfaMatchGroupInput._getWinner(opponents, match.winner) end Array.forEach(opponents, function(opponent) @@ -250,27 +249,26 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores) if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then map.finished = true - map.resulttype = MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED + map.status = MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED map.scores = {} map.statuses = {} return map end - local opponentsInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) return MapFunctions.getOpponentInfo(mapInput, opponentIndex, hasScores) end) - map.scores = Array.map(opponentsInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) map.finished = MapFunctions.isFinished(mapInput, opponentCount, hasScores) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(mapInput.winner, mapInput.finished, opponentsInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentsInfo) - StarcraftFfaMatchGroupInput._setPlacements(opponentsInfo, not hasScores) - map.winner = StarcraftFfaMatchGroupInput._getWinner(opponentsInfo, mapInput.winner, map.resulttype) + map.status = MatchGroupInputUtil.getMatchStatus(mapInput.winner, mapInput.finished) + StarcraftFfaMatchGroupInput._setPlacements(map.opponents, not hasScores) + map.winner = StarcraftFfaMatchGroupInput._getWinner(map.opponents, mapInput.winner) end - Array.forEach(opponentsInfo, function(opponentInfo, opponentIndex) + Array.forEach(map.opponents, function(opponentInfo, opponentIndex) map.extradata['placement' .. opponentIndex] = opponentInfo.placement end) @@ -370,12 +368,11 @@ end ---@param opponents {placement: integer?, score: integer?, status: string} ---@param winnerInput integer|string|nil ----@param resultType string? ---@return integer? -function StarcraftFfaMatchGroupInput._getWinner(opponents, winnerInput, resultType) +function StarcraftFfaMatchGroupInput._getWinner(opponents, winnerInput) if Logic.isNumeric(winnerInput) then return tonumber(winnerInput) - elseif resultType == MatchGroupInputUtil.RESULT_TYPE.DRAW then + elseif MatchGroupInputUtil.isDraw(opponents, winnerInput) then return MatchGroupInputUtil.WINNER_DRAW end diff --git a/components/match2/wikis/ageofempires/match_group_input_custom.lua b/components/match2/wikis/ageofempires/match_group_input_custom.lua index d03f4d4f4d4..04a11b0b681 100644 --- a/components/match2/wikis/ageofempires/match_group_input_custom.lua +++ b/components/match2/wikis/ageofempires/match_group_input_custom.lua @@ -66,11 +66,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -162,24 +161,22 @@ function CustomMatchGroupInput.extractMaps(match, opponents) Table.mergeInto(map, MatchGroupInputUtil.getTournamentContext(map, match)) - map.opponents = CustomMatchGroupInput.processPlayerMapData(map, opponents) - map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(opponent, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, opponentIndex = opponentIndex, score = map['score' .. opponentIndex], }, CustomMatchGroupInput.calculateMapScore(map.winner, map.finished)) - return {score = score, status = status} + local players = CustomMatchGroupInput.processPlayerMapData(map, opponent, opponentIndex) + return {score = score, status = status, players = players} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -293,17 +290,16 @@ function CustomMatchGroupInput._getMapName(map, mapsInfo) end ---@param map table ----@param opponents table[] ----@return {players: table[]}[] -function CustomMatchGroupInput.processPlayerMapData(map, opponents) - return Array.map(opponents, function(opponent, opponentIndex) - return {players = CustomMatchGroupInput._participants( - opponent.match2players, - map, - opponentIndex, - opponent.type - )} - end) +---@param opponent table +---@param opponentIndex integer +---@return table[] +function CustomMatchGroupInput.processPlayerMapData(map, opponent, opponentIndex) + return CustomMatchGroupInput._participants( + opponent.match2players, + map, + opponentIndex, + opponent.type + ) end ---@param opponentPlayers table[] diff --git a/components/match2/wikis/apexlegends/match_group_input_custom.lua b/components/match2/wikis/apexlegends/match_group_input_custom.lua index ebc7fd8b67e..38b3b150d59 100644 --- a/components/match2/wikis/apexlegends/match_group_input_custom.lua +++ b/components/match2/wikis/apexlegends/match_group_input_custom.lua @@ -66,13 +66,8 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = - MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput) - and MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED - or nil - match.walkover = nil - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) - + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) local placementOfTeams = CustomMatchGroupInput.calculatePlacementOfTeams(opponents) Array.forEach(opponents, function(opponent, opponentIndex) opponent.placement = placementOfTeams[opponentIndex] @@ -106,21 +101,18 @@ function MatchFunctions.extractMaps(match, opponents, scoreSettings) Table.mergeInto(map, MatchGroupInputUtil.readDate(map.date)) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(matchOpponent) + map.opponents = Array.map(opponents, function(matchOpponent) local opponentMapInput = Json.parseIfString(matchOpponent['m' .. mapIndex]) return MapFunctions.makeMapOpponentDetails(opponentMapInput, scoreSettings) end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.isNotPlayed(winnerInput, finishedInput) - and MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED - or nil - map.walkover = nil - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end - map.extradata = MapFunctions.getExtraData(map, opponentInfo) + map.extradata = MapFunctions.getExtraData(map, map.opponents) table.insert(maps, map) match[key] = nil diff --git a/components/match2/wikis/arenafps/match_group_input_custom.lua b/components/match2/wikis/arenafps/match_group_input_custom.lua index 8164af69e42..bc59b0c2a07 100644 --- a/components/match2/wikis/arenafps/match_group_input_custom.lua +++ b/components/match2/wikis/arenafps/match_group_input_custom.lua @@ -59,11 +59,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -97,7 +96,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -107,11 +106,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/battlerite/match_group_input_custom.lua b/components/match2/wikis/battlerite/match_group_input_custom.lua index 514d19dd162..41dda1ddf80 100644 --- a/components/match2/wikis/battlerite/match_group_input_custom.lua +++ b/components/match2/wikis/battlerite/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -105,7 +104,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -115,11 +114,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/brawlhalla/match_group_input_custom.lua b/components/match2/wikis/brawlhalla/match_group_input_custom.lua index 1f459f2f673..31704b71ce1 100644 --- a/components/match2/wikis/brawlhalla/match_group_input_custom.lua +++ b/components/match2/wikis/brawlhalla/match_group_input_custom.lua @@ -55,11 +55,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -94,25 +93,22 @@ function CustomMatchGroupInput.extractMaps(match, matchOpponents) comment = map.comment, } map.finished = MatchGroupInputUtil.mapIsFinished(map) - map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex) - return CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) - end) - local opponentInfo = Array.map(matchOpponents, function(_, opponentIndex) + map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, opponentIndex = opponentIndex, score = map['score' .. opponentIndex], }, CustomMatchGroupInput.calculateMapScore(map.winner, map.finished)) - return {score = score, status = status} + local players = CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) + return {score = score, status = status, players = players} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -133,10 +129,10 @@ end ---@param map table ---@param opponent table ---@param opponentIndex integer ----@return table? +---@return {char: string?, player: string?}[]? function CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) if opponent.type == Opponent.solo then - return CustomMatchGroupInput._processSoloMapData(opponent.match2players[1], map, opponentIndex) + return {CustomMatchGroupInput._processSoloMapData(opponent.match2players[1], map, opponentIndex)} end return nil end @@ -144,17 +140,13 @@ end ---@param player table ---@param map table ---@param opponentIndex integer ----@return table +---@return {char: string?, player: string?} function CustomMatchGroupInput._processSoloMapData(player, map, opponentIndex) local char = map['char' .. opponentIndex] or '' return { - players = { - { - char = MatchGroupInputUtil.getCharacterName(CharacterStandardization, char), - player = player.name, - } - } + char = MatchGroupInputUtil.getCharacterName(CharacterStandardization, char), + player = player.name, } end diff --git a/components/match2/wikis/brawlstars/match_group_input_custom.lua b/components/match2/wikis/brawlstars/match_group_input_custom.lua index c6501dcaf6f..593ffd22442 100644 --- a/components/match2/wikis/brawlstars/match_group_input_custom.lua +++ b/components/match2/wikis/brawlstars/match_group_input_custom.lua @@ -65,11 +65,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -103,7 +102,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.participants = MapFunctions.getParticipants(map, opponents) map.extradata = MapFunctions.getExtraData(map, #opponents) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -113,13 +112,12 @@ function CustomMatchGroupInput.extractMaps(match, opponents) return {score = score, status = status} end) - map.finished = MatchGroupInputUtil.mapIsFinished(map, opponentInfo) + map.finished = MatchGroupInputUtil.mapIsFinished(map, map.opponents) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/callofduty/match_group_input_custom.lua b/components/match2/wikis/callofduty/match_group_input_custom.lua index 855d9b731d9..3b8144e0d16 100644 --- a/components/match2/wikis/callofduty/match_group_input_custom.lua +++ b/components/match2/wikis/callofduty/match_group_input_custom.lua @@ -55,11 +55,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -91,7 +90,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -101,11 +100,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/clashofclans/match_group_input_custom.lua b/components/match2/wikis/clashofclans/match_group_input_custom.lua index b1b143aa6a8..fc54c1ea081 100644 --- a/components/match2/wikis/clashofclans/match_group_input_custom.lua +++ b/components/match2/wikis/clashofclans/match_group_input_custom.lua @@ -64,11 +64,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -112,7 +111,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -127,11 +126,10 @@ function MatchFunctions.extractMaps(match, opponentCount) } end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/clashroyale/match_group_input_custom.lua b/components/match2/wikis/clashroyale/match_group_input_custom.lua index a73f22b2385..26cb9f2fe4a 100644 --- a/components/match2/wikis/clashroyale/match_group_input_custom.lua +++ b/components/match2/wikis/clashroyale/match_group_input_custom.lua @@ -64,11 +64,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -179,7 +178,7 @@ function MapFunctions.readMap(mapInput, mapIndex, subGroup, opponentCount) } map.finished = MatchGroupInputUtil.mapIsFinished(mapInput) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = mapInput.walkover, winner = mapInput.winner, @@ -189,12 +188,11 @@ function MapFunctions.readMap(mapInput, mapIndex, subGroup, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(mapInput.winner, mapInput.finished, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, mapInput.winner, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(mapInput.winner, mapInput.finished) + map.winner = MatchGroupInputUtil.getWinner(map.status, mapInput.winner, map.opponents) end return map, subGroup diff --git a/components/match2/wikis/clashroyale/match_summary.lua b/components/match2/wikis/clashroyale/match_summary.lua index cc9d5687858..4cb78a5a685 100644 --- a/components/match2/wikis/clashroyale/match_summary.lua +++ b/components/match2/wikis/clashroyale/match_summary.lua @@ -239,7 +239,7 @@ function CustomMatchSummary._calculateSubMatchWinner(subMatch) local subMatchIsFinished = Array.all(subMatch.games, function(game) return Logic.isNotEmpty(game.winner) - or game.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED + or game.resulttype == 'np' end) if not subMatchIsFinished then return end diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 63c1a2bf9cf..5414efa2bf0 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -67,11 +67,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -105,7 +104,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -115,11 +114,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -245,7 +243,7 @@ end function MatchFunctions.getExtraData(match, opponents, finishedInput) return { mapveto = MatchGroupInputUtil.getMapVeto(match), - status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and finishedInput or nil, + status = match.status == MatchGroupInputUtil.MATCH_STATUS.NOT_PLAYED and finishedInput or nil, overturned = Logic.isNotEmpty(match.overturned), featured = MatchFunctions.isFeatured(match, opponents), hidden = Logic.readBool(Variables.varDefault('match_hidden')) diff --git a/components/match2/wikis/criticalops/match_group_input_custom.lua b/components/match2/wikis/criticalops/match_group_input_custom.lua index 2166274e046..442c7114b00 100644 --- a/components/match2/wikis/criticalops/match_group_input_custom.lua +++ b/components/match2/wikis/criticalops/match_group_input_custom.lua @@ -32,9 +32,8 @@ local CustomMatchGroupInput = {} ---@param options table? ---@return table function CustomMatchGroupInput.processMatch(match, options) - match.finished = Logic.nilIfEmpty(match.finished) or match.status - - local finishedInput = match.finished --[[@as string?]] + local finishedInput = Logic.nilIfEmpty(match.finished) or match.status --[[@as string?]] + match.status = nil local winnerInput = match.winner --[[@as string?]] Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date)) @@ -63,11 +62,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -111,7 +109,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -121,11 +119,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -148,7 +145,6 @@ end function MatchFunctions.getExtraData(match) return { mapveto = MatchGroupInputUtil.getMapVeto(match), - status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and match.status or nil, } end diff --git a/components/match2/wikis/crossfire/match_group_input_custom.lua b/components/match2/wikis/crossfire/match_group_input_custom.lua index 591dcee9eb0..5b9dae6bcb7 100644 --- a/components/match2/wikis/crossfire/match_group_input_custom.lua +++ b/components/match2/wikis/crossfire/match_group_input_custom.lua @@ -64,11 +64,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -104,7 +103,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -114,11 +113,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/deadlock/match_group_input_custom.lua b/components/match2/wikis/deadlock/match_group_input_custom.lua index 09b12b575b1..b37b4392a93 100644 --- a/components/match2/wikis/deadlock/match_group_input_custom.lua +++ b/components/match2/wikis/deadlock/match_group_input_custom.lua @@ -57,11 +57,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -91,7 +90,7 @@ function MatchFunctions.extractMaps(match, opponents) map.extradata = MapFunctions.getExtraData(map, #opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -101,11 +100,10 @@ function MatchFunctions.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/dota2/match_group_input_custom.lua b/components/match2/wikis/dota2/match_group_input_custom.lua index 6bb7c98e0f6..01d124cfcc2 100644 --- a/components/match2/wikis/dota2/match_group_input_custom.lua +++ b/components/match2/wikis/dota2/match_group_input_custom.lua @@ -102,11 +102,10 @@ function CustomMatchGroupInput.processMatchWithoutStandalone(MatchParser, match) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -145,7 +144,7 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents) map.extradata = MapFunctions.getExtraData(MatchParser, map, #opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -155,11 +154,10 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/easportsfc/match_group_input_custom.lua b/components/match2/wikis/easportsfc/match_group_input_custom.lua index 94eef48d385..5c561d52974 100644 --- a/components/match2/wikis/easportsfc/match_group_input_custom.lua +++ b/components/match2/wikis/easportsfc/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -104,24 +103,22 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.mode = Opponent.toMode(opponents[1].type, opponents[2].type) map.extradata = CustomMatchGroupInput.getMapExtraData(map, opponents, Logic.readBool(match.hasSubmatches)) - map.opponents = CustomMatchGroupInput.getParticipants(map, opponents) - map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(opponent, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, opponentIndex = opponentIndex, score = map['score' .. opponentIndex], }) - return {score = score, status = status} + local players = CustomMatchGroupInput.getParticipants(map, opponent, opponentIndex) + return {score = score, status = status, players = players} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -195,28 +192,27 @@ function CustomMatchGroupInput._submatchPenaltyScores(map, opponents, hasSubmatc end ---@param map table ----@param opponents MGIParsedOpponent[] +---@param opponent MGIParsedOpponent +---@param opponentIndex integer ---@return {players: table[]}[] -function CustomMatchGroupInput.getParticipants(map, opponents) - return Array.map(opponents, function(opponent, opponentIndex) - local players = Array.mapIndexes(function(playerIndex) - return map['t' .. opponentIndex .. 'p' .. playerIndex] - end) - local participants, _ = MatchGroupInputUtil.parseParticipants( - opponent.match2players, - players, - function(playerIndex) - local data = map['t' .. opponentIndex .. 'p' .. playerIndex] - return data and {name = data} or nil - end, - function(playerIndex, playerIdData, playerInputData) - return { - played = true - } - end - ) - return {players = participants} +function CustomMatchGroupInput.getParticipants(map, opponent, opponentIndex) + local players = Array.mapIndexes(function(playerIndex) + return map['t' .. opponentIndex .. 'p' .. playerIndex] end) + local participants, _ = MatchGroupInputUtil.parseParticipants( + opponent.match2players, + players, + function(playerIndex) + local data = map['t' .. opponentIndex .. 'p' .. playerIndex] + return data and {name = data} or nil + end, + function(playerIndex, playerIdData, playerInputData) + return { + played = true + } + end + ) + return participants end return CustomMatchGroupInput diff --git a/components/match2/wikis/fighters/match_group_input_custom.lua b/components/match2/wikis/fighters/match_group_input_custom.lua index 6ce54e33aa3..42cfc9bd025 100644 --- a/components/match2/wikis/fighters/match_group_input_custom.lua +++ b/components/match2/wikis/fighters/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -92,25 +91,22 @@ function CustomMatchGroupInput.extractMaps(match, matchOpponents) comment = map.comment, } map.finished = MatchGroupInputUtil.mapIsFinished(map) - map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex) - return CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) - end) - local opponentInfo = Array.map(matchOpponents, function(_, opponentIndex) + map.opponents = Array.map(matchOpponents, function(opponent, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, opponentIndex = opponentIndex, score = map['score' .. opponentIndex], }, CustomMatchGroupInput.calculateMapScore(map.winner, map.finished)) - return {score = score, status = status} + local players = CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) + return {score = score, status = status, players = players} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -131,7 +127,7 @@ end ---@param map table ---@param opponent table ---@param opponentIndex integer ----@return table? +---@return table[] function CustomMatchGroupInput.getParticipantsOfOpponent(map, opponent, opponentIndex) if opponent.type == Opponent.literal then return {} @@ -143,7 +139,7 @@ end ---@param map table ---@param opponent table ---@param opponentIndex integer ----@return {players: table[]} +---@return table[] function CustomMatchGroupInput._processPlayerMapData(map, opponent, opponentIndex) local game = Game.toIdentifier{game = Variables.varDefault('tournament_game')} local CharacterStandardizationData = mw.loadData('Module:CharacterStandardization/' .. game) @@ -178,7 +174,7 @@ function CustomMatchGroupInput._processPlayerMapData(map, opponent, opponentInde Array.forEach(unattachedParticipants, function(participant) table.insert(participants, participant) end) - return {players = participants} + return participants end ---@param winnerInput string|integer|nil diff --git a/components/match2/wikis/geoguessr/match_group_input_custom.lua b/components/match2/wikis/geoguessr/match_group_input_custom.lua index 80bf2e35730..fa75043cbb2 100644 --- a/components/match2/wikis/geoguessr/match_group_input_custom.lua +++ b/components/match2/wikis/geoguessr/match_group_input_custom.lua @@ -55,11 +55,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -88,7 +87,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -98,11 +97,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/halo/match_group_input_custom.lua b/components/match2/wikis/halo/match_group_input_custom.lua index 996beff95f6..d31ec39cdbc 100644 --- a/components/match2/wikis/halo/match_group_input_custom.lua +++ b/components/match2/wikis/halo/match_group_input_custom.lua @@ -62,11 +62,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -102,7 +101,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -112,11 +111,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/hearthstone/match_group_input_custom.lua b/components/match2/wikis/hearthstone/match_group_input_custom.lua index 4d13365b951..4fefac2489d 100644 --- a/components/match2/wikis/hearthstone/match_group_input_custom.lua +++ b/components/match2/wikis/hearthstone/match_group_input_custom.lua @@ -63,11 +63,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -111,7 +110,7 @@ function MatchFunctions.extractMaps(match, opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, #opponents), function(opponentIndex) + map.opponents = Array.map(Array.range(1, #opponents), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -121,11 +120,10 @@ function MatchFunctions.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end map.extradata = MapFunctions.getExtradata(map, opponents) diff --git a/components/match2/wikis/heroes/match_group_input_custom.lua b/components/match2/wikis/heroes/match_group_input_custom.lua index 0afedcf85ae..37020902d24 100644 --- a/components/match2/wikis/heroes/match_group_input_custom.lua +++ b/components/match2/wikis/heroes/match_group_input_custom.lua @@ -63,11 +63,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -96,7 +95,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -106,11 +105,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/honorofkings/match_group_input_custom.lua b/components/match2/wikis/honorofkings/match_group_input_custom.lua index 2f6d453fa24..93fe6059de3 100644 --- a/components/match2/wikis/honorofkings/match_group_input_custom.lua +++ b/components/match2/wikis/honorofkings/match_group_input_custom.lua @@ -70,11 +70,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -107,7 +106,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -117,11 +116,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua index 1f4e864e85f..16f0f360fe9 100644 --- a/components/match2/wikis/leagueoflegends/match_group_input_custom.lua +++ b/components/match2/wikis/leagueoflegends/match_group_input_custom.lua @@ -98,11 +98,10 @@ function CustomMatchGroupInput.processMatchWithoutStandalone(MatchParser, match) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -136,7 +135,7 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents) map.extradata = MapFunctions.getExtraData(MatchParser, map, #opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -146,11 +145,10 @@ function MatchFunctions.extractMaps(MatchParser, match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/magic/match_group_input_custom.lua b/components/match2/wikis/magic/match_group_input_custom.lua index 22a32dda4bd..1e05a19669b 100644 --- a/components/match2/wikis/magic/match_group_input_custom.lua +++ b/components/match2/wikis/magic/match_group_input_custom.lua @@ -65,11 +65,10 @@ function CustomMatchGroupInput.processMatch(match) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -103,7 +102,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.mode = Opponent.toMode(opponents[1].type, opponents[2].type) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -113,11 +112,10 @@ function CustomMatchGroupInput.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/mobilelegends/match_group_input_custom.lua b/components/match2/wikis/mobilelegends/match_group_input_custom.lua index 1752c8b6f99..cbe537a6f23 100644 --- a/components/match2/wikis/mobilelegends/match_group_input_custom.lua +++ b/components/match2/wikis/mobilelegends/match_group_input_custom.lua @@ -57,11 +57,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -91,7 +90,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.participants = MapFunctions.getParticipants(map, opponents) map.extradata = MapFunctions.getExtraData(map, #opponents) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -101,13 +100,12 @@ function CustomMatchGroupInput.extractMaps(match, opponents) return {score = score, status = status} end) - map.finished = MatchGroupInputUtil.mapIsFinished(map, opponentInfo) + map.finished = MatchGroupInputUtil.mapIsFinished(map, map.opponents) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/omegastrikers/match_group_input_custom.lua b/components/match2/wikis/omegastrikers/match_group_input_custom.lua index 1de9123b05a..6d800620490 100644 --- a/components/match2/wikis/omegastrikers/match_group_input_custom.lua +++ b/components/match2/wikis/omegastrikers/match_group_input_custom.lua @@ -57,11 +57,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -92,7 +91,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.participants = MapFunctions.getParticipants(map, opponents) map.extradata = MapFunctions.getExtraData(map, #opponents) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -102,13 +101,12 @@ function CustomMatchGroupInput.extractMaps(match, opponents) return {score = score, status = status} end) - map.finished = MatchGroupInputUtil.mapIsFinished(map, opponentInfo) + map.finished = MatchGroupInputUtil.mapIsFinished(map, map.opponents) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/osu/match_group_input_custom.lua b/components/match2/wikis/osu/match_group_input_custom.lua index 67d5a2812f4..7fbc71fcaaa 100644 --- a/components/match2/wikis/osu/match_group_input_custom.lua +++ b/components/match2/wikis/osu/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -100,7 +99,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local percentageScore = (map['score' .. opponentIndex] or ''):match('(%d+)%%') if percentageScore then return {score = map['score' .. opponentIndex], status = MatchGroupInputUtil.STATUS.SCORE} @@ -115,11 +114,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/overwatch/match_group_input_custom.lua b/components/match2/wikis/overwatch/match_group_input_custom.lua index cbc380e2f49..56ca5bb08ba 100644 --- a/components/match2/wikis/overwatch/match_group_input_custom.lua +++ b/components/match2/wikis/overwatch/match_group_input_custom.lua @@ -55,11 +55,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -91,7 +90,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local scoreInput = map['score' .. opponentIndex] if map.mode == 'Push' and scoreInput then scoreInput = scoreInput:gsub('m', '') @@ -105,11 +104,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/pokemon/match_group_input_custom.lua b/components/match2/wikis/pokemon/match_group_input_custom.lua index 1e794b9215b..0ace7cd97a5 100644 --- a/components/match2/wikis/pokemon/match_group_input_custom.lua +++ b/components/match2/wikis/pokemon/match_group_input_custom.lua @@ -66,11 +66,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -99,7 +98,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -109,11 +108,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/rainbowsix/match_group_input_custom.lua b/components/match2/wikis/rainbowsix/match_group_input_custom.lua index c7d4c32abe8..bba9cd4e398 100644 --- a/components/match2/wikis/rainbowsix/match_group_input_custom.lua +++ b/components/match2/wikis/rainbowsix/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -97,7 +96,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -107,11 +106,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/rocketleague/match_group_input_custom.lua b/components/match2/wikis/rocketleague/match_group_input_custom.lua index 6be6f4fb7c1..9831835d49d 100644 --- a/components/match2/wikis/rocketleague/match_group_input_custom.lua +++ b/components/match2/wikis/rocketleague/match_group_input_custom.lua @@ -63,11 +63,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -100,7 +99,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.vod = map.vod or String.nilIfEmpty(match['vodgame' .. mapIndex]) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -110,16 +109,15 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if Logic.readBoolOrNil(finishedInput) == nil and Logic.isNotEmpty(map.scores) then map.finished = true end if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/sideswipe/match_group_input_custom.lua b/components/match2/wikis/sideswipe/match_group_input_custom.lua index 58a88cd14a3..2025db63d2d 100644 --- a/components/match2/wikis/sideswipe/match_group_input_custom.lua +++ b/components/match2/wikis/sideswipe/match_group_input_custom.lua @@ -51,11 +51,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -87,7 +86,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -97,11 +96,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/smite/match_group_input_custom.lua b/components/match2/wikis/smite/match_group_input_custom.lua index 3c5e312b75e..a9bee85a80f 100644 --- a/components/match2/wikis/smite/match_group_input_custom.lua +++ b/components/match2/wikis/smite/match_group_input_custom.lua @@ -66,11 +66,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -156,7 +155,7 @@ function MapFunctions.readMap(map, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -166,11 +165,10 @@ function MapFunctions.readMap(map, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end return map diff --git a/components/match2/wikis/splatoon/match_group_input_custom.lua b/components/match2/wikis/splatoon/match_group_input_custom.lua index 5e0bde734a4..a93647a336f 100644 --- a/components/match2/wikis/splatoon/match_group_input_custom.lua +++ b/components/match2/wikis/splatoon/match_group_input_custom.lua @@ -56,11 +56,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -90,7 +89,7 @@ function MatchFunctions.extractMaps(match, opponents) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local scoreInput = map['score' .. opponentIndex] if map.maptype == 'Turf War' and scoreInput then scoreInput = scoreInput:gsub('%%', '') @@ -104,11 +103,10 @@ function MatchFunctions.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/splitgate/match_group_input_custom.lua b/components/match2/wikis/splitgate/match_group_input_custom.lua index 079c3857943..5b69c933ee9 100644 --- a/components/match2/wikis/splitgate/match_group_input_custom.lua +++ b/components/match2/wikis/splitgate/match_group_input_custom.lua @@ -59,11 +59,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -99,7 +98,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -109,11 +108,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/stormgate/match_group_input_custom.lua b/components/match2/wikis/stormgate/match_group_input_custom.lua index 533a9ca99e1..ffdc3521556 100644 --- a/components/match2/wikis/stormgate/match_group_input_custom.lua +++ b/components/match2/wikis/stormgate/match_group_input_custom.lua @@ -93,11 +93,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -207,6 +206,7 @@ end ---@param numberOfGames integer ---@return table function MatchFunctions.getExtraData(match, numberOfGames) + ---@type table local extradata = { casters = MatchGroupInputUtil.readCasters(match, {noSort = true}), } @@ -247,7 +247,7 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) } map.finished = MatchGroupInputUtil.mapIsFinished(mapInput) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = mapInput.walkover, winner = mapInput.winner, @@ -257,12 +257,11 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(mapInput.winner, mapInput.finished, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, mapInput.winner, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(mapInput.winner, mapInput.finished) + map.winner = MatchGroupInputUtil.getWinner(map.status, mapInput.winner, map.opponents) end return map, subGroup diff --git a/components/match2/wikis/teamfortress/match_group_input_custom.lua b/components/match2/wikis/teamfortress/match_group_input_custom.lua index b9186bfc00c..0b8b4350767 100644 --- a/components/match2/wikis/teamfortress/match_group_input_custom.lua +++ b/components/match2/wikis/teamfortress/match_group_input_custom.lua @@ -56,11 +56,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -89,7 +88,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -99,11 +98,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -129,7 +127,7 @@ end ---@param games table[] ---@return table function MatchFunctions.getLinks(match, games) - ---@type table + ---@type table local links = MatchGroupInputUtil.getLinks(match) links.logstf = {} links.logstfgold = {} diff --git a/components/match2/wikis/tetris/match_group_input_custom.lua b/components/match2/wikis/tetris/match_group_input_custom.lua index a3d7300a484..28d244c722d 100644 --- a/components/match2/wikis/tetris/match_group_input_custom.lua +++ b/components/match2/wikis/tetris/match_group_input_custom.lua @@ -65,11 +65,10 @@ function CustomMatchGroupInput.processMatch(match) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -105,7 +104,7 @@ function CustomMatchGroupInput.extractMaps(match, opponents) map.mode = Opponent.toMode(opponents[1].type, opponents[2].type) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(_, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -115,11 +114,10 @@ function CustomMatchGroupInput.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/tft/match_group_input_custom.lua b/components/match2/wikis/tft/match_group_input_custom.lua index 2df450c6674..cfe26471486 100644 --- a/components/match2/wikis/tft/match_group_input_custom.lua +++ b/components/match2/wikis/tft/match_group_input_custom.lua @@ -53,11 +53,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -113,7 +112,7 @@ function MatchFunctions.extractMaps(match, opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, #opponents), function(opponentIndex) + map.opponents = Array.map(Array.range(1, #opponents), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -123,11 +122,10 @@ function MatchFunctions.extractMaps(match, opponents) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end map.extradata = MapFunctions.getExtradata(map, opponents) diff --git a/components/match2/wikis/trackmania/match_group_input_custom.lua b/components/match2/wikis/trackmania/match_group_input_custom.lua index 2caf2f254f2..670e81edbe0 100644 --- a/components/match2/wikis/trackmania/match_group_input_custom.lua +++ b/components/match2/wikis/trackmania/match_group_input_custom.lua @@ -54,11 +54,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -90,7 +89,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -100,11 +99,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/valorant/match_group_input_custom.lua b/components/match2/wikis/valorant/match_group_input_custom.lua index 8dce08f1f8f..5d45f6e5423 100644 --- a/components/match2/wikis/valorant/match_group_input_custom.lua +++ b/components/match2/wikis/valorant/match_group_input_custom.lua @@ -59,11 +59,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -90,25 +89,24 @@ function CustomMatchGroupInput.extractMaps(match, opponents) local finishedInput = map.finished --[[@as string?]] local winnerInput = map.winner --[[@as string?]] - map.opponents = MapFunctions.getParticipants(map, opponents) - map.extradata = MapFunctions.getExtraData(map, map.opponents) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(opponents, function(_, opponentIndex) + map.opponents = Array.map(opponents, function(opponent, opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, opponentIndex = opponentIndex, score = map['score' .. opponentIndex], }, MapFunctions.calculateMapScore(map)) - return {score = score, status = status} + local players = MapFunctions.getParticipants(map, opponent, opponentIndex) + return {score = score, status = status, players = players} end) + map.extradata = MapFunctions.getExtraData(map, map.opponents) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -182,41 +180,40 @@ function MapFunctions.getExtraData(map, participants) end ---@param map table ----@param opponents MGIParsedOpponent[] +---@param opponent MGIParsedOpponent +---@param opponentIndex integer ---@return {players: table[]}[] -function MapFunctions.getParticipants(map, opponents) +function MapFunctions.getParticipants(map, opponent, opponentIndex) local getCharacterName = FnUtil.curry(MatchGroupInputUtil.getCharacterName, AgentNames) - return Array.map(opponents, function(opponent, opponentIndex) - local players = Array.mapIndexes(function(playerIndex) - return opponent.match2players[playerIndex] or - (map['t' .. opponentIndex .. 'p' .. playerIndex] and {}) or - nil - end) - local participants, unattachedParticipants = MatchGroupInputUtil.parseParticipants( - opponent.match2players, - players, - function(playerIndex) - local data = Json.parseIfString(map['t' .. opponentIndex .. 'p' .. playerIndex]) - return data and {name = data.player} or nil - end, - function(playerIndex, playerIdData, playerInputData) - local stats = Json.parseIfString(map['t'.. opponentIndex .. 'p' .. playerIndex]) or {} - return { - kills = stats.kills, - deaths = stats.deaths, - assists = stats.assists, - acs = stats.acs, - player = playerIdData.name or playerInputData.name, - agent = getCharacterName(stats.agent), - } - end - ) - Array.forEach(unattachedParticipants, function(participant) - table.insert(participants, participant) - end) - return {players = participants} + local players = Array.mapIndexes(function(playerIndex) + return opponent.match2players[playerIndex] or + (map['t' .. opponentIndex .. 'p' .. playerIndex] and {}) or + nil + end) + local participants, unattachedParticipants = MatchGroupInputUtil.parseParticipants( + opponent.match2players, + players, + function(playerIndex) + local data = Json.parseIfString(map['t' .. opponentIndex .. 'p' .. playerIndex]) + return data and {name = data.player} or nil + end, + function(playerIndex, playerIdData, playerInputData) + local stats = Json.parseIfString(map['t'.. opponentIndex .. 'p' .. playerIndex]) or {} + return { + kills = stats.kills, + deaths = stats.deaths, + assists = stats.assists, + acs = stats.acs, + player = playerIdData.name or playerInputData.name, + agent = getCharacterName(stats.agent), + } + end + ) + Array.forEach(unattachedParticipants, function(participant) + table.insert(participants, participant) end) + return participants end ---@param map table diff --git a/components/match2/wikis/warcraft/match_group_input_custom.lua b/components/match2/wikis/warcraft/match_group_input_custom.lua index d519ad1d3de..f5a76c6d073 100644 --- a/components/match2/wikis/warcraft/match_group_input_custom.lua +++ b/components/match2/wikis/warcraft/match_group_input_custom.lua @@ -99,11 +99,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -273,7 +272,7 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) } map.finished = MatchGroupInputUtil.mapIsFinished(mapInput) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = mapInput.walkover, winner = mapInput.winner, @@ -283,12 +282,11 @@ function MapFunctions.readMap(mapInput, subGroup, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(mapInput.winner, mapInput.finished, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, mapInput.winner, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(mapInput.winner, mapInput.finished) + map.winner = MatchGroupInputUtil.getWinner(map.status, mapInput.winner, map.opponents) end return map, subGroup diff --git a/components/match2/wikis/wildrift/match_group_input_custom.lua b/components/match2/wikis/wildrift/match_group_input_custom.lua index 169bb8b69ba..c7952824fec 100644 --- a/components/match2/wikis/wildrift/match_group_input_custom.lua +++ b/components/match2/wikis/wildrift/match_group_input_custom.lua @@ -68,11 +68,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -101,7 +100,7 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -111,11 +110,10 @@ function CustomMatchGroupInput.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/worldoftanks/match_group_input_custom.lua b/components/match2/wikis/worldoftanks/match_group_input_custom.lua index d7f65452136..13e6fc96e8a 100644 --- a/components/match2/wikis/worldoftanks/match_group_input_custom.lua +++ b/components/match2/wikis/worldoftanks/match_group_input_custom.lua @@ -60,11 +60,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -100,7 +99,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -110,11 +109,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) diff --git a/components/match2/wikis/zula/match_group_input_custom.lua b/components/match2/wikis/zula/match_group_input_custom.lua index 340a8b109b4..e1486a7b3a8 100644 --- a/components/match2/wikis/zula/match_group_input_custom.lua +++ b/components/match2/wikis/zula/match_group_input_custom.lua @@ -29,9 +29,8 @@ local CustomMatchGroupInput = {} ---@param options table? ---@return table function CustomMatchGroupInput.processMatch(match, options) - match.finished = Logic.nilIfEmpty(match.finished) or match.status - - local finishedInput = match.finished --[[@as string?]] + local finishedInput = Logic.nilIfEmpty(match.finished) or match.status --[[@as string?]] + match.status = nil local winnerInput = match.winner --[[@as string?]] Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date)) @@ -60,11 +59,10 @@ function CustomMatchGroupInput.processMatch(match, options) match.finished = MatchGroupInputUtil.matchIsFinished(match, opponents) if match.finished then - match.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponents) - match.walkover = MatchGroupInputUtil.getWalkover(match.resulttype, opponents) - match.winner = MatchGroupInputUtil.getWinner(match.resulttype, winnerInput, opponents) + match.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + match.winner = MatchGroupInputUtil.getWinner(match.status, winnerInput, opponents) Array.forEach(opponents, function(opponent, opponentIndex) - opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex) + opponent.placement = MatchGroupInputUtil.placementFromWinner(match.status, match.winner, opponentIndex) end) end @@ -97,7 +95,7 @@ function MatchFunctions.extractMaps(match, opponentCount) map.extradata = MapFunctions.getExtraData(map, opponentCount) map.finished = MatchGroupInputUtil.mapIsFinished(map) - local opponentInfo = Array.map(Array.range(1, opponentCount), function(opponentIndex) + map.opponents = Array.map(Array.range(1, opponentCount), function(opponentIndex) local score, status = MatchGroupInputUtil.computeOpponentScore({ walkover = map.walkover, winner = map.winner, @@ -107,11 +105,10 @@ function MatchFunctions.extractMaps(match, opponentCount) return {score = score, status = status} end) - map.scores = Array.map(opponentInfo, Operator.property('score')) + map.scores = Array.map(map.opponents, Operator.property('score')) if map.finished then - map.resulttype = MatchGroupInputUtil.getResultType(winnerInput, finishedInput, opponentInfo) - map.walkover = MatchGroupInputUtil.getWalkover(map.resulttype, opponentInfo) - map.winner = MatchGroupInputUtil.getWinner(map.resulttype, winnerInput, opponentInfo) + map.status = MatchGroupInputUtil.getMatchStatus(winnerInput, finishedInput) + map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents) end table.insert(maps, map) @@ -142,7 +139,6 @@ end ---@return table function MatchFunctions.getExtraData(match) return { - status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and match.status or nil, mapveto = MatchGroupInputUtil.getMapVeto(match), } end