mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-15 20:46:57 +00:00
Extracted a method
This commit is contained in:
@@ -10,12 +10,7 @@ class Tournamentmatchgen
|
|||||||
tournament.destroyAllMatches
|
tournament.destroyAllMatches
|
||||||
@matches = []
|
@matches = []
|
||||||
tournament.weights.sort_by{|x|[x.max]}.each do |w|
|
tournament.weights.sort_by{|x|[x.max]}.each do |w|
|
||||||
@wrestlers = w.wrestlers
|
buildTournamentWeights(tournament.id, w)
|
||||||
@matches = Pool.new.generatePools(w.pools,@wrestlers,w,tournament.id,@matches)
|
|
||||||
@weight_matches = @matches.select{|m|m.weight_id == w.id}
|
|
||||||
@last_match = @weight_matches.sort_by{|m| m.round}.last
|
|
||||||
@highest_round = @last_match.round
|
|
||||||
@matches = Poolbracket.new.generateBracketMatches(@matches,w,@highest_round)
|
|
||||||
end
|
end
|
||||||
@matches = Boutgen.new.assignBouts(@matches,tournament.weights)
|
@matches = Boutgen.new.assignBouts(@matches,tournament.weights)
|
||||||
@matches = Losernamegen.new.assignLoserNames(@matches,tournament.weights)
|
@matches = Losernamegen.new.assignLoserNames(@matches,tournament.weights)
|
||||||
@@ -23,6 +18,15 @@ class Tournamentmatchgen
|
|||||||
return @matches
|
return @matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def buildTournamentWeights(tournament_id, weight)
|
||||||
|
@wrestlers = weight.wrestlers
|
||||||
|
@matches = Pool.new.generatePools(weight.pools,@wrestlers, 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
|
||||||
|
|
||||||
def saveMatches(tournament,matches)
|
def saveMatches(tournament,matches)
|
||||||
matches.each do |m|
|
matches.each do |m|
|
||||||
m.tournament_id = tournament.id
|
m.tournament_id = tournament.id
|
||||||
@@ -30,4 +34,3 @@ class Tournamentmatchgen
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user