From 49a6545af9f9f3e20ee390afe9cab56fc4e5ea73 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Wed, 17 Apr 2019 21:05:09 +0200 Subject: [PATCH] Fix start point for stages with matchnumbers that are not powers of 2 --- app/services/match_service.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/services/match_service.rb b/app/services/match_service.rb index 0eb9fa8..29fffdb 100644 --- a/app/services/match_service.rb +++ b/app/services/match_service.rb @@ -37,9 +37,11 @@ class MatchService matches << match 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 # 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])] matches << match end