From c524bba025ffd09044ce35efc85ee720f3179111 Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 7 Apr 2014 01:06:50 -0400 Subject: lol# On branch master --- app/controllers/matches_controller.rb | 5 +- app/views/matches/index.html.erb | 90 ++++++++++++++++++++------------ app/views/tournaments/_selected.html.erb | 1 - 3 files changed, 61 insertions(+), 35 deletions(-) (limited to 'app') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index f196978..1d4ee27 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -9,10 +9,11 @@ class MatchesController < ApplicationController def index @matches = @tournament.matches - # width of SVG - @width = 300 * (Math.log2(@matches.count).floor + 1); + # depth of SVG tree + @depth = Math.log2(@matches.count).floor+1; # height of SVG @height = 200 * 2**Math.log2(@matches.count).floor + 100; + @h_sector = 2**(@depth-1)+1 end # For compatability with the router assumptions made by ApplicationController#check_permission diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 052d176..1941179 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -37,8 +37,19 @@
+ <% lastrx = 0 + lastry = 0 + lastrh = 0 + lastrw = 0 %> + + + + + + <% (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 %> + + + <% 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 @matches[i-1].teams.first %> + Team <%= @matches[i-1].teams.first.id %> + <% end %> + + VS + + + + <% if @matches[i-1].teams[1] %> + Team <%= @matches[i-1].teams[1].id %> + <% end %> + + + <% if i > 1 %> + + <% end %> + <% lastrx = rx + lastry = ry + lastrh = rh + lastrw = rw %> - <% if i > 1 %> - - <% end %> + <% end %>
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index b66acb0..c3a1736 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -17,5 +17,4 @@

<% end %> - <%= f.submit %> <% end %> -- cgit v1.2.3-2-g168b From bfcf3ee4f4ef28457feb21a39d347f846184309c Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 7 Apr 2014 01:13:31 -0400 Subject: Made settings work for league. --- app/models/tournament.rb | 22 +++++++++++++++------- app/views/tournaments/_selected.html.erb | 21 ++++++++++++++++++++- 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 3e85744..67f994d 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -46,13 +46,21 @@ class Tournament < ActiveRecord::Base end end - def get_type(val) { - return vartypes[:true_false] if val == "true" or val == "false" - return vartypes[:range] if /\d+-\d+/ =~ val - return vartypes[:integer] if /\d+/ =~ val - return vartypes[:select] if /,/ =~ val - return vartypes[:string] - } + def get_type(val) + case val + when "true", "false" + vartypes[:true_false] + when /\d+-\d/ =~ val + vartypes[:range] + when /\d+/ =~ val + vartypes[:integer] + when /,/ =~ val + vartypes[:select] + else + vartypes[:string] + end + end + def keys @tournament.preferences_raw.all.collect { |x| x.name } diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index b66acb0..d37c741 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -17,5 +17,24 @@

<% end %> - <%= f.submit %> + <%= fields_for "tournament[preferences]", @tournament.preferences do |setting_fields| %> + <% @game.settings.each do |setting| %> + <% case setting.stype %> + <% when 0 %> + <%= setting_fields.text_field( setting.name, :name ) %> + <% when 1 %> + <%= setting_fields.text_area( setting.name, setting.name ) %> + <% when 2 %> + <%= setting_fields.collection_radio_buttons( setting.name, setting.type_opt.split(',') ) %> + <% when 3 %> + <%= setting_fields.collection_check_boxes( setting.name, setting.type_opt.split(',') ) %> + <% when 4 %> + <%= setting_fields.radio_button( setting.name, "true" ) %> + <%= setting_fields.radio_button( setting.name, "false" ) %> + <% when 5 %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> + <% end %> + <% end %> + <% end %> + <%= f.submit %> <% end %> -- cgit v1.2.3-2-g168b