diff --git a/components/match2/commons/match_group_display_helper.lua b/components/match2/commons/match_group_display_helper.lua index 82bb053259..ac259f427b 100644 --- a/components/match2/commons/match_group_display_helper.lua +++ b/components/match2/commons/match_group_display_helper.lua @@ -178,7 +178,7 @@ function DisplayHelper.Map(game, config) end ---@param opponent table ----@param status string? +---@param gameStatus string? ---@return string function DisplayHelper.MapScore(opponent, gameStatus) if gameStatus == 'notplayed' then diff --git a/components/match2/wikis/counterstrike/match_legacy.lua b/components/match2/wikis/counterstrike/match_legacy.lua index 66a6e24046..34067dac34 100644 --- a/components/match2/wikis/counterstrike/match_legacy.lua +++ b/components/match2/wikis/counterstrike/match_legacy.lua @@ -6,9 +6,11 @@ -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- +local Array = require('Module:Array') local Json = require('Module:Json') local Lua = require('Module:Lua') local Logic = require('Module:Logic') +local Operator = require('Module:Operator') local String = require('Module:StringUtils') local Table = require('Module:Table') local TextSanitizer = require('Module:TextSanitizer') @@ -179,6 +181,8 @@ function MatchLegacy.storeGames(match, match2) local game = Table.deepCopy(game2) -- Extradata local extradata = Json.parseIfString(game2.extradata) + local opponents = Json.parseIfString(game2.opponents) or {} + local scores = Array.map(opponents, Operator.property('score')) game.extradata = {} local opponent1scores, opponent2scores = {}, {} @@ -207,14 +211,13 @@ function MatchLegacy.storeGames(match, match2) game.opponent1flag = match.opponent1flag game.opponent2flag = match.opponent2flag game.date = match.date - local scores = game2.scores or {} if type(scores) == 'string' then scores = Json.parse(scores) end game.opponent1score = scores[1] or 0 game.opponent2score = scores[2] or 0 - local walkover = MatchOpponentHelper.calculateWalkoverType(game2.opponents) + local walkover = MatchOpponentHelper.calculateWalkoverType(opponents) if walkover == 'FF' or walkover == 'DQ' then game.walkover = 1 end diff --git a/components/match2/wikis/criticalops/match_legacy.lua b/components/match2/wikis/criticalops/match_legacy.lua index 6067bbded8..bdb5c25d04 100644 --- a/components/match2/wikis/criticalops/match_legacy.lua +++ b/components/match2/wikis/criticalops/match_legacy.lua @@ -6,9 +6,11 @@ -- Please see https://github.com/Liquipedia/Lua-Modules to contribute -- +local Array = require('Module:Array') local Json = require('Module:Json') local Lua = require('Module:Lua') local Logic = require('Module:Logic') +local Operator = require('Module:Operator') local String = require('Module:StringUtils') local Table = require('Module:Table') local TextSanitizer = require('Module:TextSanitizer') @@ -174,6 +176,8 @@ function MatchLegacy.storeGames(match, match2) local game = Table.deepCopy(game2) -- Extradata local extradata = Json.parseIfString(game2.extradata) + local opponents = Json.parseIfString(game2.opponents) or {} + local scores = Array.map(opponents, Operator.property('score')) game.extradata = {} local opponent1scores, opponent2scores = {}, {} @@ -202,14 +206,13 @@ function MatchLegacy.storeGames(match, match2) game.opponent1flag = match.opponent1flag game.opponent2flag = match.opponent2flag game.date = match.date - local scores = game2.scores or {} if type(scores) == 'string' then scores = Json.parse(scores) end game.opponent1score = scores[1] or 0 game.opponent2score = scores[2] or 0 - local walkover = MatchOpponentHelper.calculateWalkoverType(game2.opponents) + local walkover = MatchOpponentHelper.calculateWalkoverType(opponents) if walkover == 'FF' or walkover == 'DQ' then game.walkover = 1 end diff --git a/components/match2/wikis/starcraft/match_legacy.lua b/components/match2/wikis/starcraft/match_legacy.lua index ff7b1a0b3d..31889ff686 100644 --- a/components/match2/wikis/starcraft/match_legacy.lua +++ b/components/match2/wikis/starcraft/match_legacy.lua @@ -12,6 +12,7 @@ local Array = require('Module:Array') local Json = require('Module:Json') local Logic = require('Module:Logic') local Lua = require('Module:Lua') +local Operator = require('Module:Operator') local String = require('Module:StringUtils') local Table = require('Module:Table') local Template = require('Module:Template') @@ -39,19 +40,19 @@ function MatchLegacy._storeGames(match, match2) local games = '' for gameIndex, game in ipairs(match2.match2games or {}) do game.extradata = Json.parseIfString(game.extradata or '{}') or game.extradata + local opponents = Json.parseIfString(game.opponents) or {} + local scores = Array.map(opponents, Operator.property('score')) if game.mode == '1v1' then game.opponent1 = game.extradata.opponent1 game.opponent2 = game.extradata.opponent2 game.date = match.date - local scores = Json.parseIfString(game.scores or '{}') or {} game.opponent1score = scores[1] or 0 game.opponent2score = scores[2] or 0 game.extradata.winnerrace = game.extradata.winnerfaction game.extradata.loserrace = game.extradata.loserfaction - local opponents = Json.parseIfString(game.opponents) or {} Array.forEach(opponents, function(opponent, opponentIndex) Array.forEach(opponent.players or {}, function(player, playerIndex) if Logic.isDeepEmpty(player) then return end @@ -78,12 +79,10 @@ function MatchLegacy._storeGames(match, match2) submatch.opponent1 = game.extradata.opponent1 submatch.opponent2 = game.extradata.opponent2 - local scores = Json.parseIfString(game.scores or '{}') or {} submatch.opponent1score = scores[1] or 0 submatch.opponent2score = scores[2] or 0 submatch.extradata = {} - local opponents = Json.parseIfString(game.opponents) or {} Array.forEach(opponents, function(opponent, opponentIndex) Array.forEach(opponent.players or {}, function(player, playerIndex) if Logic.isDeepEmpty(player) then return end @@ -95,7 +94,7 @@ function MatchLegacy._storeGames(match, match2) end) submatch.winner = game.winner or '' - local walkover = MatchOpponentHelper.calculateWalkoverType(game.opponents) + local walkover = MatchOpponentHelper.calculateWalkoverType(opponents) submatch.walkover = (walkover or ''):lower() submatch.finished = match2.finished or '0' submatch.mode = '1v1' diff --git a/components/match2/wikis/warcraft/match_legacy.lua b/components/match2/wikis/warcraft/match_legacy.lua index 175989abb2..320f409869 100644 --- a/components/match2/wikis/warcraft/match_legacy.lua +++ b/components/match2/wikis/warcraft/match_legacy.lua @@ -267,7 +267,7 @@ function MatchLegacy._storeGame(game2, gameIndex, match) game.resulttype = nil game.walkover = nil - local walkover = MatchOpponentHelper.calculateWalkoverType(game2.opponents) + local walkover = MatchOpponentHelper.calculateWalkoverType(opponents) if walkover then game.resulttype = walkover if walkover == UNKNOWNREASON_DEFAULT_LOSS then diff --git a/components/match2/wikis/zula/match_legacy.lua b/components/match2/wikis/zula/match_legacy.lua index 933fcd7d67..dceebcce77 100644 --- a/components/match2/wikis/zula/match_legacy.lua +++ b/components/match2/wikis/zula/match_legacy.lua @@ -209,7 +209,8 @@ function MatchLegacy.storeGames(match, match2) game.opponent1score = scores[1] or 0 game.opponent2score = scores[2] or 0 - local walkover = MatchOpponentHelper.calculateWalkoverType(game2.opponents) + local opponents = Json.parseIfString(game2.opponents) or {} + local walkover = MatchOpponentHelper.calculateWalkoverType(opponents) if walkover == 'FF' or walkover == 'DQ' then game.walkover = 1 end