From 410bbdce9752fb49ab711d4c148af1c6bbc2a53f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 18:53:25 -0400 Subject: clean up seeds.rb --- db/seeds.rb | 41 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index f565815..dc95929 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,33 +9,20 @@ 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, 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) -#Game.find_by_name("League of Legends").settings.create(name: "Scoring Method", type_opt: "FibonacciPeerWithBlowout,MarginalPeer,WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 3) -#Game.find_by_name("League of Legends").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 4) -#Game.find_by_name("League of Legends").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 5) - -Game.find_by_name("Chess").settings.create(name: "Time Control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: 0, display_order: 1) -#Game.find_by_name("Chess").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) -#Game.find_by_name("Chess").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) -#Game.find_by_name("Chess").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) - -Game.find_by_name("Hearthstone").settings.create(name: "Deck Name", description: "Enter a name for your deck, be descriptive.", vartype: 1, display_order: 1) -#Game.find_by_name("Hearthstone").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 2) -#Game.find_by_name("Hearthstone").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 3) -#Game.find_by_name("Hearthstone").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 4) - -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Favorite Object", description: "What is your favorite object in RPS?", type_opt: "Rock,Paper,Scissors", vartype: 2, display_order: 5) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Lizard, Spock allowed?", description: "Will you allow Lizard and Spock?", vartype: 4, display_order: 4) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Why are those up there even called radio buttons?", description: "Check boxes make sense at least", type_opt: "I do not know.,There is now spoon.,Wow.,Because electricity.,Wat?", vartype: 3, display_order: 6) -#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scoring Method", type_opt: "WinnerTakesAll", description: "Select Scoring Method", vartype: 5, display_order: 1) -#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Seeding Method", type_opt: "Manual,Random,MultiStage", description: "Select Seeding Method", vartype: 5, display_order: 2) -#Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Scheduling Method", type_opt: "Elimination,RoundRobin", description: "Select Scheduling Method", vartype: 5, display_order: 3) +league = 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: "riot_api") +league.settings.create(display_order: 1, name: "Map" , description: "Select a map to play on.", vartype: GameSetting::types[:pick_one_dropdown], type_opt: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", default: "Summoners Rift") +league.settings.create(display_order: 2, name: "Pick type", description: "Select a pick type." , vartype: GameSetting::types[:pick_one_dropdown], type_opt: "Blind pick,Draft" , default: "Draft") + +chess = 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") +chess.settings.create(display_order: 1, name: "Time Control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: GameSetting::types[:text_short], default: "") + +hearthstone = 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") +hearthstone.settings.create(display_order: 1, name: "Deck name", description: "Enter a name for your deck, be descriptive.", vartype: GameSetting::types[:text_long], default: "") + +rockpaperscissors = 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") +rockpaperscissors.settings.create(display_order: 4, name: "Lizard/Spock allowed?", description: "Will you allow Lizard and Spock?" , vartype: GameSetting::types[:true_false] , default: false) +rockpaperscissors.settings.create(display_order: 5, name: "Favorite object" , description: "What is your favorite object in RPS?", vartype: GameSetting::types[:pick_one_radio], type_opt: "Rock,Paper,Scissors", default: "Rock") +rockpaperscissors.settings.create(display_order: 6, name: "Check boxes" , description: "Example boxes" , vartype: GameSetting::types[:pick_several] , type_opt: "I do not know,There is now spoon,Wow,Because electricity,Wat?", default: "Wow,Wat?") if Rails.env.development? #user 1, the ADMIN -- cgit v1.2.3 From 70690fe168e88ad54be83e7a1ac45bdc32f1a54a Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 20:13:18 -0400 Subject: Updated RR scheduling. --- lib/scheduling/round_robin.rb | 77 ++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb index 1d9ac0d..0cbddc1 100644 --- a/lib/scheduling/round_robin.rb +++ b/lib/scheduling/round_robin.rb @@ -7,42 +7,53 @@ module Scheduling end def create_matches - #number of teams*number of teams per match = number of matches per round - num_teams = (tournament.players.count/tournament.min_players_per_team).floor + # => find the number of matches and teams to create + @num_teams = (tournament.players.count/tournament.min_players_per_team).floor @matches_per_round = num_teams * tournament.min_teams_per_match + # => initialize data and status members + @team_pairs ||= {} + if @team_pairs.empty? + @matches_finished = 0 + end + + # => Create new matches @matches_per_round.each do |match| tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end - tournament_stage.seeding.seed_matches(tournament_stage) + # => seed the first time + if @team_pairs.empty? + tournament_stage.seeding.seed_matches(tournament_stage) + tournament_stage.matches.each {|match| match.teams.each {|team| @team_pairs += team}} + else + # => Reorder the list of teams + top = @team_pairs.shift + @team_pairs.push @team_pairs.shift + @team_pairs.unshift top + + # => Add the teams to the matches + match = tournament_stage.matches[@matches_finished-1] + matches = 1 + (0..@team_pairs.count-1).each do |i| + match.teams += @team_pairs[i] + if @team_pairs.count.%(tournament.min_teams_per_match).zero? + match = tournament_stage.matches[@matches_finished-1 + matches] + matches += 1 + end + end + + end end def finish_match(match) - #declare winner of match, and store that somehow - rotate - return "totes worked\n" + @matches_finished += 1 end def graph(current_user) end private - - def create_round_array - #round robin should look like this. - #NOTE: I DO NOT KNOW IF THIS IS HOW TO PROPERLY POPULATE THE ROUND ROBIN ARRAY WITH TEAMS - @team_pairs = Array.new(num_matches) - for i in 0..@match.teams.size - @team_pairs.push(@match.teams[i]) - #if there is an odd number of teams, add a dummy for byes - if @match.teams.size % 2 != 0 && i == @match.teams.size-1 - dummy = Team.create - @team_pairs.push(dummy) - end - end - end - def tournament_stage @tournament_stage end @@ -50,29 +61,5 @@ module Scheduling def tournament tournament_stage.tournament end - - def rotate - #this is called when a round has completed - - #remove first team - hold = @team_pairs.shift - #rotate by 1 element - @team_pairs.rotate! - #place first team the front of the array - @team_pairs.unshift(hold) - end - - def mother_fuckin_winner - scores = {} - @teams_pairs.each do |team| - scores[team] = team.matches. - where(:tournament_stage => tournament_stage). - collect{|match|match.winner==team} - end - weiner = scores.index(scores.max) - scores[weiner] - end - - end end -- cgit v1.2.3 From b8ce4ab9ad7e6359080e894958a3181cbb3895d2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:24:36 -0400 Subject: touch up tournament creation --- app/controllers/tournaments_controller.rb | 17 ++++++++++++++--- app/models/game.rb | 4 +++- app/models/tournament.rb | 24 +++++++++++++----------- app/views/tournaments/_form.html.erb | 25 ++++++++++++------------- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 9c8ad7a..2e854a2 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -31,6 +31,17 @@ class TournamentsController < ApplicationController # GET /tournaments/new def new @tournament = Tournament.new(tournament_attribute_params) + if @tournament.game + @tournament.game.settings.each do |game_setting| + @tournament.tournament_settings.build( + name: game_setting.name, + value: game_setting.value, + vartype: game_setting.vartype, + type_opt: game_setting.type_opt, + description: game_setting.description, + display_order: game_setting.display_order) + end + end end # GET /tournaments/1/edit @@ -46,17 +57,17 @@ class TournamentsController < ApplicationController ok = true begin ActiveRecord::Base.transaction do - ok &= @tournament.save 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)) + ok &= @tournament.stages.build(tournament_stage_params(i)) rescue ActionController::ParameterMissing => e ok = false - @tournament.errors.add("stages[#{i}]", "Stage #{i} not set") + @tournament.errors.add("stages[#{i}]", "needs to be set") end end + ok &= @tournament.save end rescue ActiveRecord::RecordNotUnique => e ok = false diff --git a/app/models/game.rb b/app/models/game.rb index 5f4c46d..c5cb32a 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,5 +1,7 @@ class Game < ActiveRecord::Base belongs_to :parent, class_name: "Game" has_many :children, class_name: "Game" - has_many :settings, class_name: "GameSetting" + has_many :game_settings + + alias_attribute :settings, :game_settings end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 97eee57..a569213 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,11 +1,13 @@ class Tournament < ActiveRecord::Base belongs_to :game - has_many :stages, class_name: "TournamentStage" + has_many :tournament_stages has_many :brackets - has_many :settings_raw, class_name: "TournamentSetting" + has_many :tournament_settings has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" + alias_attribute :stages, :tournament_stages + # Settings ################################################################# def settings @@ -25,7 +27,7 @@ class Tournament < ActiveRecord::Base end def [](setting_name) - tournament_setting = @tournament.settings_raw.find_by_name(setting_name) + tournament_setting = @tournament.tournament_settings.find{|s|s.name==setting_name} if tournament_setting.nil? return nil else @@ -34,13 +36,13 @@ class Tournament < ActiveRecord::Base end def []=(setting_name, val) - tournament_setting = @tournament.settings_raw.find_by_name(setting_name) + tournament_setting = @tournament.tournament_settings.find{|s|s.name==setting_name} if tournament_setting.nil? game_setting = @tournament.game.settings.find_by_name(setting_name) - @tournament.settings_raw.create(name: setting, value: val, - vartype: game_setting.vartype, - type_opt: game_setting.type_opt, - description: game_setting.description, + @tournament.tournament_settings.build(name: setting_name, value: val, + vartype: game_setting.vartype, + type_opt: game_setting.type_opt, + description: game_setting.description, display_order: game_setting.display_order) else tournament_setting.value = val @@ -48,7 +50,7 @@ class Tournament < ActiveRecord::Base end def keys - @tournament.settings_raw.all.collect { |x| x.name } + @tournament.tournament_settings.all.collect { |x| x.name } end def empty?() keys.empty? end @@ -58,9 +60,9 @@ class Tournament < ActiveRecord::Base def method_missing(name, *args) if name.to_s.ends_with?('=') - self[name.to_s.sub(/=$/, '').to_sym] = args.first + self[name.to_s.sub(/=$/, '').to_s] = args.first else - return self[name.to_sym] + return self[name.to_s] end end end diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index cb4c175..329fc5f 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -7,7 +7,7 @@

