summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-27 03:04:09 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-27 03:04:09 -0400
commit987b3e0d151d58c6b44e16e3ec4d13ce7f303fe7 (patch)
tree24971fe4b80e1dd4b6d27b9041945ffb7163748d
parent125d861972b9fcd99147d67b0e8fe4102f96190e (diff)
get the tournament creation page complete
-rw-r--r--app/models/tournament.rb3
-rw-r--r--app/views/tournaments/_form.html.erb4
-rw-r--r--lib/sampling/double_blind.rb30
-rw-r--r--lib/sampling/manual.rb7
4 files changed, 37 insertions, 7 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 47cda7e..97eee57 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -107,7 +107,7 @@ class Tournament < ActiveRecord::Base
end
def sampling_methods
- make_methods("sampling").collect do |name|
+ make_methods("sampling").select do |name|
"Sampling::#{name.camelcase}".constantize.works_with?(self.game)
end
end
@@ -120,6 +120,7 @@ class Tournament < ActiveRecord::Base
make_methods "seeding"
end
+ private
def make_methods(dir)
@@methods ||= {}
if @@methods[dir].nil? or Rails.env.development?
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 78ceca4..b8d6fc1 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -83,9 +83,9 @@
<fieldset><legend>Stages</legend>
<label for="num_stages">Number of tournament stages</label>
- <input type="number" name="num_stages" min="1">
+ <input type="number" name="num_stages" min="1" value="<%= params[:num_stages] ? params[:num_stages].to_i : 1 %>">
<% for i in 1..(params[:num_stages].to_i) do %>
- <%= fields_for "tournament[stages][#{i}]", @tournament.stages do |stage_fields| %>
+ <%= fields_for "tournament[stages][#{i}]", @tournament.stages[i] do |stage_fields| %>
<fieldset><legend>Stage <%= i %></legend>
<%= stage_fields.label :scheduling_method %>
<%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %>
diff --git a/lib/sampling/double_blind.rb b/lib/sampling/double_blind.rb
index 4a5201c..409da10 100644
--- a/lib/sampling/double_blind.rb
+++ b/lib/sampling/double_blind.rb
@@ -1,7 +1,35 @@
module Sampling
module DoubleBlind
- def works_with?(game)
+ def self.works_with?(game)
return true
end
+
+ def self.uses_remote?
+ return false
+ end
+
+ def self.set_remote_name(user, game, value)
+ raise "This sampling method doesn't use remote usernames."
+ end
+
+ def self.get_remote_name(value)
+ raise "This sampling method doesn't use remote usernames."
+ end
+
+ def self.sampling_start(match)
+ # TODO
+ end
+
+ def self.sampling_done?(match)
+ # TODO
+ end
+
+ def self.render_user_interaction(match, user)
+ # TODO
+ end
+
+ def self.handle_user_interaction(match, user, sampling_params)
+ # TODO
+ end
end
end
diff --git a/lib/sampling/manual.rb b/lib/sampling/manual.rb
index 17c8104..a1bf9a5 100644
--- a/lib/sampling/manual.rb
+++ b/lib/sampling/manual.rb
@@ -1,5 +1,5 @@
module Sampling
- module HostEntry
+ module Manual
def self.works_with?(game)
return true
end
@@ -25,11 +25,12 @@ module Sampling
end
def self.render_user_interaction(match, user)
-
+ # TODO
end
def self.handle_user_interaction(match, user, sampling_params)
- match.statistics.create(user: nil, name: "blowout",
+ # TODO
+ #match.statistics.create(user: nil, name: "blowout",
end
end
end