summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/tournaments_controller.rb17
-rw-r--r--app/models/game.rb4
-rw-r--r--app/models/tournament.rb24
-rw-r--r--app/views/tournaments/_form.html.erb25
-rw-r--r--db/seeds.rb90
-rw-r--r--lib/seeding/README.md13
-rw-r--r--lib/seeding/early_bird_seeding.rb6
-rw-r--r--lib/seeding/fair_ranked_seeding.rb16
-rw-r--r--lib/seeding/random_seeding.rb6
9 files changed, 104 insertions, 97 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 @@
<p>
<%= 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") %>
</p>
<% if @tournament.game.nil? %>
@@ -50,32 +50,31 @@
<fieldset><legend>Settings</legend>
<%= f.fields_for :settings do |setting_fields| %>
- <% (@tournament.settings.empty? ? @tournament.game.settings : @tournament.settings).each do |setting| %><p>
- <% name = setting.name.parameterize.underscore %>
- <%= setting_fields.label name %>
+ <% @tournament.tournament_settings.each do |setting| %><p>
+ <%= setting_fields.label setting.name %>
<br>
<% 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 %>
<ul>
<% setting.type_opt.split(',').each do |option|%>
- <li><label><%= setting_fields.radio_button( name, option ) %><%= option %></label></li>
+ <li><label><%= setting_fields.radio_button( setting.name, option ) %><%= option.humanize %></label></li>
<% end %>
</ul>
<% when 3 %>
<ul>
<% setting.type_opt.split(',').each do |option|%>
- <li><label><%= check_box_tag(name, value = option, checked = false, options = {}) %><%= option %></label></li>
+ <li><label><%= check_box_tag("tournament[settings][#{setting.name}][]", option, setting.value.split(',').include?(option)) %><%= option.humanize %></label></li>
<% end %>
</ul>
<% 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 %>
</p><% end %>
<% end %>
@@ -83,8 +82,8 @@
<%= 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") %>
+ <input type="number" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>">
+ <%# 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| %><fieldset><legend>Stage <%= i %></legend>
<%= stage_fields.label :scheduling_method %>
diff --git a/db/seeds.rb b/db/seeds.rb
index f565815..c37dcf7 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: "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: "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: "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
@@ -56,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
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).
diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb
index cb24415..5c289ed 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 6531c43..6bc62ca 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
@@ -22,17 +22,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
@@ -40,4 +40,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 65979bc..36e06d6 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