summaryrefslogtreecommitdiff
path: root/app/models/tournament.rb
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-06 22:06:32 -0500
committerTomer Kimia <tkimia@purdue.edu>2014-03-06 22:06:32 -0500
commit2bfc17c39f9b8b5ea71d36d2d5f041295f24192f (patch)
treedb8a9a72364e7fc80c17a0c3c2c58b835d06f140 /app/models/tournament.rb
parent3f6f212c1d50a0ae953104524ceffe94095307cf (diff)
tournaments setup started. NOT FINISHED
Diffstat (limited to 'app/models/tournament.rb')
-rw-r--r--app/models/tournament.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 26dec72..c359b1c 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -19,4 +19,17 @@ class Tournament < ActiveRecord::Base
pair = UserTournamentPair.new(tournament: self, user: user)
return pair.save
end
+
+ def setup
+ num_teams = (self.users.count/self.players_per_team).floor
+ num_matches = num_teams - 1
+ 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
+ end
+
+
end