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

Now naming loser of boutNumber in boutgen. Boutgen only run once now.

This commit is contained in:
2015-04-21 21:15:44 -04:00
parent a6757e6bfe
commit b61431930f
3 changed files with 69 additions and 41 deletions

View File

@@ -7,19 +7,74 @@ class Boutgen
def giveBout(matches) def giveBout(matches)
@matches = matches.sort_by{|x|[x.weight_max]} @matches = matches.sort_by{|x|[x.weight_max]}
@matches.each_with_index do |m, i| @matches.each_with_index do |m, i|
bout = m.round * 1000 + i @bout = m.round * 1000 + i
m.boutNumber = bout m.boutNumber = @bout
end end
return @matches return @matches
end end
def assignBouts(matches) def assignBouts(matches,weights)
@round = 1 @round = 1
until matchesByRound(@round, matches).blank? do until matchesByRound(@round, matches).blank? do
@matches = matchesByRound(@round, matches) @matches = matchesByRound(@round, matches)
giveBout(@matches) giveBout(@matches)
@round += 1 @round += 1
end end
assignLoserNames(matches,weights)
return matches return matches
end end
def assignLoserNames(matches,weights)
weights.each do |w|
@matches = matches.select{|m| m.weight_id == w.id}
if w.pool_bracket_type == "twoPoolsToSemi"
twoPoolsToSemiLoser(@matches)
elsif w.pool_bracket_type == "fourPoolsToQuarter"
fourPoolsToQuarterLoser(@matches)
elsif w.pool_bracket_type == "fourPoolsToSemi"
fourPoolsToSemiLoser(@matches)
end
end
end
def twoPoolsToSemiLoser(matches)
@match1 = matches.select{|m| m.w1_name == "Winner Pool 1"}.first
@match2 = matches.select{|m| m.w1_name == "Winner Pool 2"}.first
@matchChange = matches.select{|m| m.bracket_position == "3/4"}.first
@matchChange.w1_name = "Loser of #{@match1.boutNumber}"
@matchChange.w2_name = "Loser of #{@match2.boutNumber}"
end
def fourPoolsToQuarterLoser(matches)
@quarters = matches.select{|m| m.bracket_position == "Quarter"}
@consoSemis = matches.select{|m| m.bracket_position == "Conso Semis"}
@semis = matches.select{|m| m.bracket_position == "Semis"}
@thirdFourth = matches.select{|m| m.bracket_position == "3/4"}.first
@seventhEighth = matches.select{|m| m.bracket_position == "7/8"}.first
@consoSemis.each do |match|
if match.bracket_position_number == 1
match.w1_name = "Loser of #{@quarters.select{|m| m.bracket_position_number == 1}.first.boutNumber}"
match.w2_name = "Loser of #{@quarters.select{|m| m.bracket_position_number == 2}.first.boutNumber}"
elsif match.bracket_position_number == 2
match.w1_name = "Loser of #{@quarters.select{|m| m.bracket_position_number == 3}.first.boutNumber}"
match.w2_name = "Loser of #{@quarters.select{|m| m.bracket_position_number == 4}.first.boutNumber}"
end
end
@thirdFourth.w1_name = "Loser of #{@semis.select{|m| m.bracket_position_number == 1}.first.boutNumber}"
@thirdFourth.w2_name = "Loser of #{@semis.select{|m| m.bracket_position_number == 2}.first.boutNumber}"
@consoSemis = matches.select{|m| m.bracket_position == "Conso Semis"}
@seventhEighth.w1_name = "Loser of #{@consoSemis.select{|m| m.bracket_position_number == 1}.first.boutNumber}"
@seventhEighth.w2_name = "Loser of #{@consoSemis.select{|m| m.bracket_position_number == 2}.first.boutNumber}"
end
def fourPoolsToSemiLoser(matches)
@semis = matches.select{|m| m.bracket_position == "Semis"}
@thirdFourth = matches.select{|m| m.bracket_position == "3/4"}.first
@consoSemis = matches.select{|m| m.bracket_position == "Conso Semis"}
@seventhEighth = matches.select{|m| m.bracket_position == "7/8"}.first
@thirdFourth.w1_name = "Loser of #{@semis.select{|m| m.bracket_position_number == 1}.first.boutNumber}"
@thirdFourth.w2_name = "Loser of #{@semis.select{|m| m.bracket_position_number == 2}.first.boutNumber}"
@seventhEighth.w1_name = "Loser of #{@consoSemis.select{|m| m.bracket_position_number == 1}.first.boutNumber}"
@seventhEighth.w2_name = "Loser of #{@consoSemis.select{|m| m.bracket_position_number == 2}.first.boutNumber}"
end
end end

