summaryrefslogtreecommitdiff
path: root/app/models/tournament.rb
diff options
context:
space:
mode:
authorDavisLWebb <davislwebb@ymail.com>2014-03-07 00:05:47 -0500
committerDavisLWebb <davislwebb@ymail.com>2014-03-07 00:05:47 -0500
commitabfb00904d5497c320200f3586fe503820ac651c (patch)
treecfbbfae80b36fa566bade137557c701516ad90ef /app/models/tournament.rb
parent0eaebadc3d943189bef136bbc2205897c106c507 (diff)
parente74879dd4769e8bed34085ee3f978fc4a31366cb (diff)
Merge branch 'master' of http://github.com/LukeShu/leaguer
Diffstat (limited to 'app/models/tournament.rb')
-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