<%= f.label :game_id, "Select a game type" %> <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> - <%= submit_tag("Select", :class => "btn") %> + <%= f.submit("Select") %>

<% if @tournament.game.nil? %> @@ -50,32 +50,31 @@
Settings <%= f.fields_for :settings do |setting_fields| %> - <% (@tournament.settings.empty? ? @tournament.game.settings : @tournament.settings).each do |setting| %>

- <% name = setting.name.parameterize.underscore %> - <%= setting_fields.label name %> + <% @tournament.tournament_settings.each do |setting| %>

+ <%= setting_fields.label setting.name %>
<% case setting.vartype %> <% when 0 %> - <%= setting_fields.text_field( name ) %> + <%= setting_fields.text_field( setting.name ) %> <% when 1 %> - <%= setting_fields.text_area( name ) %> + <%= setting_fields.text_area( setting.name ) %> <% when 2 %>

    <% setting.type_opt.split(',').each do |option|%> -
  • +
  • <% end %>
<% when 3 %>
    <% setting.type_opt.split(',').each do |option|%> -
  • +
  • <% end %>
<% when 4 %> - <%= setting_fields.radio_button( name, "true" ) %> True - <%= setting_fields.radio_button( name, "false" ) %> False + <%= setting_fields.radio_button( setting.name, "true" ) %> True + <%= setting_fields.radio_button( setting.name, "false" ) %> False <% when 5 %> - <%= setting_fields.select( name, setting.type_opt.split(',') ) %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> <% end %>

