diff options
author | nfoy <nfoy@purdue.edu> | 2014-04-27 19:12:07 -0400 |
---|---|---|
committer | nfoy <nfoy@purdue.edu> | 2014-04-27 19:12:07 -0400 |
commit | 95542d38ddae5700e7fa35c166260a51ce17e46a (patch) | |
tree | 3ed1b9fcb793a426901586367dc5212819e9bff5 /lib/scheduling | |
parent | 07dbbeb404dedcf9733262ae2ce9cdddc086bb0e (diff) | |
parent | 8b1e26bf00c7e536def47ae4ef3441192f154aa8 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'lib/scheduling')
-rw-r--r-- | lib/scheduling/README.md | 19 | ||||
-rw-r--r-- | lib/scheduling/round_robin.rb | 8 |
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/scheduling/README.md b/lib/scheduling/README.md index 173b7be..8b21164 100644 --- a/lib/scheduling/README.md +++ b/lib/scheduling/README.md @@ -1,13 +1,22 @@ -Files in this directory should implement the following interface: +Scheduling interface +==================== + +Files in this directory should be _classes_ implementing the following +interface: - `initialize(tournament_stage)` - construct new Scheduling object from tournament_stage + + Construct new Scheduling object from tournament_stage. - `create_matches` - creates all the matches of the current round + + Creates all the matches of the current round. - `finish_match(match)` - progresses the match through the schedule + + Progresses the match through the schedule. - `graph` - returns a string representation of an svg image of the current stage
\ No newline at end of file + + Returns a string representation of an svg image of the current + stage. diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb index 7a9e257..1d9ac0d 100644 --- a/lib/scheduling/round_robin.rb +++ b/lib/scheduling/round_robin.rb @@ -7,11 +7,15 @@ module Scheduling end def create_matches + #number of teams*number of teams per match = number of matches per round num_teams = (tournament.players.count/tournament.min_players_per_team).floor - num_matches = Float(num_teams/2)*(num_teams-1) - for i in 1..num_matches + @matches_per_round = num_teams * tournament.min_teams_per_match + + @matches_per_round.each do |match| tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end + + tournament_stage.seeding.seed_matches(tournament_stage) end def finish_match(match) |