Skip to content

Commit

Permalink
feat(match2): replace walkover and resulttype with status on ma…
Browse files Browse the repository at this point in the history
…tch level on non-standardized wikis
  • Loading branch information
Rathoz committed Nov 6, 2024
1 parent 765b6ff commit 87fa198
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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
Expand All @@ -79,10 +79,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)
Expand Down Expand Up @@ -229,7 +228,7 @@ function MapFunctions.readMap(mapInput, opponentCount, hasScores)
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.winner = StarcraftFfaMatchGroupInput._getWinner(opponentsInfo, mapInput.winner)
end

Array.forEach(opponentsInfo, function(opponentInfo, opponentIndex)
Expand Down Expand Up @@ -336,12 +335,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -245,7 +244,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'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions components/match2/wikis/warcraft/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 87fa198

Please sign in to comment.