summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 23:15:59 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-03-06 23:15:59 -0500
commitdd7c85b2eb93688ffb3c4311ca1e10eaa9bd544e (patch)
tree42a227d7e34bf7f187298b5cc907d09b336e52b7 /app/models
parent39ceb0e99eecd76b2cdebeb802930a98a764417a (diff)
parentacf821e35851b672fcb5fb350e77aedf5a674843 (diff)
Merge branch 'master' of github.com:LukeShu/leaguer
Diffstat (limited to 'app/models')
-rw-r--r--app/models/tournament.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 44b22f5..fe781e1 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -25,9 +25,17 @@ class Tournament < ActiveRecord::Base
for i in 0..num_matches
self.matches.create(name: "Match #{i}")
end
- #self.players.each_slice(num_teams) do |team_players|
- # Team.new(users: team_players)
- #end
+ match_num = 0
+ team_num = 0
+ self.players.each_slice(@tournament.max_players) do |players|
+ matches[match_num].teams[team_num] = Team.new(users: players)
+ if (team_num == 0 and team_num % @tournament.max_teams_per_match == 0)
+ match_num += 1
+ team_num = 0
+ else
+ team_num += 1
+ end
+ end
end