From 8f19c2d5d32681601a63df291f04a90b6786e1cf Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Sat, 26 Apr 2014 18:20:26 -0400 Subject: Added some meat to roundrobin.rb --- lib/scheduling/elimination.rb | 1 + lib/scheduling/roundrobin.rb | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb index bf752b6..074cb5c 100644 --- a/lib/scheduling/elimination.rb +++ b/lib/scheduling/elimination.rb @@ -34,6 +34,7 @@ module Scheduling end def match_finished(match) + #what in the goddamn fuck does this mean matches = match.tournament_stage.matches_ordered cur_match_num = matches.invert[match] unless cur_match_num == 1 diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb index e2db2cf..d023cfb 100644 --- a/lib/scheduling/roundrobin.rb +++ b/lib/scheduling/roundrobin.rb @@ -8,34 +8,53 @@ module Scheduling def create_matches num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor - num_matches = (num_teams* Float(num_teams-1)/2).ceil + num_matches = Float(num_teams/2)*(num_teams-1) + end - #round robin should look like this + def create_round_array + #round robin should look like this. + #NOTE: I DO NOT KNOW IF THIS IS HOW TO PROPERLY POPULATE THE ROUND ROBIN ARRAY WITH TEAMS @team_pairs = Array.new(num_matches) for i in 0..@match.teams.size @team_pairs.push(@match.teams[i]) + #if there is an odd number of teams, add a dummy for byes + if @match.teams.size % 2 != 0 && i == @match.teams.size-1 + dummy = Team.create + @team_pairs.push(dummy) + end 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 + #remove first team hold = @team_pairs.shift + #rotate by 1 element @team_pairs.rotate! + #place first team the front of the array @team_pairs.unshift(hold) - # for j in 0..4 - # puts "#{array[j]}, #{array[j+(array.size/2)-1]}" - # end - # puts "\n\n" + + end + def mother_fuckin_winner + scores = {} + @teams_pairs.each do |team| + scores[team] = team.matches. + where(:tournament_stage => tournament_stage). + collect{|match|match.winner==team} + end + weiner = scores.index(scores.max) + scores[weiner] end def match_finished(match) - + #declare winner of match, and store that somehow + rotate + return "totes worked\n" end def graph(current_user) - + end end end -- cgit v1.2.3-54-g00ecf From 4035c852212671627a000cda7c1f8439b47a70d5 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Sat, 26 Apr 2014 18:23:53 -0400 Subject: Removed the self.tourn from roundrobin.rb. Also, last time we meant meat as in weiners. Super fat ones. Also Luke gave Davis and I some broken ass code. --- lib/scheduling/roundrobin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb index d023cfb..fbb291e 100644 --- a/lib/scheduling/roundrobin.rb +++ b/lib/scheduling/roundrobin.rb @@ -7,7 +7,7 @@ module Scheduling end def create_matches - num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor + num_teams = (tournament.players.count/tournament.min_players_per_team).floor num_matches = Float(num_teams/2)*(num_teams-1) end -- cgit v1.2.3-54-g00ecf From 78df502c74525cee987e551fc82e91595e63ed01 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Sat, 26 Apr 2014 18:26:43 -0400 Subject: Added match creation to roundrobin.rb. Also Luke did not give us broken ass code, sorry for the last message Luke. --- lib/scheduling/roundrobin.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb index fbb291e..e149860 100644 --- a/lib/scheduling/roundrobin.rb +++ b/lib/scheduling/roundrobin.rb @@ -9,6 +9,9 @@ module Scheduling def create_matches 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 + tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) + end end def create_round_array -- cgit v1.2.3-54-g00ecf