Skip to content

Commit

Permalink
Update match_group_input_custom.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Hesketh2 authored Nov 6, 2024
1 parent efcb309 commit 05c9103
Showing 1 changed file with 3 additions and 45 deletions.
48 changes: 3 additions & 45 deletions components/match2/wikis/goals/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,15 @@ local MatchGroupInputUtil = Lua.import('Module:MatchGroup/Input/Util')
local Streams = Lua.import('Module:Links/Stream')

local CustomMatchGroupInput = {}
CustomMatchGroupInput.DEFAULT_MODE = 'solo'
CustomMatchGroupInput.getBestOf = MatchGroupInputUtil.getBestOf

-- called from Module:MatchGroup
---@param match table
---@param options table?
---@return table
function CustomMatchGroupInput.processMatch(match, options)
local winnerInput = match.winner --[[@as string?]]
local finishedInput = match.finished --[[@as string?]]

Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date))

local opponents = Array.mapIndexes(function(opponentIndex)
return MatchGroupInputUtil.readOpponent(match, opponentIndex, {})
end)

local games = CustomMatchGroupInput.extractMaps(match, opponents)

local autoScoreFunction = MatchGroupInputUtil.canUseAutoScore(match, games)
and CustomMatchGroupInput.calculateMatchScore(games)
or nil

Array.forEach(opponents, function(opponent, opponentIndex)
opponent.score, opponent.status = MatchGroupInputUtil.computeOpponentScore({
walkover = match.walkover,
winner = winnerInput,
opponentIndex = opponentIndex,
score = opponent.score,
}, autoScoreFunction)
end)

match.bestof = MatchGroupInputUtil.getBestOf(match.bestof, games)
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)
Array.forEach(opponents, function(opponent, opponentIndex)
opponent.placement = MatchGroupInputUtil.placementFromWinner(match.resulttype, match.winner, opponentIndex)
end)
end

match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'solo'))
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

match.stream = Streams.processStreams(match)

match.games = games
match.opponents = opponents

return match
return MatchGroupInputUtil.standardProcessMatch(match, CustomMatchGroupInput)
end

---@param match table
Expand Down

0 comments on commit 05c9103

Please sign in to comment.