From b4bc055585dee532653a8c64e45385e085ec22a8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 22 Apr 2014 18:29:17 -0400 Subject: I hate code --- lib/scheduling/elimination.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb index e718d54..5ce71ca 100644 --- a/lib/scheduling/elimination.rb +++ b/lib/scheduling/elimination.rb @@ -1,5 +1,7 @@ + module Scheduling class Elimination + include Rails.application.routes.url_helpers def initialize(tournament_stage) @tournament_stage = tournament_stage @@ -21,9 +23,9 @@ module Scheduling match_num = num_matches-1 team_num = 0 # for each grouping of min_players_per_team - self.tournament.players.each_slice(min_players_per_team) do |team_members| + self.tournament.players.each_slice(self.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 == min_teams_per_match) + if (team_num == self.tournament.min_teams_per_match) match_num -= 1 team_num = 0 else @@ -42,7 +44,7 @@ module Scheduling end end - def graph + def graph(current_user) matches = @tournament_stage.matches_ordered # depth of SVG tree depth = Math.log2(matches.count).floor+1; @@ -71,7 +73,7 @@ STRING rx = 50/(depth+1) + 100/(depth+1)*(depth-(Math.log2(i).floor+1)) ry = ( 100/(2**(Math.log2(i).floor)+1) + rh * 1.1 * (2**Math.log2(i).ceil-i)) - str += "\t\n" + str += "\t\n" str += "\t\t\n" if matches[i].teams.first - str += '\t\tTeam #{matches[i].teams.first.id}\n' + str += "\t\tTeam #{matches[i].teams.first.id}\n" end str += "\t\t VS \n" @@ -113,7 +115,7 @@ STRING lastrh = rh lastrw = rw end - str += "\n" + str += "\n" end str += '' -- cgit v1.2.3-54-g00ecf