Fix start point for stages with matchnumbers that are not powers of 2

This commit is contained in:
Daniel Schädler 2019-04-17 21:05:09 +02:00
parent 1c2d051364
commit 49a6545af9
1 changed files with 3 additions and 1 deletions

View File

@ -37,9 +37,11 @@ class MatchService
matches << match matches << match
end end
# the start point is to compensate for all the teams that are already within a "normal" match
startpoint = matches.size
until matches.size >= needed_games until matches.size >= needed_games
# while we do not have enough matches in general we need to fill the array with "single team" matches # while we do not have enough matches in general we need to fill the array with "single team" matches
i = matches.size i = matches.size + startpoint
match = Match.new state: :single_team, position: i, match_scores: [MatchScore.create(team: teams[i])] match = Match.new state: :single_team, position: i, match_scores: [MatchScore.create(team: teams[i])]
matches << match matches << match
end end