From 0f982ba511d4f38322f69a6aaed768181b4e2852 Mon Sep 17 00:00:00 2001 From: tkimia Date: Sun, 6 Apr 2014 21:10:46 -0400 Subject: some more graphics --- app/assets/stylesheets/matches.css.scss | 8 ++++ app/controllers/matches_controller.rb | 2 +- app/models/tournament.rb | 2 +- app/views/matches/index.html.erb | 80 +++++++++++++++++++-------------- 4 files changed, 56 insertions(+), 36 deletions(-) diff --git a/app/assets/stylesheets/matches.css.scss b/app/assets/stylesheets/matches.css.scss index 4c396e3..e0bed85 100644 --- a/app/assets/stylesheets/matches.css.scss +++ b/app/assets/stylesheets/matches.css.scss @@ -1,3 +1,11 @@ // Place all the styles related to the matches controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +#match-tree{ + float: right; +} + +#hovered-info-text { + +} \ No newline at end of file diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index e773667..28bc512 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -9,7 +9,7 @@ class MatchesController < ApplicationController def index @matches = @tournament.matches # width of SVG - @width = 300 * (Math.log2(@matches.count).floor + 1) + 300; + @width = 300 * (Math.log2(@matches.count).floor + 1); # height of SVG @height = 200 * 2**Math.log2(@matches.count).floor + 100; end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 0029de7..859518c 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -38,7 +38,7 @@ class Tournament < ActiveRecord::Base #create a new team in the current match self.matches[match_num].teams.push(Team.create(users: 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 > max_teams_per_match) match_num -= 1 team_num = 0 else diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 031b2a9..6fd831f 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -27,38 +27,50 @@
- - - <% (1..@matches.count).each do |i| %> - - - <% when 0 %> - <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> - stroke="red" - fill-opacity="0.6" - <% else %> - stroke="green" - <% end %> - <% when 1 %> - stroke="orange" - <% when 2 %> - stroke="yellow" - <% when 3 %> - stroke="grey" - <% end %> - /> - - <% end %> - - + + + <% (1..@matches.count).each do |i| %> + + + <% when 0 %> + <% if @matches[i-1].teams.count < @tournament.min_teams_per_match %> + stroke="red" + fill-opacity="0.6" + <% else %> + stroke="green" + <% end %> + <% when 1 %> + stroke="orange" + <% when 2 %> + stroke="yellow" + <% when 3 %> + stroke="grey" + <% end %> + /> + + <% if i > 1 %> + + <% end %> + <% end %> -
\ No newline at end of file + -- cgit v1.2.3-2-g168b