diff options
author | nfoy <nfoy@purdue.edu> | 2014-04-24 19:03:41 -0400 |
---|---|---|
committer | nfoy <nfoy@purdue.edu> | 2014-04-24 19:03:41 -0400 |
commit | 1b11684986136ee87da6242c3ba6aba5ef581510 (patch) | |
tree | d7ec999baced4836a9b3b7b31eee39cfe09410c9 | |
parent | 9823642115ef52f0a21b9466cef412098a124f3d (diff) | |
parent | db073045ff7cf5d8a2fb4a3349ed6a9a6ac019d3 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r-- | app/assets/stylesheets/custom.css.scss | 3 | ||||
-rw-r--r-- | app/assets/stylesheets/matches.css.scss | 15 | ||||
-rw-r--r-- | app/controllers/matches_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/tournaments_controller.rb | 4 | ||||
-rw-r--r-- | app/models/api_request.rb | 2 | ||||
-rw-r--r-- | app/models/api_requests.rb | 2 | ||||
-rw-r--r-- | app/models/tournament.rb | 12 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 7 | ||||
-rwxr-xr-x | db.sh | 2 | ||||
-rw-r--r-- | db/migrate/20140424162546_create_simple_captcha_data.rb (renamed from db/migrate/20140423214420_create_simple_captcha_data.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202545_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140424014421_add_attachments.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202549_create_delayed_jobs.rb (renamed from db/migrate/20140424014424_create_delayed_jobs.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202553_create_servers.rb (renamed from db/migrate/20140424014425_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202557_create_matches.rb (renamed from db/migrate/20140424014426_create_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202600_create_teams.rb (renamed from db/migrate/20140424014427_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202604_create_alerts.rb (renamed from db/migrate/20140424014428_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202608_create_pms.rb (renamed from db/migrate/20140424014429_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202611_create_tournaments.rb (renamed from db/migrate/20140424014431_create_tournaments.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202615_create_games.rb (renamed from db/migrate/20140424014433_create_games.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202619_create_users.rb (renamed from db/migrate/20140424014434_create_users.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202623_create_sessions.rb (renamed from db/migrate/20140424014436_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202626_create_brackets.rb (renamed from db/migrate/20140424014437_create_brackets.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202630_create_game_settings.rb (renamed from db/migrate/20140424014439_create_game_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202634_create_tournament_settings.rb (renamed from db/migrate/20140424014440_create_tournament_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202638_create_tournament_stages.rb (renamed from db/migrate/20140424014442_create_tournament_stages.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202641_create_statistics.rb (renamed from db/migrate/20140424014443_create_statistics.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202645_create_remote_usernames.rb (renamed from db/migrate/20140424014445_create_remote_usernames.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202649_create_bracket_matches.rb (renamed from db/migrate/20140424014446_create_bracket_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202652_create_api_requests.rb (renamed from db/migrate/20140424014448_create_api_requests.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202656_create_tournament_players_join_table.rb (renamed from db/migrate/20140424014449_create_tournament_players_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202659_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140424014451_create_tournament_hosts_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202703_create_team_user_join_table.rb (renamed from db/migrate/20140424014452_create_team_user_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202706_create_match_team_join_table.rb (renamed from db/migrate/20140424014454_create_match_team_join_table.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140424202717_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140424014459_add_hidden_attrs_to_user.rb) | 0 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | db/seeds.rb | 100 | ||||
-rwxr-xr-x | generate.sh | 2 | ||||
-rw-r--r-- | lib/scheduling/elimination.rb | 60 | ||||
-rw-r--r-- | test/models/api_request_test.rb (renamed from test/models/api_requests_test.rb) | 2 |
44 files changed, 153 insertions, 64 deletions
diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index 4104235..b456893 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -36,13 +36,14 @@ a, input[type="submit"] { } -input[type="text"], input[type="password"]{ +input[type="text"], input[type="password"], textarea{ -webkit-box-shadow: inset 0 0 8px rgba(0,0,0,0.1), 0 0 16px rgba(0,0,0,0.1); -moz-box-shadow: inset 0 0 8px rgba(0,0,0,0.1), 0 0 16px rgba(0,0,0,0.1); box-shadow: inset 0 0 8px rgba(0,0,0,0.1), 0 0 16px rgba(0,0,0,0.1); border: 3px inset #A5A5A5; padding: 8px; + color: $orange !important; background: rgba(0,0,0,0.5); margin: 0 0 5px 0; } diff --git a/app/assets/stylesheets/matches.css.scss b/app/assets/stylesheets/matches.css.scss index 66da68e..ee43ab4 100644 --- a/app/assets/stylesheets/matches.css.scss +++ b/app/assets/stylesheets/matches.css.scss @@ -51,4 +51,19 @@ form { color: #333; } +} + +svg { + min-width: 600px; +} + +@media (max-width: 900px) { + svg text { + font-size: 200%; + } +} +@media (max-width: 700px) { + svg text { + font-size: 150%; + } }
\ No newline at end of file diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 1ad86d0..138cf28 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -23,8 +23,8 @@ class MatchesController < ApplicationController @match.teams.each do |team| team.users.each do |user| - players_id.push(user.remote_usernames[0]["json_value"]["id"]) - players.push(user.remote_usernames[0]["json_value"]["id"]) + players_id.push(user.remote_usernames[0].value["id"]) + players.push(user.remote_usernames[0].value["name"]) end end diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index ebc54c1..1354ad6 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -116,8 +116,8 @@ class TournamentsController < ApplicationController success = true ActiveRecord::Base.transaction do success &= @tournament.save && - success &= @tournament.tournament_stages.create(scheduling: "elimination") - success &= @tournament.tournament_stages.first.create_matches + success &= @tournament.stages.create(scheduling: "elimination") + success &= @tournament.stages.first.create_matches end if success format.html { redirect_to @tournament, notice: 'You have started this tournament.' } diff --git a/app/models/api_request.rb b/app/models/api_request.rb new file mode 100644 index 0000000..ffb7267 --- /dev/null +++ b/app/models/api_request.rb @@ -0,0 +1,2 @@ +class ApiRequest < ActiveRecord::Base +end diff --git a/app/models/api_requests.rb b/app/models/api_requests.rb deleted file mode 100644 index 19c76e2..0000000 --- a/app/models/api_requests.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ApiRequests < ActiveRecord::Base -end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index e21ccb1..861be6c 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,20 +1,10 @@ class Tournament < ActiveRecord::Base belongs_to :game - has_many :tournament_stages + has_many :stages, class_name: "TournamentStage" has_many :settings_raw, class_name: "TournamentSetting" 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" - def stages_ordered - h = {} - i = 1 - self.tournament_stages.order(:id).each do |s| - h[i] = s - i += 1 - end - return h - end - def settings @settings ||= Settings.new(self) end diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 8a50fee..784d7db 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -12,8 +12,7 @@ </tr> </thead> <tbody> - <% @tournament.stages_ordered.keys.sort.each do |stage_key| %> - <% stage = @tournament.stages_ordered[stage_key] %> + <% @tournament.stages.order(:id).each do |stage| %> <% stage.matches_ordered.keys.sort.reverse.each do |match_key| %><tr> <% match = stage.matches_ordered[match_key] %> <td><%= "Match #{match.id}" %></td> @@ -36,6 +35,6 @@ <br> -<% @tournament.stages_ordered.keys.sort.each do |stage_key| %> - <div class="graph"><%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %></div> +<% @tournament.stages.order(:id).each do |stage| %> + <div class="graph"><%= raw stage.to_svg(current_user) %></div> <% end %> @@ -0,0 +1,2 @@ +#!/bin/bash +bundle exec rake db:drop && bundle exec rake db:migrate && bundle exec rake db:seed diff --git a/db/migrate/20140423214420_create_simple_captcha_data.rb b/db/migrate/20140424162546_create_simple_captcha_data.rb index 4573b20..4573b20 100644 --- a/db/migrate/20140423214420_create_simple_captcha_data.rb +++ b/db/migrate/20140424162546_create_simple_captcha_data.rb diff --git a/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb index 690cec2..690cec2 100644 --- a/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb +++ b/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb diff --git a/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb b/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb index 7f41ac6..7f41ac6 100644 --- a/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb +++ b/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb diff --git a/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb b/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb index 04c12ef..04c12ef 100644 --- a/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb +++ b/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb diff --git a/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb b/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb index b8d6588..b8d6588 100644 --- a/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb +++ b/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb diff --git a/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb index 9ce904f..9ce904f 100644 --- a/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb +++ b/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb diff --git a/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb index 60f67ab..60f67ab 100644 --- a/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb +++ b/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb diff --git a/db/migrate/20140424014424_create_delayed_jobs.rb b/db/migrate/20140424202549_create_delayed_jobs.rb index ec0dd93..ec0dd93 100644 --- a/db/migrate/20140424014424_create_delayed_jobs.rb +++ b/db/migrate/20140424202549_create_delayed_jobs.rb diff --git a/db/migrate/20140424014425_create_servers.rb b/db/migrate/20140424202553_create_servers.rb index fbe1b02..fbe1b02 100644 --- a/db/migrate/20140424014425_create_servers.rb +++ b/db/migrate/20140424202553_create_servers.rb diff --git a/db/migrate/20140424014426_create_matches.rb b/db/migrate/20140424202557_create_matches.rb index bac92d1..bac92d1 100644 --- a/db/migrate/20140424014426_create_matches.rb +++ b/db/migrate/20140424202557_create_matches.rb diff --git a/db/migrate/20140424014427_create_teams.rb b/db/migrate/20140424202600_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140424014427_create_teams.rb +++ b/db/migrate/20140424202600_create_teams.rb diff --git a/db/migrate/20140424014428_create_alerts.rb b/db/migrate/20140424202604_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140424014428_create_alerts.rb +++ b/db/migrate/20140424202604_create_alerts.rb diff --git a/db/migrate/20140424014429_create_pms.rb b/db/migrate/20140424202608_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140424014429_create_pms.rb +++ b/db/migrate/20140424202608_create_pms.rb diff --git a/db/migrate/20140424014431_create_tournaments.rb b/db/migrate/20140424202611_create_tournaments.rb index 716871f..716871f 100644 --- a/db/migrate/20140424014431_create_tournaments.rb +++ b/db/migrate/20140424202611_create_tournaments.rb diff --git a/db/migrate/20140424014433_create_games.rb b/db/migrate/20140424202615_create_games.rb index 23edf0b..23edf0b 100644 --- a/db/migrate/20140424014433_create_games.rb +++ b/db/migrate/20140424202615_create_games.rb diff --git a/db/migrate/20140424014434_create_users.rb b/db/migrate/20140424202619_create_users.rb index 8032870..8032870 100644 --- a/db/migrate/20140424014434_create_users.rb +++ b/db/migrate/20140424202619_create_users.rb diff --git a/db/migrate/20140424014436_create_sessions.rb b/db/migrate/20140424202623_create_sessions.rb index f667f1e..f667f1e 100644 --- a/db/migrate/20140424014436_create_sessions.rb +++ b/db/migrate/20140424202623_create_sessions.rb diff --git a/db/migrate/20140424014437_create_brackets.rb b/db/migrate/20140424202626_create_brackets.rb index 8813bf2..8813bf2 100644 --- a/db/migrate/20140424014437_create_brackets.rb +++ b/db/migrate/20140424202626_create_brackets.rb diff --git a/db/migrate/20140424014439_create_game_settings.rb b/db/migrate/20140424202630_create_game_settings.rb index 06fb72e..06fb72e 100644 --- a/db/migrate/20140424014439_create_game_settings.rb +++ b/db/migrate/20140424202630_create_game_settings.rb diff --git a/db/migrate/20140424014440_create_tournament_settings.rb b/db/migrate/20140424202634_create_tournament_settings.rb index e56697f..e56697f 100644 --- a/db/migrate/20140424014440_create_tournament_settings.rb +++ b/db/migrate/20140424202634_create_tournament_settings.rb diff --git a/db/migrate/20140424014442_create_tournament_stages.rb b/db/migrate/20140424202638_create_tournament_stages.rb index e3668cb..e3668cb 100644 --- a/db/migrate/20140424014442_create_tournament_stages.rb +++ b/db/migrate/20140424202638_create_tournament_stages.rb diff --git a/db/migrate/20140424014443_create_statistics.rb b/db/migrate/20140424202641_create_statistics.rb index cc2e97d..cc2e97d 100644 --- a/db/migrate/20140424014443_create_statistics.rb +++ b/db/migrate/20140424202641_create_statistics.rb diff --git a/db/migrate/20140424014445_create_remote_usernames.rb b/db/migrate/20140424202645_create_remote_usernames.rb index e265985..e265985 100644 --- a/db/migrate/20140424014445_create_remote_usernames.rb +++ b/db/migrate/20140424202645_create_remote_usernames.rb diff --git a/db/migrate/20140424014446_create_bracket_matches.rb b/db/migrate/20140424202649_create_bracket_matches.rb index 3323e31..3323e31 100644 --- a/db/migrate/20140424014446_create_bracket_matches.rb +++ b/db/migrate/20140424202649_create_bracket_matches.rb diff --git a/db/migrate/20140424014448_create_api_requests.rb b/db/migrate/20140424202652_create_api_requests.rb index 544c330..544c330 100644 --- a/db/migrate/20140424014448_create_api_requests.rb +++ b/db/migrate/20140424202652_create_api_requests.rb diff --git a/db/migrate/20140424014449_create_tournament_players_join_table.rb b/db/migrate/20140424202656_create_tournament_players_join_table.rb index be240e8..be240e8 100644 --- a/db/migrate/20140424014449_create_tournament_players_join_table.rb +++ b/db/migrate/20140424202656_create_tournament_players_join_table.rb diff --git a/db/migrate/20140424014451_create_tournament_hosts_join_table.rb b/db/migrate/20140424202659_create_tournament_hosts_join_table.rb index 7521d89..7521d89 100644 --- a/db/migrate/20140424014451_create_tournament_hosts_join_table.rb +++ b/db/migrate/20140424202659_create_tournament_hosts_join_table.rb diff --git a/db/migrate/20140424014452_create_team_user_join_table.rb b/db/migrate/20140424202703_create_team_user_join_table.rb index f3b57fc..f3b57fc 100644 --- a/db/migrate/20140424014452_create_team_user_join_table.rb +++ b/db/migrate/20140424202703_create_team_user_join_table.rb diff --git a/db/migrate/20140424014454_create_match_team_join_table.rb b/db/migrate/20140424202706_create_match_team_join_table.rb index c2ed1b7..c2ed1b7 100644 --- a/db/migrate/20140424014454_create_match_team_join_table.rb +++ b/db/migrate/20140424202706_create_match_team_join_table.rb diff --git a/db/migrate/20140424014459_add_hidden_attrs_to_user.rb b/db/migrate/20140424202717_add_hidden_attrs_to_user.rb index 9b5c505..9b5c505 100644 --- a/db/migrate/20140424014459_add_hidden_attrs_to_user.rb +++ b/db/migrate/20140424202717_add_hidden_attrs_to_user.rb diff --git a/db/schema.rb b/db/schema.rb index 0e9202a..0833263 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140424014459) do +ActiveRecord::Schema.define(version: 20140424202717) do create_table "alerts", force: true do |t| t.integer "author_id" diff --git a/db/seeds.rb b/db/seeds.rb index 7b8709c..61cf44a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -16,18 +16,32 @@ Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_ 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: 2) -Game.find_by_name("Rock, Paper, Scissors").settings.create(name: "Lizard, Spock allowed?", description: "Will you allow Lizard and Spock?", vartype: 4, display_order: 1) -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: 3) +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) if Rails.env.development? + #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 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") @@ -39,14 +53,74 @@ 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") - User.create(name: "Sytrie", password: "password", email: "Sytrie@gmail.com", user_name: "Sytrie", password_confirmation: "password") - User.create(name: "Derpanator115", password: "password", email: "Derpanator115@gmail.com", user_name: "Derpanator115", password_confirmation: "password") - User.create(name: "Wlknexe56", password: "password", email: "Wlknexe56@gmail.com", user_name: "Wlknexe56", password_confirmation: "password") - User.create(name: "DVisionzz", password: "password", email: "DVisionzz@gmail.com", user_name: "DVisionzz", password_confirmation: "password") - User.create(name: "HYP3RTONIC", password: "password", email: "HYP3RTONIC@gmail.com", user_name: "HYP3RTONIC", password_confirmation: "password") - User.create(name: "M9Fumjaa", password: "password", email: "M9Fumjaa@gmail.com", user_name: "M9Fumjaa", password_confirmation: "password") - User.create(name: "spikevsnaruto", password: "password", email: "spikevsnaruto@gmail.com", user_name: "spikevsnaruto", password_confirmation: "password") - User.create(name: "GoogleMaSkills", password: "password", email: "GoogleMaSkills@gmail.com", user_name: "GoogleMaSkills", password_confirmation: "password") - User.create(name: "james chamberlan", password: "password", email: "james chamberlan@gmail.com", user_name: "james chamberlan", password_confirmation: "password") - User.create(name: "Kaceytron", password: "password", email: "Kaceytron@gmail.com", user_name: "Kaceytron", password_confirmation: "password") + 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: "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 + 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, set_rounds: 1, randomized_teams: true, sampling_method: nil) + + #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]) + 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, set_rounds: 1, randomized_teams: true, sampling_method: nil) + + 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, set_rounds: 1, randomized_teams: true, sampling_method: nil) + + 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, set_rounds: 1, randomized_teams: true, sampling_method: nil) + + for i in 0..9 + if i == 0 + tourn5.hosts.push(players_for_league[i]) + end + tourn5.join(players_for_league[i]) + end + tourn5.join(players_for_league[9]) + end diff --git a/generate.sh b/generate.sh index 8e29384..be2e1a1 100755 --- a/generate.sh +++ b/generate.sh @@ -61,7 +61,7 @@ bundle exec rails generate model remote_username game:references user:references bundle exec rails generate model bracket_match bracket:references match:references predicted_winner:references -bundle exec rails generate model api_requests api_name:string +bundle exec rails generate model api_request api_name:string # Join tables bundle exec rails generate migration CreateTournamentPlayersJoinTable players tournaments diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb index 1ac696d..cf0d625 100644 --- a/lib/scheduling/elimination.rb +++ b/lib/scheduling/elimination.rb @@ -17,7 +17,7 @@ module Scheduling def create_matches num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor - num_matches = num_teams - 1 + num_matches = (Float(num_teams - tournament.min_teams_per_match)/(tournament.min_teams_per_match - 1)).ceil + 1 for i in 1..num_matches self.tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end @@ -32,7 +32,7 @@ module Scheduling # if the match is full, move to the next match, otherwise move to the next team if (team_num == self.tournament.min_teams_per_match) match_num -= 1 - team_num = 0 + team_num = 1 else team_num += 1 end @@ -51,10 +51,16 @@ module Scheduling def graph(current_user) matches = @tournament_stage.matches_ordered + numTeams = @tournament_stage.tournament.min_teams_per_match + logBase = numTeams + # depth of SVG tree - depth = Math.log2(matches.count).floor+1; + depth = Math.log(matches.count*(logBase-1),logBase).floor+1; + # height of SVG - height = [200 * 2**Math.log2(matches.count).floor + 100, 500].max; + matchHeight = 50*logBase; + height = [(matchHeight+50) * logBase**(depth-1) + 100, 500].max; + lastrx = 0 lastry = 0 lastrh = 0 @@ -73,10 +79,12 @@ module Scheduling </defs> STRING (1..matches.count).each do |i| - rh = 100/(2**(depth-1)+1) - 5 + matchDepth = Math.log(i*(logBase-1), logBase).floor+1 + base = (logBase**(matchDepth-1)/(logBase-1)).ceil + rh = 100 / (logBase**(depth-1)+1) - 100/height; rw = 100/(depth+1) - 5 - rx = 50/(depth+1) + 100/(depth+1)*(depth-(Math.log2(i).floor+1)) - ry = ( 100/(2**(Math.log2(i).floor)+1) + rh * 1.1 * (2**Math.log2(i).ceil-i)) + rx = 50/(depth+1) + 100/(depth+1)*(depth-matchDepth) + ry = 100/(logBase**(matchDepth-1)+1) * (i-base+1) - rh/2 str += "\t<a id=\"svg-match-#{i}\" xlink:href=\"#{match_path(matches[i])}\"><g>\n" str += "\t\t<rect height=\"#{rh}%\" width=\"#{rw}%\" x=\"#{rx}%\" y=\"#{ry}%\" fill=\"url(#gradMatch)\" rx=\"5px\" stroke-width=\"2\"" @@ -95,30 +103,29 @@ STRING when 3 str += ' stroke="grey"' end - str += "/>\n" - color = (matches[i].teams[0] and matches[i].teams[0].users.include?(current_user)) ? "#BCED91" : "white" - str += "\t\t<rect width=\"#{rw-5}%\" height=\"#{rh/4}%\" x=\"#{rx + 2.5}%\" y=\"#{ry + rh/6}%\" fill=\"#{color}\" />\n" - if matches[i].teams.first - str += "\t\t<text x=\"#{rx + rw/4}%\" y=\"#{ry + rh/3}%\" font-size=\"#{rh}\">Team #{matches[i].teams.first.id}</text>\n" - end - - str += "\t\t<text x=\"#{rx + 1.3*rw/3}%\" y=\"#{ry + 5.2*rh/9}%\" font-size=\"#{rh}\"> VS </text>\n" + str += "/>\n" - color = (matches[i].teams[1] and matches[i].teams[1].users.include?(current_user)) ? "#BCED91" : "white" - str += "\t\t<rect width=\"#{rw-5}%\" height=\"#{rh/4}%\" x=\"#{rx + 2.5}%\" y=\"#{ry + 3*rh/5}%\" fill=\"#{color}\" />\n" - if matches[i].teams[1] - str += "\t\t<text x=\"#{rx + rw/4}%\" y=\"#{ry + 4*rh/5}%\" font-size=\"#{rh}\">Team #{matches[i].teams[1].id}</text>\n" + t = 1 + while t <= numTeams + color = (matches[i].teams[t-1] and matches[i].teams[t-1].users.include?(current_user)) ? "#5BC0DE" : "white" + str += "\t\t<rect width=\"#{rw-5}%\" height=\"#{rh*Float(30)/(matchHeight)}%\" x=\"#{rx + 2.5}%\" y=\"#{ry + (Float(t-1)/numTeams)*rh + 2 }%\" fill=\"#{color}\" />\n" + if matches[i].teams[t-1] + str += "\t\t<text x=\"#{rx + rw/4}%\" y=\"#{ry + (Float(t-1)/numTeams + Float(30)/(matchHeight))*rh}%\" font-size=\"#{rh}\">Team #{matches[i].teams[t-1].id}</text>\n" + end + if (t < numTeams) + str += "\t\t<text x=\"#{rx + 1.3*rw/3}%\" y=\"#{ry + (Float(20+35*(t))/matchHeight)*rh}%\" font-size=\"#{rh}\"> VS </text>\n" + end + t = t + 1 end if i > 1 - str += "\t\t<line x1=\"#{rx+rw}%\" y1=\"#{ry+rh/2}%\" x2=\"#{lastrx}%\" y2=\"#{lastry+lastrh/2}%\" stroke=\"black\" stroke-width=\"2\" >\n" - end - if Math.log2(i+1) == Math.log2(i+1).ceil - lastrx = rx - lastry = ry - lastrh = rh - lastrw = rw + parent = (i+logBase-2)/logBase + pDepth = Math.log(parent*(logBase-1), logBase).floor+1 + pBase = (logBase**(pDepth-1)/(logBase-1)).ceil + lastrx = 50/(depth+1) + 100/(depth+1)*(depth-pDepth) + lastry = 100/(logBase**(pDepth-1)+1) * (parent-pBase+1) - rh/2 + str += "\t\t<line x1=\"#{rx+rw}%\" y1=\"#{ry+rh/2}%\" x2=\"#{lastrx}%\" y2=\"#{lastry+rh/2}%\" stroke=\"white\" stroke-width=\"2\" >\n" end str += "</g></a>\n" end @@ -126,5 +133,6 @@ STRING return str end + end end diff --git a/test/models/api_requests_test.rb b/test/models/api_request_test.rb index 18763a7..ea37ce4 100644 --- a/test/models/api_requests_test.rb +++ b/test/models/api_request_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ApiRequestsTest < ActiveSupport::TestCase +class ApiRequestTest < ActiveSupport::TestCase # test "the truth" do # assert true # end |