Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
hjpalpha committed Dec 23, 2024
1 parent c9d81b2 commit e1e3c94
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion components/match2/commons/match_group_display_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions components/match2/wikis/counterstrike/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 = {}, {}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions components/match2/wikis/criticalops/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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 = {}, {}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions components/match2/wikis/starcraft/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/warcraft/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion components/match2/wikis/zula/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e1e3c94

Please sign in to comment.