diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-06 22:05:17 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-06 22:05:17 -0400 |
commit | aa7f5b6daa1012023f34c53f7772ca5567824e94 (patch) | |
tree | 4157fe9de1e84fc4cc9d5f7c5785a329d4ad5369 /app/models | |
parent | dd46c4b23640b0719e16e874b8f593e159b54a3c (diff) | |
parent | 5084f01e0ea7ba7c378982099fdbf9880857f091 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tournament.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 0029de7..72c3ac8 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -34,16 +34,17 @@ class Tournament < ActiveRecord::Base match_num = num_matches-1 team_num = 0 #for each grouping of min_players_per_team - self.players.each_slice(min_players_per_team) do |players| - #create a new team in the current match - self.matches[match_num].teams.push(Team.create(users: players)) + players.each_slice(min_players_per_team) do |players| + #if the match is full, move to the next match, otherwise move to the next team - if (team_num != 0 and team_num % max_teams_per_match == 0) + if (team_num == min_teams_per_match) match_num -= 1 team_num = 0 else team_num += 1 end + #create a new team in the current match + self.matches[match_num].teams.push(Team.create(users: players)) end end end |