From 7de35332168374c176915cfeced61acc11f0ec8e Mon Sep 17 00:00:00 2001 From: tkimia Date: Thu, 24 Apr 2014 19:22:11 -0400 Subject: again, small changes --- lib/scheduling/elimination.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb index 0e93f7a..eedeb52 100644 --- a/lib/scheduling/elimination.rb +++ b/lib/scheduling/elimination.rb @@ -113,7 +113,7 @@ STRING t = 1 while t <= numTeams color = (matches[i].teams[t-1] and matches[i].teams[t-1].users.include?(current_user)) ? "#5BC0DE" : "white" - str += "\t\t\n" + str += "\t\t\n" if matches[i].teams[t-1] str += "\t\tTeam #{matches[i].teams[t-1].id}\n" end -- cgit v1.2.3-54-g00ecf From 78e9616e4e75fb030879e9fb8077d1ee68a67873 Mon Sep 17 00:00:00 2001 From: tkimia Date: Sat, 26 Apr 2014 17:27:46 -0400 Subject: SVG elimination is essentially finished --- lib/scheduling/elimination.rb | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb index 15c33ed..bf752b6 100644 --- a/lib/scheduling/elimination.rb +++ b/lib/scheduling/elimination.rb @@ -8,28 +8,28 @@ 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 - tournament.min_teams_per_match)/(tournament.min_teams_per_match - 1)).ceil + 1 for i in 1..num_matches - self.tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) + tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end match_num = num_matches-1 team_num = 0 - self.tournament.players.shuffle + tournament.players.shuffle # for each grouping of min_players_per_team - self.tournament.players.each_slice(self.tournament.min_players_per_team) do |team_members| + tournament.players.each_slice(tournament.min_players_per_team) do |team_members| # if the match is full, move to the next match, otherwise move to the next team - if (team_num == self.tournament.min_teams_per_match) + if (team_num == tournament.min_teams_per_match) match_num -= 1 team_num = 1 else team_num += 1 end # create a new team in the current match - self.tournament_stage.matches[match_num].teams.push(Team.create(users: team_members)) + tournament_stage.matches[match_num].teams.push(Team.create(users: team_members)) end end @@ -59,18 +59,20 @@ module Scheduling xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="#{height}"> - - - + + + STRING + base = 1 + pBase = 1 (1..matches.count).each do |i| matchDepth = Math.log(i*(logBase-1), logBase).floor+1 puts matchDepth - base = (logBase**(matchDepth-1)/(logBase-1)).ceil - if base == 0 - base = 1 + if matchDepth > Math.log(base*(logBase-1), logBase).floor+1 + pBase = base + base = i end puts base rh = 100 / (logBase**(depth-1)+1) - 100/height; @@ -107,7 +109,7 @@ STRING color = (matches[i].teams[t-1] and matches[i].teams[t-1].users.include?(current_user)) ? "#5BC0DE" : "white" str += "\t\t\n" if matches[i].teams[t-1] - str += "\t\tTeam #{matches[i].teams[t-1].id}\n" + str += "\t\tTeam #{matches[i].teams[t-1].id}\n" end if (t < numTeams) str += "\t\t VS \n" @@ -118,7 +120,6 @@ STRING if i > 1 parent = (i+logBase-2)/logBase pDepth = Math.log(parent*(logBase-1), logBase).floor+1 - pBase = (logBase**(pDepth-1)/(logBase-1)).ceil lastrx = 50/(depth+1) + 100/(depth+1)*(depth-pDepth) lastry = 100/(logBase**(pDepth-1)+1) * (parent-pBase+1) - rh/2 str += "\t\t\n" @@ -137,7 +138,7 @@ STRING end def tournament - self.tournament_stage.tournament + tournament_stage.tournament end end end -- cgit v1.2.3-54-g00ecf