summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/tournament.rb9
-rw-r--r--app/views/tournaments/index.html.erb14
2 files changed, 14 insertions, 9 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 859518c..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 > max_teams_per_match)
+ 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
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index e174de7..72eacba 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -15,13 +15,17 @@
<h3><%= t.name %></h3>
<% end %>
- <div class="row">
+ <div class="row" style="margin-left:2%;">
<div class="col-md-4 host">
Hosted by: <%= t.hosts.first.name %>
</div>
- <div class="col-md-8 things">
- <p> Players per team </p>
- <p> two </p>
+ <div class="col-md-4 things">
+ <p> Players per team: <%= t.min_players_per_team %></p>
+ <p> Players signed up: <%= t.players.count %> </p>
+ </div>
+ <div class="col-md-4 things">
+ <p> <%= (t.randomized_teams)? "Teams are Random" : "Teams are Chosen" %></p>
+ <p> Players signed up: <%= t.players.count %> </p>
</div>
</div>
@@ -36,7 +40,7 @@
<%= submit_tag("Join") %>
<% end %>
<% else %>
- <p> You've signed up for this tournament! </p>
+ <p style="margin-top:10px;"> You've signed up for this tournament! </p>
<% end %>
</div>