summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-28 09:53:32 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-28 09:53:32 -0400
commitffa2652ec2b251818328e8927b112dde9e45de80 (patch)
tree4e91e6b8bad5786fe97fe25fe16568882dfa73a5
parente0feee503865ac797a2d5bf95f7c655c0289a329 (diff)
clean up db/seeds.rb
-rw-r--r--db/seeds.rb120
-rw-r--r--lib/scheduling/round_robin.rb1
2 files changed, 44 insertions, 77 deletions
diff --git a/db/seeds.rb b/db/seeds.rb
index ea0338d..c8b15d8 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -9,26 +9,26 @@
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 = 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)
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: "double_blind")
+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)
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: "double_blind")
+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)
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: "double_blind")
+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)
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
+ # User 1, the ADMIN
User.create(name: "Administrator", user_name: "admin", email: "root@localhost.lan", password: "password", password_confirmation: "password", permissions: 0xFFFFFFFF)
- #john doe's for testing
+ # John Doe's for testing
User.create(name: "John 0", password: "password", email: "john0@gmail.com", user_name: "johndoe0", password_confirmation: "password")
User.create(name: "John 1", password: "password", email: "john1@gmail.com", user_name: "johndoe1", password_confirmation: "password")
User.create(name: "John 2", password: "password", email: "john2@gmail.com", user_name: "johndoe2", password_confirmation: "password")
@@ -40,9 +40,8 @@ if Rails.env.development?
User.create(name: "John 8", password: "password", email: "john8@gmail.com", user_name: "johndoe8", password_confirmation: "password")
User.create(name: "John 9", password: "password", email: "john9@gmail.com", user_name: "johndoe9", password_confirmation: "password")
- players_for_league = Array.new
-
- #users for our fake seeded game from the yamls
+ # Users for mocked Riot API calls
+ players_for_league = []
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"))
@@ -54,7 +53,7 @@ if Rails.env.development?
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"))
- #semi-real users
+ # 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")
@@ -68,62 +67,58 @@ if Rails.env.development?
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: league, status: 0, name: "League of Legends Seed",
+ # League of Legends tournament
+ league_tourn = Tournament.create(game: league, 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
- if i == 0
- league_tourn.hosts.push(players_for_league[i])
- end
- league_tourn.join(players_for_league[i])
+ scoring_method: "TODO")
+ # TODO: create stages
+ league_tourn.hosts.push(User.find(1))
+ players_for_league.each do |player|
+ league_tourn.join(player)
end
- league_tourn.join(players_for_league[9])
-
- #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, sampling_method: "manual")
+ # Chess
+ chess_tourn = Tournament.create(game: chess, name: "Chess Seed",
+ min_players_per_team: 1, max_players_per_team: 1,
+ min_teams_per_match: 2, max_teams_per_match: 2,
+ scoring_method: "TODO")
+ # TODO: create stages
chess_tourn.hosts.push(davis)
chess_tourn.join(davis)
chess_tourn.join(foy)
- #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, sampling_method: "manual")
-
+ # Rock Paper Scissors
+ rps = Tournament.create(game: rockpaperscissors, 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,
+ scoring_method: "TODO")
rps.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding")
rps.hosts.push(davis)
rps.join(davis)
rps.join(foy)
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, sampling_method: "manual")
-
- for i in 0..9
- if i == 0
- tourn5.hosts.push(players_for_league[i])
- end
- tourn5.join(players_for_league[i])
+ # Another League tournament
+ tourn5 = Tournament.create(game_id: league, 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,
+ scoring_method: "TODO")
+ league_tourn.hosts.push(User.find(1))
+ players_for_league.each do |player|
+ tourn5.join(player)
end
tourn5.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding")
- 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, sampling_method: "manual")
- for i in 0..9
- if i == 0
- tourn6.hosts.push(players_for_league[i])
- end
- tourn6.join(players_for_league[i])
- end
+ # Yet another League tournament
+ tourn6 = Tournament.create(game_id: 1, 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,
+ scoring_method: "TODO")
tourn6.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding")
- tourn6.join(players_for_league[9])
+ players_for_league.each do |player|
+ tourn6.join(player)
+ end
tourn6.join(davis)
tourn6.join(foy)
tourn6.join(guntas)
@@ -132,33 +127,4 @@ if Rails.env.development?
tourn6.join(jordan)
tourn6.join(obama)
tourn6.join(joey)
-
-
-=begin
- hash1 = {:username => "TeslasMind", :id => id}
- hash2 = {:username => "Alpha142", :id => id}
- hash3 = {:username => "ImFromNasa", :id => id}
- hash4 = {:username => "NalfeinX", :id => id}
- hash5 = {:username => "GTBPhoenix", :id => id}
- hash6 = {:username => , :id => id}
- hash7 = {:username => username, :id => id}ages.first.create_matchesages.first.create_matches
-end
-if success
-format.html { redirect_to @tournament,
-end
-if success
-format.html { redirect_to @tournament,
- hash8 = {:username => username, :id => id}
- hash9 = {:username => username, :id => id}
- hash10 = {:username => username, :id => id}
-
-
-
-FOR ROUNG ROBIN
-
-http://stackoverflow.com/questions/6648512/scheduling-algorithm-for-a-round-robin-tournament
-
-
-=end
-
end
diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb
index a9defae..6185864 100644
--- a/lib/scheduling/round_robin.rb
+++ b/lib/scheduling/round_robin.rb
@@ -1,3 +1,4 @@
+# http://stackoverflow.com/questions/6648512/scheduling-algorithm-for-a-round-robin-tournament
module Scheduling
class RoundRobin
include Rails.application.routes.url_helpers