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

Composed the poolToBracket method. It should simply read as an outline of how to do its job.

This commit is contained in:
RJ Osborne
2015-05-23 05:24:18 -04:00
parent 44ec0b55f0
commit 9d78cd52d2

View File

@@ -13,12 +13,9 @@ class Tournamentmatchgen
end
def poolToBracket
destroyMatches()
@tournament.weights.sort_by{|x|[x.max]}.each do |w|
buildTournamentWeights(w)
end
@matches = Boutgen.new.assignBouts(@matches,@tournament.weights)
@matches = Losernamegen.new.assignLoserNames(@matches,@tournament.weights)
destroyMatches
buildTournamentWeights
generateMatches
saveMatches
return @matches
end
@@ -28,13 +25,22 @@ class Tournamentmatchgen
@matches = []
end
def buildTournamentWeights(weight)
@wrestlers = weight.wrestlers
@matches = Pool.new.generatePools(weight, @tournament.id, @matches)
@weight_matches = @matches.select{|m| m.weight_id == weight.id }
@last_match = @weight_matches.sort_by{|m| m.round}.last
@highest_round = @last_match.round
@matches = Poolbracket.new.generateBracketMatches(@matches, weight, @highest_round)
def buildTournamentWeights
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
@wrestlers = weight.wrestlers
@matches = Pool.new.generatePools(weight, @tournament.id, @matches)
@weight_matches = @matches.select{|m| m.weight_id == weight.id }
@last_match = @weight_matches.sort_by{|m| m.round}.last
@highest_round = @last_match.round
@matches = Poolbracket.new.generateBracketMatches(@matches, weight, @highest_round)
end
end
def generateMatches
@matches =
Losernamegen.new.assignLoserNames(
Boutgen.new.assignBouts(@matches, @tournament.weights),
@tournament.weights)
end
def saveMatches
@@ -43,4 +49,5 @@ class Tournamentmatchgen
m.save
end
end
end