-
-
- - -
- Winner Pool 1 Score -
- -
- Winner Pool 4Score - -
- - -
- Winner Pool 3Score -
- -
- Winner Pool 2 Score - -
- -
-
-
- - -
- -
- -
- - -
- - - -
-
-
- - -
- - 1st - -
- - -
diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 9f2b06e..7a99334 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -37,7 +37,7 @@ class StaticPagesController < ApplicationController if params[:weight] @weight = Weight.find(params[:weight]) @tournament = Tournament.find(@weight.tournament_id) - @matches = @tournament.upcomingMatches + @matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id} @wrestlers = Wrestler.where(weight_id: @weight.id) @poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1} @poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2} diff --git a/app/models/matchup.rb b/app/models/matchup.rb index c47e861..29f9e02 100644 --- a/app/models/matchup.rb +++ b/app/models/matchup.rb @@ -1,5 +1,5 @@ class Matchup - attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name + attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position def weight_max @weight = Weight.find(self.weight_id) diff --git a/app/models/poolbracket.rb b/app/models/poolbracket.rb new file mode 100644 index 0000000..49e4297 --- /dev/null +++ b/app/models/poolbracket.rb @@ -0,0 +1,53 @@ +class Poolbracket + attr_accessor :weight + + def generateBracketMatches(matches,weight,highest_round) + if weight.pool_bracket_type == "twoPoolsToSemi" + + elsif weight.pool_bracket_type == "twoPoolToFinal" + + elsif weight.pool_bracket_type == "fourPoolsToQuarter" + + elsif weight.pool_bracket_type == "fourPoolsToSemi" + matches = fourPoolsToSemi(matches,weight,highest_round) + end + return matches + end + + def fourPoolsToSemi(matches,weight,round) + @round = round + 1 + matches = createMatchup(matches,weight,@round,"Winner Pool 1","Winner Pool 4","Semis") + matches = createMatchup(matches,weight,@round,"Winner Pool 2","Winner Pool 3","Semis") + matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 4","Conso Semis") + matches = createMatchup(matches,weight,@round,"Runner Up Pool 2","Runner Up Pool 3","Conso Semis") + matches = assignBouts(matches) + @round = @round + 1 + @matches = matches.select{|m| m.weight_id == weight.id} + matches = createMatchup(matches,weight,@round,"","","1/2") + @match1 = @matches.select{|m| m.w1_name == "Winner Pool 1"}.first + @match2 = @matches.select{|m| m.w1_name == "Winner Pool 2"}.first + matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4") + matches = createMatchup(matches,weight,@round,"","","5/6") + @match1 = @matches.select{|m| m.w1_name == "Runner Up Pool 1"}.first + @match2 = @matches.select{|m| m.w1_name == "Runner Up Pool 2"}.first + matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","7/8") + return matches + end + + def createMatchup(matches,weight,round,w1_name,w2_name,bracket_position) + @match = Matchup.new + @match.w1_name = w1_name + @match.w2_name = w2_name + @match.weight_id = weight.id + @match.round = round + @match.bracket_position = bracket_position + matches << @match + return matches + end + + def assignBouts(matches) + @bouts = Bout.new + @matches = @bouts.assignBouts(matches) + return @matches + end +end \ No newline at end of file diff --git a/app/models/weight.rb b/app/models/weight.rb index 79c479b..8b379be 100644 --- a/app/models/weight.rb +++ b/app/models/weight.rb @@ -97,13 +97,17 @@ class Weight < ActiveRecord::Base elsif self.wrestlers.size > 11 && self.wrestlers.size <= 16 return "fourPoolsToSemi" end - self.wrestlers.size end def generateMatchups(matches) @wrestlers = self.wrestlers @pool = Pool.new @matches = @pool.generatePools(self.pools,@wrestlers,self,self.tournament_id,matches) + @weight_matches = @matches.select{|m|m.weight_id == self.id} + @last_match = @weight_matches.sort_by{|m| m.round}.last + @highest_round = @last_match.round + @bracket = Poolbracket.new + @matches = @bracket.generateBracketMatches(@matches,self,@highest_round) return @matches end diff --git a/app/views/static_pages/_fourPoolBracket.html.erb b/app/views/static_pages/_fourPoolBracket.html.erb index 59775d4..6b25baf 100644 --- a/app/views/static_pages/_fourPoolBracket.html.erb +++ b/app/views/static_pages/_fourPoolBracket.html.erb @@ -1,185 +1,192 @@ - - - -