Skip to content

Commit

Permalink
Use bestoff to determine playall
Browse files Browse the repository at this point in the history
  • Loading branch information
fregerson committed Dec 16, 2024
1 parent 8b5e784 commit ca52779
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,12 @@ function MatchGroupInputUtil.matchIsFinished(match, opponents)
return true
end

local playall = Logic.readBoolOrNil(match.finished)
local playall = Logic.readBoolOrNil(match.playall)
local bestof = match.bestof
if playall then
return MatchGroupInputUtil.allHasBeenPlayed(match.games)
return MatchGroupInputUtil.allHasBeenPlayed(bestof, opponents)
end

local bestof = match.bestof
if not bestof then
return false
end
Expand Down Expand Up @@ -898,8 +898,9 @@ end

---@param games table[]
---@return boolean
function MatchGroupInputUtil.allHasBeenPlayed(games)
return Array.all(games, function(game) return game.finished end)
function MatchGroupInputUtil.allHasBeenPlayed(playall, opponents)
local scoreSum = Array.reduce(opponents, function(sum, opponent) return sum + (opponent.score or 0) end, 0)
return scoreSum >= playall
end

---@param bestOfInput string|integer?
Expand Down

0 comments on commit ca52779

Please sign in to comment.