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 1 commit
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
16 changes: 11 additions & 5 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,8 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
local winnerInput = map.winner --[[@as string?]]

local dateToUse = map.date or match.date
Table.mergeInto(map, MatchGroupInputUtil.readDate(dateToUse))
local dateProps = MatchGroupInputUtil.readDate(dateToUse)
Table.mergeInto(map, dateProps)

if Parser.ADD_SUB_GROUP then
subGroup = tonumber(map.subgroup) or (subGroup + 1)
Expand All @@ -1244,7 +1245,7 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
end

if Parser.getGame then
map.game = Parser.getGame(match, map)
map.game = Parser.getGame(math, map)
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved
end

map.opponents = Array.map(opponents, function(opponent, opponentIndex)
Expand Down Expand Up @@ -1283,9 +1284,11 @@ function MatchGroupInputUtil.standardProcessMaps(match, opponents, Parser)
map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents)
end

dateProps.date = nil
map.extradata = Table.merge(
{displayname = map.mapDisplayName},
Parser.getExtraData and Parser.getExtraData(match, map, opponents) or nil
Parser.getExtraData and Parser.getExtraData(match, map, opponents) or nil,
dateProps
)

table.insert(maps, map)
Expand Down Expand Up @@ -1414,7 +1417,8 @@ function MatchGroupInputUtil.standardProcessFfaMaps(match, opponents, scoreSetti
local winnerInput = map.winner --[[@as string?]]

local dateToUse = map.date or match.date
Table.mergeInto(map, MatchGroupInputUtil.readDate(dateToUse))
local dateProps = MatchGroupInputUtil.readDate(dateToUse)
Table.mergeInto(map, dateProps)
map.finished = MatchGroupInputUtil.mapIsFinished(map)

map.opponents = Array.map(opponents, function(matchOpponent)
Expand All @@ -1432,7 +1436,9 @@ function MatchGroupInputUtil.standardProcessFfaMaps(match, opponents, scoreSetti
map.winner = MatchGroupInputUtil.getWinner(map.status, winnerInput, map.opponents)
end

map.extradata = Parser.getExtraData and Parser.getExtraData(match, map, opponents) or nil
map.extradata = Parser.getExtraData and Parser.getExtraData(match, map, opponents) or {}
dateProps.date = nil -- don't need this in extradata
Table.mergeInto(map.extradata, dateProps)
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved
hjpalpha marked this conversation as resolved.
Show resolved Hide resolved

table.insert(maps, map)
match[key] = nil
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,10 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores)
}
}

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

if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then
map.finished = true
Expand Down
13 changes: 7 additions & 6 deletions components/match2/wikis/warcraft/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ function FfaMatchFunctions.extractMaps(match, opponents)
local hasScores = Logic.readBool(match.hasscore)
local maps = {}
for mapKey, mapInput in Table.iter.pairsByPrefix(match, 'map', {requireIndex = true}) do
local map = FfaMapFunctions.readMap(mapInput, #opponents, hasScores)
local map = FfaMapFunctions.readMap(match, mapInput, #opponents, hasScores)

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

---@param match table
---@param mapInput table
---@param opponentCount integer
---@param hasScores boolean
---@return table
function FfaMapFunctions.readMap(mapInput, opponentCount, hasScores)
function FfaMapFunctions.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 @@ -551,10 +552,10 @@ function FfaMapFunctions.readMap(mapInput, opponentCount, hasScores)
}
}

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

if MatchGroupInputUtil.isNotPlayed(mapInput.winner, mapInput.finished) then
map.finished = true
Expand Down
Loading