summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/tournaments_controller.rb23
-rw-r--r--app/views/common/_show_tournament.html.erb2
-rw-r--r--app/views/tournaments/_form.html.erb2
-rw-r--r--db/seeds.rb18
-rw-r--r--lib/scheduling/round_robin.rb (renamed from lib/scheduling/roundrobin.rb)0
5 files changed, 18 insertions, 27 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index 8752298..c212273 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -15,7 +15,8 @@ class TournamentsController < ApplicationController
when 0
render action: 'show'
when 1
- redirect_to tournament_matches_path(@tournament)
+ #redirect_to tournament_matches_page(@tournament)
+ redirect_to "/tournaments/" + @tournament.id.to_s + "/matches"
when 2
redirect_to tournaments_page
end
@@ -50,20 +51,11 @@ class TournamentsController < ApplicationController
ok &= @tournament.update(tournament_setting_params)
ok &= @tournament.hosts.push(current_user)
for i in 1..(params[:num_stages].to_i) do
- begin
- ok &= @tournament.stages.create(tournament_stage_params(i))
- rescue ActionController::ParameterMissing => e
- ok = false
- @tournament.errors.add("stages[#{i}]", "Stage #{i} not set")
- end
+ ok &= @tournament.stages.create(tournament_stage_params(i))
end
end
- rescue ActiveRecord::RecordNotUnique => e
- ok = false
- @tournament.errors.add(:name, "must be unique")
- rescue => e
+ rescue
ok = false
- @tournament.errors.add(:exception, "Unknown error: ``#{e.class.name}'' -- #{e.inspect} -- #{e.methods - Object.new.methods}")
end
respond_to do |format|
if ok
@@ -134,7 +126,7 @@ class TournamentsController < ApplicationController
ActiveRecord::Base.transaction do
success &= @tournament.save &&
sched = tournament_attribute_params[:type_opt]
- success &= @tournament.stages.create(scheduling: sched)
+ success &= @tournament.stages.create(scheduling_method: sched)
success &= @tournament.stages.first.create_matches
end
if success
@@ -179,9 +171,8 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_attribute_params
- params[:num_stages] ||= 1
if params[:tournament]
- p = params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :sampling_method, :scoring_method)
+ p = params.require(:tournament).permit(:game_id, :status, :name, :min_players_per_team, :max_players_per_team, :min_teams_per_match, :max_teams_per_match, :set_rounds, :randomized_teams, :sampling_method, :scoring_method)
if p[:game_id]
game = Game.find(p[:game_id])
p[:min_players_per_team] ||= game.min_players_per_team
@@ -207,7 +198,7 @@ class TournamentsController < ApplicationController
end
def tournament_stage_params(i)
- params.require(:tournament).require(:stages).require(i.to_s).permit(:scheduling_method, :seeding_method)
+ params.require(:tournament).require(i.to_sym).permit(:scheduling_method, :seeding_method)
end
def is_owner?(object)
diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb
index b16a37b..a9569b6 100644
--- a/app/views/common/_show_tournament.html.erb
+++ b/app/views/common/_show_tournament.html.erb
@@ -14,7 +14,7 @@
<p> Players signed up: <%= target.players.count %> </p>
</div>
<div class="col-md-4 things">
- <p> <%= (target.randomized_teams)? "Teams are Random" : "Teams are Chosen" %></p>
+ <p> <%# (target.randomized_teams)? "Teams are Random" : "Teams are Chosen" %></p>
<p> Players signed up: <%= target.players.count %> </p>
</div>
</div>
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 28d9c27..cb4c175 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -84,7 +84,7 @@
<%= f.fields_for :stages do |stages_fields| %><fieldset><legend>Stages</legend>
<label for="num_stages">Number of tournament stages</label>
<input type="number" name="num_stages" min="1" value="<%= params[:num_stages] ? params[:num_stages].to_i : 1 %>">
- <%= submit_tag("Set Stages", :class => "btn") %>
+ <%# submit_tag("Set Stages", :class => "btn") %>
<% for i in 1..(params[:num_stages].to_i) do %>
<%= stages_fields.fields_for i.to_s do |stage_fields| %><fieldset><legend>Stage <%= i %></legend>
<%= stage_fields.label :scheduling_method %>
diff --git a/db/seeds.rb b/db/seeds.rb
index 0d77208..f565815 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -9,10 +9,10 @@
p = User.permission_bits
Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm] | p[:edit_pm] | p[:create_bracket])
-Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind,RiotAPI")
-Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: true, sampling_method: "Manual,Double Blind")
-Game.create(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: 1, randomized_teams: false, sampling_method: "Manual,Double Blind")
-Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2, set_rounds: nil, randomized_teams: false, sampling_method: "Manual,Double Blind")
+Game.create(name: "League of Legends",min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2, sampling_method: "Manual,Double Blind,RiotAPI")
+Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, sampling_method: "Manual,Double Blind")
+Game.create(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2, sampling_method: "Manual,Double Blind")
+Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2, sampling_method: "Manual,Double Blind")
Game.find_by_name("League of Legends").settings.create(name: "Map", default: "Summoners Rift", type_opt: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", description: "Select a map to play on.", vartype: 5, display_order: 1)
Game.find_by_name("League of Legends").settings.create(name: "Pick Type", type_opt: "Blind Pick,Draft", description: "Select a pick type.", vartype: 5, display_order: 2)
@@ -84,7 +84,7 @@ if Rails.env.development?
#league of legends tournament
league_tourn = Tournament.create(game_id: 1, status: 0, name: "League of Legends Seed", min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2,
- max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ max_teams_per_match: 2, sampling_method: nil)
#adds players to the seeded league tournament
for i in 0..9
@@ -97,7 +97,7 @@ if Rails.env.development?
#chess
chess_tourn = Tournament.create(game_id: 2, status: 0, name: "Chess Seed", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2,
- max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ max_teams_per_match: 2, sampling_method: nil)
chess_tourn.hosts.push(davis)
chess_tourn.join(davis)
@@ -105,7 +105,7 @@ if Rails.env.development?
#Rock Paper Scissors
rps = Tournament.create(game_id: 4, status: 0, name: "Rock, Paper, Scissors Seed", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2,
- max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ max_teams_per_match: 2, sampling_method: nil)
rps.hosts.push(davis)
rps.join(davis)
@@ -113,7 +113,7 @@ if Rails.env.development?
rps.join(guntas)
tourn5 = Tournament.create(game_id: 1, status: 0, name: "5 Teams, 2 Teams Per Match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2,
- max_teams_per_match: 2, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ max_teams_per_match: 2, sampling_method: nil)
for i in 0..9
if i == 0
@@ -124,7 +124,7 @@ if Rails.env.development?
tourn5.join(players_for_league[9])
tourn6 = Tournament.create(game_id: 1, status: 0, name: "3 teams per match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 3,
- max_teams_per_match: 3, set_rounds: 1, randomized_teams: true, sampling_method: nil)
+ max_teams_per_match: 3, sampling_method: nil)
for i in 0..9
if i == 0
diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/round_robin.rb
index 7a9e257..7a9e257 100644
--- a/lib/scheduling/roundrobin.rb
+++ b/lib/scheduling/round_robin.rb