summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-27 20:39:17 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-27 20:39:17 -0400
commitfbdb313c53b836deb1b4151169b32656fd1f70da (patch)
treea2444e326d7a737ee5c8bbcd149afa16481796de /lib
parentc87dbe49d521683900c20a9425a96467fa631489 (diff)
parent9d0be853cef35412c0bfe92c80502fd9da7947f1 (diff)
Merge branch 'master' of http://github.com/LukeShu/leaguer
Diffstat (limited to 'lib')
-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
4 files changed, 23 insertions, 18 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).
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