Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(match2): store further date props in game extradata #5338

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/match2/commons/match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ function Match._prepareGameRecordForStore(matchRecord, gameRecord)

gameRecord.parent = matchRecord.parent
gameRecord.tournament = matchRecord.tournament
gameRecord.extradata = Match._addCommonGameExtradata(gameRecord)
if not gameRecord.participants then
gameRecord.participants = {}
for opponentId, opponent in ipairs(gameRecord.opponents or {}) do
Expand All @@ -387,6 +388,20 @@ function Match._prepareGameRecordForStore(matchRecord, gameRecord)
Match.clampFields(gameRecord, Match.gameFields)
end

---@param game table
---@return table
function Match._addCommonGameExtradata(game)
local commonExtradata = {
comment = game.comment,
dateexact = game.dateexact,
timestamp = tonumber(game.timestamp),
timezoneid = game.timezoneId,
timezoneoffset = game.timezoneOffset,
}

return Table.merge(commonExtradata, game.extradata or {})
end

---@param playerRecord table
function Match._preparePlayerRecordForStore(playerRecord)
playerRecord.extradata = playerRecord.extradata or {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ end
---@return table
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
comment = map.comment,
header = map.header,
server = map.server,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function MatchFunctions.extractMaps(match, opponents)
local hasScores = not Logic.readBool(match.noscore)
local maps = {}
for mapKey, mapInput in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
local map = MapFunctions.readMap(mapInput, #opponents, hasScores)
local map = MapFunctions.readMap(match, mapInput, #opponents, hasScores)

Array.forEach(map.opponents, function(opponent, opponentIndex)
opponent.players = BaseMapFunctions.getPlayersOfMapOpponent(map, opponents[opponentIndex], opponentIndex)
Expand All @@ -171,11 +171,12 @@ function MatchFunctions.extractMaps(match, opponents)
return maps
end

---@param match table
---@param mapInput table
---@param opponentCount integer
---@param hasScores boolean
---@return table
function MapFunctions.readMap(mapInput, opponentCount, hasScores)
function MapFunctions.readMap(match, mapInput, opponentCount, hasScores)
local mapName = mapInput.map
if mapName and mapName:upper() ~= TBD then
mapName = mw.ext.TeamLiquidIntegration.resolve_redirect(mapInput.map)
Expand All @@ -194,10 +195,7 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores)
}
}

if mapInput.date then
Table.mergeInto(map, MatchGroupInputUtil.readDate(mapInput.date))
map.extradata.dateexact = map.dateexact
end
Table.mergeInto(map, MatchGroupInputUtil.readDate(mapInput.date or match.date))

if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then
map.finished = true
Expand Down
12 changes: 0 additions & 12 deletions components/match2/wikis/ageofempires/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ end
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
mapmode = Table.extract(map, 'mode'),
}
end
Expand Down Expand Up @@ -355,15 +354,4 @@ function FfaMapFunctions.getPlayersOfMapOpponent(map, opponent, opponentMapInput
)
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
21 changes: 0 additions & 21 deletions components/match2/wikis/apexlegends/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ function MatchFunctions.getExtraData(match, games, opponents)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

---@param map table
---@return fun(opponentIndex: integer): integer?
function MapFunctions.calculateMapScore(map)
Expand Down Expand Up @@ -125,15 +115,4 @@ function FfaMatchFunctions.getExtraData(match, games, opponents, settings)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
21 changes: 0 additions & 21 deletions components/match2/wikis/arenafps/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ function MatchFunctions.calculateMatchScore(maps)
end
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

--- FFA Match

---@param match table
Expand Down Expand Up @@ -115,15 +105,4 @@ function FfaMatchFunctions.getExtraData(match, games, opponents, settings)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
10 changes: 0 additions & 10 deletions components/match2/wikis/artifact/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ function MapFunctions.getPlayersOfMapOpponent(map, opponent, opponentIndex)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

---@param map table
---@return fun(opponentIndex: integer): integer?
function MapFunctions.calculateMapScore(map)
Expand Down
11 changes: 0 additions & 11 deletions components/match2/wikis/autochess/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,4 @@ function FfaMatchFunctions.getExtraData(match, games, opponents, settings)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
14 changes: 0 additions & 14 deletions components/match2/wikis/battalion/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,4 @@ function MatchFunctions.calculateMatchScore(maps)
end
end

--
-- map related functions
--

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

return CustomMatchGroupInput
14 changes: 0 additions & 14 deletions components/match2/wikis/battlerite/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,4 @@ function MatchFunctions.getExtraData(match, games, opponents)
}
end

--
-- map related functions
--

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

return CustomMatchGroupInput
10 changes: 0 additions & 10 deletions components/match2/wikis/brawlhalla/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,4 @@ function MapFunctions.getMapName(map, mapIndex, match)
return map.map
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

return CustomMatchGroupInput
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ end
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
bestof = map.bestof,
comment = map.comment,
maptype = map.maptype,
firstpick = FIRST_PICK_CONVERSION[string.lower(map.firstpick or '')]
}
Expand Down
21 changes: 0 additions & 21 deletions components/match2/wikis/callofduty/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ function MatchFunctions.getExtraData(match, games, opponents)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

--- FFA Match

---@param match table
Expand Down Expand Up @@ -118,15 +108,4 @@ function FfaMatchFunctions.getExtraData(match, games, opponents, settings)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ end
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
times = MapFunctions.readTimes(map),
percentages = MapFunctions.readPercentages(map),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ end
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
comment = map.comment,
}

return Table.merge(extradata, MapFunctions.getCardsExtradata(map.opponents))
return MapFunctions.getCardsExtradata(map.opponents)
end

--- additionally store cards info in extradata so we can condition on them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,7 @@ end
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
local extradata = {
comment = map.comment,
}

Table.mergeInto(extradata, MapFunctions._getHalfScores(map))

return extradata
return MapFunctions._getHalfScores(map)
end

---@param map table
Expand Down Expand Up @@ -284,15 +278,4 @@ function FfaMatchFunctions.getExtraData(match, games, opponents, settings)
}
end

---@param match table
---@param map table
---@param opponents table[]
---@return table
function FfaMapFunctions.getExtraData(match, map, opponents)
return {
dateexact = map.dateexact,
comment = map.comment,
}
end

return CustomMatchGroupInput
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ local Logic = require('Module:Logic')
local Lua = require('Module:Lua')
local MathUtil = require('Module:MathUtil')
local Operator = require('Module:Operator')
local Table = require('Module:Table')

local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')

Expand Down Expand Up @@ -77,9 +76,7 @@ end
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
local extradata = MapFunctions.getSideData(map)

return Table.merge(extradata, {comment = map.comment})
return MapFunctions.getSideData(map)
end

---@param map table
Expand Down
14 changes: 0 additions & 14 deletions components/match2/wikis/crossfire/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,4 @@ function MatchFunctions.getExtraData(match, games, opponents)
}
end

--
-- map related functions
--

---@param match table
---@param map table
---@param opponents table[]
---@return table
function MapFunctions.getExtraData(match, map, opponents)
return {
comment = map.comment,
}
end

return CustomMatchGroupInput
Loading
Loading