summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-26 16:57:26 -0400
committertkimia <tkimia@purdue.edu>2014-04-26 16:57:26 -0400
commit59d8a08232ae7872e2777ac42756fa259e1d1f6f (patch)
tree7a6f6819ca4d3226f33017c22de1e55a65e1fd6c /lib
parentfedc51fb2d95d1e67c06e560448563a64fa458b1 (diff)
parent2aaaf29ae291edc34d0512ce9a812fc0de14f76b (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'lib')
-rw-r--r--lib/scheduling/elimination.rb17
-rw-r--r--lib/scheduling/roundrobin.rb41
-rw-r--r--lib/scoring/ScoringAlgorithm.rb6
3 files changed, 56 insertions, 8 deletions
diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb
index eedeb52..15c33ed 100644
--- a/lib/scheduling/elimination.rb
+++ b/lib/scheduling/elimination.rb
@@ -7,14 +7,6 @@ module Scheduling
@tournament_stage = tournament_stage
end
- def tournament_stage
- @tournament_stage
- end
-
- def tournament
- self.tournament_stage.tournament
- end
-
def create_matches
num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor
num_matches = (Float(num_teams - tournament.min_teams_per_match)/(tournament.min_teams_per_match - 1)).ceil + 1
@@ -138,5 +130,14 @@ STRING
return str
end
+ private
+
+ def tournament_stage
+ @tournament_stage
+ end
+
+ def tournament
+ self.tournament_stage.tournament
+ end
end
end
diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb
new file mode 100644
index 0000000..10af20e
--- /dev/null
+++ b/lib/scheduling/roundrobin.rb
@@ -0,0 +1,41 @@
+module Scheduling
+ class RoundRobin
+ include Rails.application.routes.url_helpers
+
+ def initialize(tournament_stage)
+ @tournament_stage = tournament_stage
+ end
+
+ def create_matches
+ num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor
+ num_matches = Float(num_teams/2)*(num_teams-1)
+
+ #round robin should look like this
+ @team_pairs = Array.new(num_matches)
+ for i in 0..@match.teams.size
+ @team_pairs.push(@match.teams[i]
+ end
+ #team_pairs needs populated with the team objects and im not sure how to do that
+ end
+
+ #this is called when a round has completed
+ def rotate
+ hold = @team_pairs.shift
+ @team_pairs.rotate!
+ @team_pairs.unshift(hold)
+ # for j in 0..4
+ # puts "#{array[j]}, #{array[j+(array.size/2)-1]}"
+ # end
+ # puts "\n\n"
+
+ end
+
+ def match_finished(match)
+
+ end
+
+ def graph(current_user)
+
+ end
+ end
+end
diff --git a/lib/scoring/ScoringAlgorithm.rb b/lib/scoring/ScoringAlgorithm.rb
new file mode 100644
index 0000000..f2afa6f
--- /dev/null
+++ b/lib/scoring/ScoringAlgorithm.rb
@@ -0,0 +1,6 @@
+module Scoring
+ class ScoringAlgorithm
+ def self.score(match, interface)
+ end
+ end
+end