1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Generate blank matchups for pool brackets

This commit is contained in:
2015-03-23 19:14:58 +00:00
parent b00d11a222
commit c1081ef64a
4 changed files with 69 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
class Matchup
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position, :bracket_position_number
def weight_max
@weight = Weight.find(self.weight_id)

View File

@@ -3,44 +3,98 @@ class Poolbracket
def generateBracketMatches(matches,weight,highest_round)
if weight.pool_bracket_type == "twoPoolsToSemi"
elsif weight.pool_bracket_type == "twoPoolToFinal"
matches = twoPoolsToSemi(matches,weight,highest_round)
elsif weight.pool_bracket_type == "twoPoolsToFinal"
matches = twoPoolsToFinal(matches,weight,highest_round)
elsif weight.pool_bracket_type == "fourPoolsToQuarter"
matches = fourPoolsToQuarter(matches,weight,highest_round)
elsif weight.pool_bracket_type == "fourPoolsToSemi"
matches = fourPoolsToSemi(matches,weight,highest_round)
end
return matches
end
def twoPoolsToSemi(matches,weight,round)
@round = round + 1
matches = createMatchup(matches,weight,@round,"Winner Pool 1","Runner Up Pool 2","Semis",nil)
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Runner Up Pool 1","Semis",nil)
matches = assignBouts(matches)
@round = @round + 1
@matches = matches.select{|m| m.weight_id == weight.id}
@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,"","","1/2",nil)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4",nil)
end
def twoPoolsToFinal(matches,weight,round)
@round = round + 1
matches = createMatchup(matches,weight,@round,"Winner Pool 1","Winner Pool 2","1/2",nil)
matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 2","3/4",nil)
end
def fourPoolsToQuarter(matches,weight,round)
@round = round + 1
matches = createMatchup(matches,weight,@round,"Winner Pool 1","Runner Up Pool 2","Quarter",1)
matches = createMatchup(matches,weight,@round,"Winner Pool 4","Runner Up Pool 3","Quarter",2)
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Runner Up Pool 1","Quarter",3)
matches = createMatchup(matches,weight,@round,"Winner Pool 3","Runner Up Pool 4","Quarter",4)
matches = assignBouts(matches)
@matches = matches.select{|m| m.weight_id == weight.id}
@match1 = @matches.select{|m| m.bracket_position_number == 1}.first
@match2 = @matches.select{|m| m.bracket_position_number == 2}.first
@match3 = @matches.select{|m| m.bracket_position_number == 3}.first
@match4 = @matches.select{|m| m.bracket_position_number == 4}.first
@round = @round + 1
matches = createMatchup(matches,weight,@round,"","","Semis",1)
matches = createMatchup(matches,weight,@round,"","","Semis",2)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","Conso Semis",1)
matches = createMatchup(matches,weight,@round,"Loser of #{@match3.boutNumber}","Loser of #{@match4.boutNumber}","Conso Semis",2)
matches = assignBouts(matches)
@matches = matches.select{|m| m.weight_id == weight.id}
@round = @round + 1
@match = @matches.select{|m| m.bracket_position == "Semis"}
@match1 = @match.select{|m|m.bracket_position_number == 1}.first
@match = @matches.select{|m| m.bracket_position == "Semis"}
@match2 = @match.select{|m|m.bracket_position_number == 2}.first
matches = createMatchup(matches,weight,@round,"","","1/2",nil)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4",nil)
@match = @matches.select{|m| m.bracket_position == "Conso Semis"}
@match1 = @match.select{|m|m.bracket_position_number == 1}.first
@match = @matches.select{|m| m.bracket_position == "Conso Semis"}
@match2 = @match.select{|m|m.bracket_position_number == 2}.first
matches = createMatchup(matches,weight,@round,"","","5/6",nil)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","7/8",nil)
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 = createMatchup(matches,weight,@round,"Winner Pool 1","Winner Pool 4","Semis",nil)
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Winner Pool 3","Semis",nil)
matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 4","Conso Semis",nil)
matches = createMatchup(matches,weight,@round,"Runner Up Pool 2","Runner Up Pool 3","Conso Semis",nil)
matches = assignBouts(matches)
@round = @round + 1
@matches = matches.select{|m| m.weight_id == weight.id}
matches = createMatchup(matches,weight,@round,"","","1/2")
matches = createMatchup(matches,weight,@round,"","","1/2",nil)
@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")
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4",nil)
matches = createMatchup(matches,weight,@round,"","","5/6",nil)
@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")
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","7/8",nil)
return matches
end
def createMatchup(matches,weight,round,w1_name,w2_name,bracket_position)
def createMatchup(matches,weight,round,w1_name,w2_name,bracket_position,bracket_position_number)
@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
@match.bracket_position_number = bracket_position_number
matches << @match
return matches
end

View File

@@ -91,7 +91,7 @@ class Weight < ActiveRecord::Base
if self.wrestlers.size > 7 && self.wrestlers.size <= 8
return "twoPoolsToSemi"
elsif self.wrestlers.size > 8 && self.wrestlers.size <= 10
return "twoPoolToFinal"
return "twoPoolsToFinal"
elsif self.wrestlers.size == 11
return "fourPoolsToQuarter"
elsif self.wrestlers.size > 11 && self.wrestlers.size <= 16

View File

@@ -44,8 +44,6 @@ if Rails.env.development?
Wrestler.create(name: 'Guy 25', school_id: 200, weight_id: 201, original_seed: 9, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 26', school_id: 201, weight_id: 201, original_seed: 10, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 27', school_id: 202, weight_id: 201, original_seed: 11, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 28', school_id: 203, weight_id: 201, original_seed: 12, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 29', school_id: 204, weight_id: 201, original_seed: 13, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 30', school_id: 204, weight_id: 202, original_seed: 13, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 31', school_id: 204, weight_id: 202, original_seed: 13, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 32', school_id: 204, weight_id: 202, original_seed: 13, season_win: 0, season_loss: 0, criteria: 'N/A')