View File

@@ -17,13 +17,11 @@ class Poolbracket
@round = round + 1 @round = round + 1
matches = createMatchup(matches,weight,@round,"Winner Pool 1","Runner Up Pool 2","Semis",1) matches = createMatchup(matches,weight,@round,"Winner Pool 1","Runner Up Pool 2","Semis",1)
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Runner Up Pool 1","Semis",2) matches = createMatchup(matches,weight,@round,"Winner Pool 2","Runner Up Pool 1","Semis",2)
matches = assignBouts(matches)
@round = @round + 1 @round = @round + 1
@matches = matches.select{|m| m.weight_id == weight.id} @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",1) matches = createMatchup(matches,weight,@round,"","","1/2",1)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4",1) matches = createMatchup(matches,weight,@round,"","","3/4",1)
return matches
end end
def twoPoolsToFinal(matches,weight,round) def twoPoolsToFinal(matches,weight,round)
@@ -38,32 +36,17 @@ class Poolbracket
matches = createMatchup(matches,weight,@round,"Winner Pool 4","Runner Up Pool 3","Quarter",2) 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 2","Runner Up Pool 1","Quarter",3)
matches = createMatchup(matches,weight,@round,"Winner Pool 3","Runner Up Pool 4","Quarter",4) 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 @round = @round + 1
matches = createMatchup(matches,weight,@round,"","","Semis",1) matches = createMatchup(matches,weight,@round,"","","Semis",1)
matches = createMatchup(matches,weight,@round,"","","Semis",2) 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,"","","Conso Semis",1)
matches = createMatchup(matches,weight,@round,"Loser of #{@match3.boutNumber}","Loser of #{@match4.boutNumber}","Conso Semis",2) matches = createMatchup(matches,weight,@round,"","","Conso Semis",2)
matches = assignBouts(matches)
@matches = matches.select{|m| m.weight_id == weight.id}
@round = @round + 1 @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",1) matches = createMatchup(matches,weight,@round,"","","1/2",1)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","3/4",1) matches = createMatchup(matches,weight,@round,"","","3/4",1)
@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",1) matches = createMatchup(matches,weight,@round,"","","5/6",1)
matches = createMatchup(matches,weight,@round,"Loser of #{@match1.boutNumber}","Loser of #{@match2.boutNumber}","7/8",1) matches = createMatchup(matches,weight,@round,"","","7/8",1)
return matches
end end
def fourPoolsToSemi(matches,weight,round) def fourPoolsToSemi(matches,weight,round)
@@ -72,17 +55,11 @@ class Poolbracket
matches = createMatchup(matches,weight,@round,"Winner Pool 2","Winner Pool 3","Semis",2) matches = createMatchup(matches,weight,@round,"Winner Pool 2","Winner Pool 3","Semis",2)
matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 4","Conso Semis",1) matches = createMatchup(matches,weight,@round,"Runner Up Pool 1","Runner Up Pool 4","Conso Semis",1)
matches = createMatchup(matches,weight,@round,"Runner Up Pool 2","Runner Up Pool 3","Conso Semis",2) matches = createMatchup(matches,weight,@round,"Runner Up Pool 2","Runner Up Pool 3","Conso Semis",2)
matches = assignBouts(matches)
@round = @round + 1 @round = @round + 1
@matches = matches.select{|m| m.weight_id == weight.id}
matches = createMatchup(matches,weight,@round,"","","1/2",1) matches = createMatchup(matches,weight,@round,"","","1/2",1)
@match1 = @matches.select{|m| m.w1_name == "Winner Pool 1"}.first matches = createMatchup(matches,weight,@round,"","","3/4",1)
@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",1)
matches = createMatchup(matches,weight,@round,"","","5/6",1) matches = createMatchup(matches,weight,@round,"","","5/6",1)
@match1 = @matches.select{|m| m.w1_name == "Runner Up Pool 1"}.first matches = createMatchup(matches,weight,@round,"","","7/8",1)
@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",1)
return matches return matches
end end
@@ -99,9 +76,5 @@ class Poolbracket
return matches return matches
end end
def assignBouts(matches)
@bouts = Boutgen.new
@matches = @bouts.assignBouts(matches)
return @matches
end
end end

View File

@@ -29,7 +29,7 @@ class Tournament < ActiveRecord::Base
def assignBouts(matches) def assignBouts(matches)
@bouts = Boutgen.new @bouts = Boutgen.new
@matches = @bouts.assignBouts(matches) @matches = @bouts.assignBouts(matches,self.weights)
return @matches return @matches
end end