<% end %> <% end %> @@ -83,8 +82,8 @@ <%= f.fields_for :stages do |stages_fields| %>
Stages - - <%# submit_tag("Set Stages", :class => "btn") %> + + <%# stage_fields.submit("Set Stages") %> <% for i in 1..(params[:num_stages].to_i) do %> <%= stages_fields.fields_for i.to_s do |stage_fields| %>
Stage <%= i %> <%= stage_fields.label :scheduling_method %> -- cgit v1.2.3 From dedb63d770af24eee6e73289499ba22ec607cbf2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:24:44 -0400 Subject: clean up seeds.rb --- db/seeds.rb | 69 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index dc95929..c37dcf7 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,19 +10,19 @@ p = User.permission_bits Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm] | p[:edit_pm] | p[:create_bracket]) league = 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: "riot_api") -league.settings.create(display_order: 1, name: "Map" , description: "Select a map to play on.", vartype: GameSetting::types[:pick_one_dropdown], type_opt: "Summoners Rift,Twisted Treeline,Crystal Scar,Haunted Abyss", default: "Summoners Rift") -league.settings.create(display_order: 2, name: "Pick type", description: "Select a pick type." , vartype: GameSetting::types[:pick_one_dropdown], type_opt: "Blind pick,Draft" , default: "Draft") +league.settings.create(display_order: 1, name: "map" , description: "Select a map to play on.", vartype: GameSetting::types[:pick_one_dropdown], type_opt: "summoners_rift,twisted_treeline,crystal_scar,haunted_abyss", default: "summoners_rift") +league.settings.create(display_order: 2, name: "pick_type", description: "Select a pick type." , vartype: GameSetting::types[:pick_one_dropdown], type_opt: "blind_pick,draft" , default: "draft") -chess = 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") -chess.settings.create(display_order: 1, name: "Time Control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: GameSetting::types[:text_short], default: "") +chess = 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: "double_blind") +chess.settings.create(display_order: 1, name: "time_control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: GameSetting::types[:text_short], default: "") -hearthstone = 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") -hearthstone.settings.create(display_order: 1, name: "Deck name", description: "Enter a name for your deck, be descriptive.", vartype: GameSetting::types[:text_long], default: "") +hearthstone = 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: "double_blind") +hearthstone.settings.create(display_order: 1, name: "deck_name", description: "Enter a name for your deck, be descriptive.", vartype: GameSetting::types[:text_long], default: "") -rockpaperscissors = 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") -rockpaperscissors.settings.create(display_order: 4, name: "Lizard/Spock allowed?", description: "Will you allow Lizard and Spock?" , vartype: GameSetting::types[:true_false] , default: false) -rockpaperscissors.settings.create(display_order: 5, name: "Favorite object" , description: "What is your favorite object in RPS?", vartype: GameSetting::types[:pick_one_radio], type_opt: "Rock,Paper,Scissors", default: "Rock") -rockpaperscissors.settings.create(display_order: 6, name: "Check boxes" , description: "Example boxes" , vartype: GameSetting::types[:pick_several] , type_opt: "I do not know,There is now spoon,Wow,Because electricity,Wat?", default: "Wow,Wat?") +rockpaperscissors = 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: "double_blind") +rockpaperscissors.settings.create(display_order: 4, name: "lizard_spock_allowed", description: "Will you allow Lizard and Spock?" , vartype: GameSetting::types[:true_false] , default: false) +rockpaperscissors.settings.create(display_order: 5, name: "favorite_object" , description: "What is your favorite object in RPS?", vartype: GameSetting::types[:pick_one_radio], type_opt: "rock,paper,scissors", default: "rock") +rockpaperscissors.settings.create(display_order: 6, name: "check_boxes" , description: "Example boxes" , vartype: GameSetting::types[:pick_several] , type_opt: "i_do_not_know,there_is_now_spoon,wow,because_electricity,wat?", default: "wow,wat?") if Rails.env.development? #user 1, the ADMIN @@ -43,35 +43,36 @@ if Rails.env.development? players_for_league = Array.new #users for our fake seeded game from the yamls - players_for_league.push(User.create(name: "Sytrie", password: "password", email: "Sytrie@gmail.com", user_name: "Sytrie", password_confirmation: "password")) - players_for_league.push(User.create(name: "Derpanator115", password: "password", email: "Derpanator115@gmail.com", user_name: "Derpanator115", password_confirmation: "password")) - players_for_league.push(User.create(name: "Wlknexe56", password: "password", email: "Wlknexe56@gmail.com", user_name: "Wlknexe56", password_confirmation: "password")) - players_for_league.push(User.create(name: "DVisionzz", password: "password", email: "DVisionzz@gmail.com", user_name: "DVisionzz", password_confirmation: "password")) - players_for_league.push(User.create(name: "HYP3RTONIC", password: "password", email: "HYP3RTONIC@gmail.com", user_name: "HYP3RTONIC", password_confirmation: "password")) - players_for_league.push(User.create(name: "M9Fumjaa", password: "password", email: "M9Fumjaa@gmail.com", user_name: "M9Fumjaa", password_confirmation: "password")) - players_for_league.push(User.create(name: "spikevsnaruto", password: "password", email: "spikevsnaruto@gmail.com", user_name: "spikevsnaruto", password_confirmation: "password")) - players_for_league.push(User.create(name: "GoogleMaSkills", password: "password", email: "GoogleMaSkills@gmail.com", user_name: "GoogleMaSkills", password_confirmation: "password")) + players_for_league.push(User.create(name: "Sytrie" , password: "password", email: "Sytrie@gmail.com" , user_name: "Sytrie" , password_confirmation: "password")) + players_for_league.push(User.create(name: "Derpanator115" , password: "password", email: "Derpanator115@gmail.com" , user_name: "Derpanator115" , password_confirmation: "password")) + players_for_league.push(User.create(name: "Wlknexe56" , password: "password", email: "Wlknexe56@gmail.com" , user_name: "Wlknexe56" , password_confirmation: "password")) + players_for_league.push(User.create(name: "DVisionzz" , password: "password", email: "DVisionzz@gmail.com" , user_name: "DVisionzz" , password_confirmation: "password")) + players_for_league.push(User.create(name: "HYP3RTONIC" , password: "password", email: "HYP3RTONIC@gmail.com" , user_name: "HYP3RTONIC" , password_confirmation: "password")) + players_for_league.push(User.create(name: "M9Fumjaa" , password: "password", email: "M9Fumjaa@gmail.com" , user_name: "M9Fumjaa" , password_confirmation: "password")) + players_for_league.push(User.create(name: "spikevsnaruto" , password: "password", email: "spikevsnaruto@gmail.com" , user_name: "spikevsnaruto" , password_confirmation: "password")) + players_for_league.push(User.create(name: "GoogleMaSkills" , password: "password", email: "GoogleMaSkills@gmail.com" , user_name: "GoogleMaSkills" , password_confirmation: "password")) players_for_league.push(User.create(name: "james chamberlan", password: "password", email: "jameschamberlan@gmail.com", user_name: "james chamberlan", password_confirmation: "password")) - players_for_league.push(User.create(name: "Kaceytron", password: "password", email: "Kaceytron@gmail.com", user_name: "Kaceytron", password_confirmation: "password")) + players_for_league.push(User.create(name: "Kaceytron" , password: "password", email: "Kaceytron@gmail.com" , user_name: "Kaceytron" , password_confirmation: "password")) #semi-real users - davis = User.create(name: "Davis Webb", password: "password", email: "davislwebb@gmail.com", user_name: "TeslasMind", password_confirmation: "password") - foy = User.create(name: "Nathaniel Foy", password: "password", email: "nfoy@notreal.com", user_name: "Nalfeinx", password_confirmation: "password") - guntas = User.create(name: "Guntas Grewal", password: "password", email: "guntasgrewal@gmail.com", user_name: "guntasgrewal", password_confirmation: "password") - luke = User.create(name: "Luke Shumaker", password: "password", email: "lukeshu@emacs4lyfe.com", user_name: "lukeshu", password_confirmation: "password") - tomer = User.create(name: "Tomer Kimia", password: "password", email: "tomer@2majors4lyfe.com", user_name: "tkimia", password_confirmation: "password") - andrew = User.create(name: "Andrew Murrell", password: "password", email: "murrel@murrel.gov", user_name: "ImFromNasa", password_confirmation: "password") - joey = User.create(name: "Joseph Adams", password: "password", email: "alpha142@fluttershyop.com", user_name: "alpha142", password_confirmation: "password") - josh = User.create(name: "Josh Huser", password: "password", email: "jhuser@iownabusiness.net", user_name: "WinterWorks", password_confirmation: "password") - dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu", user_name: "Dumbledore", password_confirmation: "password") - marco = User.create(name: "Marco Polo", password: "password", email: "marco@ta4lyfe.com", user_name: "iCoordinate", password_confirmation: "password") - jordan = User.create(name: "Geoffrey Webb", password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix", password_confirmation: "password") - obama = User.create(name: "Obama", password: "password", email: "obama@whitehouse.gov", user_name: "Obama", password_confirmation: "password") - + davis = User.create(name: "Davis Webb" , password: "password", email: "davislwebb@gmail.com" , user_name: "TeslasMind" , password_confirmation: "password") + foy = User.create(name: "Nathaniel Foy" , password: "password", email: "nfoy@notreal.com" , user_name: "Nalfeinx" , password_confirmation: "password") + guntas = User.create(name: "Guntas Grewal" , password: "password", email: "guntasgrewal@gmail.com" , user_name: "guntasgrewal", password_confirmation: "password") + luke = User.create(name: "Luke Shumaker" , password: "password", email: "lukeshu@emacs4lyfe.com" , user_name: "lukeshu" , password_confirmation: "password") + tomer = User.create(name: "Tomer Kimia" , password: "password", email: "tomer@2majors4lyfe.com" , user_name: "tkimia" , password_confirmation: "password") + andrew = User.create(name: "Andrew Murrell" , password: "password", email: "murrel@murrel.gov" , user_name: "ImFromNasa" , password_confirmation: "password") + joey = User.create(name: "Joseph Adams" , password: "password", email: "alpha142@fluttershyop.com" , user_name: "alpha142" , password_confirmation: "password") + josh = User.create(name: "Josh Huser" , password: "password", email: "jhuser@iownabusiness.net" , user_name: "WinterWorks" , password_confirmation: "password") + dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu" , user_name: "Dumbledore" , password_confirmation: "password") + marco = User.create(name: "Marco Polo" , password: "password", email: "marco@ta4lyfe.com" , user_name: "iCoordinate" , password_confirmation: "password") + jordan = User.create(name: "Geoffrey Webb" , password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix" , password_confirmation: "password") + obama = User.create(name: "Obama" , password: "password", email: "obama@whitehouse.gov" , user_name: "Obama" , password_confirmation: "password") #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, sampling_method: nil) + league_tourn = Tournament.create(game: league, 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, + sampling_method: "riot_api", scoring_method: "TODO") #adds players to the seeded league tournament for i in 0..9 -- cgit v1.2.3 From b71747c6c8b24ab8144a3fc412cc2d385406c512 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:26:10 -0400 Subject: clean lib/seeding/README.md --- lib/seeding/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/seeding/README.md b/lib/seeding/README.md index 596adea..d323b6d 100644 --- a/lib/seeding/README.md +++ b/lib/seeding/README.md @@ -1,5 +1,10 @@ -Files in this directory should implement the following interface: +Seeding interface +================= -- `seed(tournament_stage)` - take a tournament stage, assign players to teams and teams to - matches (matches must exist) \ No newline at end of file +Files in this directory should be _modules_ implement the following +interface: + + - `seed(TournamentStage)` + + Take a tournament stage, assign players to teams and teams to + matches (matches must exist). -- cgit v1.2.3 From 9d0be853cef35412c0bfe92c80502fd9da7947f1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:29:22 -0400 Subject: Fix namespacing in lib/seeding --- lib/seeding/early_bird_seeding.rb | 6 +++--- lib/seeding/fair_ranked_seeding.rb | 16 ++++++++-------- lib/seeding/random_seeding.rb | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb index f3fc6f9..488a1a2 100644 --- a/lib/seeding/early_bird_seeding.rb +++ b/lib/seeding/early_bird_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class EarlyBirdSeeding - def seed(tournament_stage) + module EarlyBirdSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -17,4 +17,4 @@ module Seeding end end end -end \ No newline at end of file +end diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 22c245e..f56d648 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class FairRankedSeeding - def seed(tournament_stage) + module FairRankedSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -19,17 +19,17 @@ module Seeding end private - def best_first(tournament) + def self.best_first(tournament) tournament.players.sort {|a, b| better(a, b, tournament) } end - def better(player1, player2, tournament) - ps1 = previousScore(player1, tournament) - ps2 = previousScore(player2, tournament) + def self.better(player1, player2, tournament) + ps1 = previous_score(player1, tournament) + ps2 = previous_score(player2, tournament) ps1 <=> ps2 end - def previousScore(player, tournament) + def self.previous_score(player, tournament) score = tournament.statistics.getStatistic(player.matches.last, player, :score) if score.nil? return 0 @@ -37,4 +37,4 @@ module Seeding score end end -end \ No newline at end of file +end diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb index bc332ef..723d70e 100644 --- a/lib/seeding/random_seeding.rb +++ b/lib/seeding/random_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class RandomSeeding - def seed(tournament_stage) + module RandomSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -17,4 +17,4 @@ module Seeding end end end -end \ No newline at end of file +end -- cgit v1.2.3 From df1cda1faab97f4c424efdcf8b6822f98b73adb8 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Sun, 27 Apr 2014 20:47:31 -0400 Subject: Made some CSS changes all over the website. Added an alert icon.still need ajax to work with it --- app/assets/stylesheets/custom.css.scss | 15 ++++++- app/assets/stylesheets/scaffolds.css.scss | 4 +- app/assets/stylesheets/tournaments.css.scss | 1 + app/views/layouts/application.html.erb | 7 +++- app/views/servers/_form.html.erb | 17 ++++---- app/views/tournaments/_form.html.erb | 64 +++++++++++++++++------------ app/views/tournaments/standings.html.erb | 20 ++++++++- 7 files changed, 87 insertions(+), 41 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index 6e54043..9e9e63a 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -24,6 +24,17 @@ header > nav { } } +.btn-custom-orange { + color: white; + background-color: rgb(255, 69, 0); + border-color: rgb(255, 69, 0); +} +.btn-custom-foxtrot { + color: white; + background-color: hsl(0, 69%, 22%) !important; +} + + a, input[type="submit"] { @extend .btn; @@ -31,7 +42,9 @@ a, input[type="submit"] { &.signup { @extend .btn-success; } &.signin { @extend .btn-warning; } &.signout { @extend .btn-danger; } - &.server { @extend .btn-danger; } + &.server { @extend .btn-warning; } + &.create-alert {@extend .btn-custom-orange;} + &.alerts { @extend .navbar-right; @extend .glyphicon; @extend .glyphicon-exclamation-sign; @extend .btn-custom-foxtrot;} font-weight: bold !important; } diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss index eb1f751..3c485b5 100644 --- a/app/assets/stylesheets/scaffolds.css.scss +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -62,8 +62,8 @@ pre { a { color: $link-yellow; &:hover { - color: #FFEF00; - text-decoration: none; + color: white; + } } diff --git a/app/assets/stylesheets/tournaments.css.scss b/app/assets/stylesheets/tournaments.css.scss index cc55253..42afd38 100644 --- a/app/assets/stylesheets/tournaments.css.scss +++ b/app/assets/stylesheets/tournaments.css.scss @@ -30,6 +30,7 @@ span.default-explanation { } + #tournament-users{ li { diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index cf55c18..9eea734 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,13 +28,16 @@ <% if signed_in? %> <%= link_to current_user.user_name, current_user, :class => "user" %> <%= link_to "Messages", pms_path, :class => "signup" %> - <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %> <% if current_user.can? :edit_server %> <%= link_to "Server settings", edit_server_path, :class => "server" %> <% end %> <% if current_user.can? :create_alert %> - <%= link_to "Create Alert", new_alert_path, :class => "signin" %> + <%= link_to "Create Alert", new_alert_path, :class => "create-alert" %> <% end %> + <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %> + <%= link_to "", alerts_path, :class => "alerts"%> + + <% else %> <%= link_to "Log in", new_session_path, :class => "signin" %> <%= link_to "Sign up", new_user_path, :class => "signup" %> diff --git a/app/views/servers/_form.html.erb b/app/views/servers/_form.html.erb index 1afde11..8853a80 100644 --- a/app/views/servers/_form.html.erb +++ b/app/views/servers/_form.html.erb @@ -1,18 +1,19 @@ <%= form_for(@server) do |f| %> <%= render "common/error_messages", :target => @server %> -
- Default permissions for new users -
    +
    + Default permissions for new users +
      <%= fields_for "server[default_user_abilities]", @server.default_user_abilities do |a| %> <% @server.default_user_abilities.keys.each do |ability| %> -
    • +
    • <% end %> <% end %>
    - -
    - <%= f.submit %> -
    +

    +

    + <%= f.submit %> +
    +

    <% end %> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index cb4c175..2212515 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -3,7 +3,7 @@ method: (@tournament.game.nil? ? "get" : "post")) do |f| %> <%= render "common/error_messages", :target => @tournament %> -
    Attributes +
    Attributes

    <%= f.label :game_id, "Select a game type" %> <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> @@ -18,23 +18,33 @@ <%= f.label :name %> <%= f.text_field :name %>

    - - - - - - - - - - - - - - - - -
    MinimumMaximum
    Players per team<%= f.text_field(:min_players_per_team, type: :number, min: 1) %><%= f.text_field(:max_players_per_team, type: :number, min: 1) %>
    Teams per match<%= f.text_field(:min_teams_per_match, type: :number, min: 1) %><%= f.text_field(:max_teams_per_match, type: :number, min: 1) %>
    +
    +

    + + + + + + + + + + +
    MinimumMaximum
    Players per team: <%= f.text_field(:min_players_per_team, type: :number, min: 1) %><%= f.text_field(:max_players_per_team, type: :number, min: 1) %>
    +

    +
    + +
    +

    + + + + + + +
    Teams per match: <%= f.text_field(:min_teams_per_match, type: :number, min: 1) %><%= f.text_field(:max_teams_per_match, type: :number, min: 1) %>
    +

    +

    <%= f.label :scoring_method %> @@ -48,7 +58,7 @@

    -
    Settings +
    Settings <%= f.fields_for :settings do |setting_fields| %> <% (@tournament.settings.empty? ? @tournament.game.settings : @tournament.settings).each do |setting| %>

    <% name = setting.name.parameterize.underscore %> @@ -81,17 +91,19 @@ <% end %>

    - <%= f.fields_for :stages do |stages_fields| %>
    Stages + <%= f.fields_for :stages do |stages_fields| %>
    Stages <%# 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| %>
    Stage <%= i %> - <%= stage_fields.label :scheduling_method %> - <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> - <%= stage_fields.label :seeding_method %> - <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> -
    <% end %> +

    + <%= stages_fields.fields_for i.to_s do |stage_fields| %>

    Stage <%= i %> + <%= stage_fields.label :scheduling_method %> + <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> + <%= stage_fields.label :seeding_method %> + <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> +
    <% end %> +

    <% end %>
    <% end %> diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb index 28d3c22..b8739de 100644 --- a/app/views/tournaments/standings.html.erb +++ b/app/views/tournaments/standings.html.erb @@ -1,4 +1,7 @@ -<% playerscores = @tournament.players.collect {|player| player => tournament.statistics.getStatistic(player.matches.last, player, :score) } %> +<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.getStatistic(player.matches.last, player, :score) } %> +<% teams = tournament_stage.matches.collect +{ |match| match.teams.collect { |team| team.id => team.players.collect +{ |player| player.user_name => @tournament.statistics.getStatistic(player.matches.last, player, :score } } } %> @@ -9,4 +12,17 @@ <% place += 1%> <% end %> -
    \ No newline at end of file + + +<% teams.each do |team| %> + + + + <% place = 0 %> + <% team.values.sort {|player1, player2| playerscores[player1] <=> playerscores[player2] }.each |player| %> + + <% place += 1%> + <% end %> + +
    Standings:<%= place.to_s + ":" %> <%= player.user_name %>
    +<% end %> \ No newline at end of file -- cgit v1.2.3