mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-13 17:18:58 +00:00
removed the matches argument to generatePools and roundRobin
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
class Pool
|
class Pool
|
||||||
def generatePools(weight, tournament, matches)
|
def generatePools(weight, tournament)
|
||||||
|
matches = []
|
||||||
@pools = weight.pools
|
@pools = weight.pools
|
||||||
@pool = 1
|
@pool = 1
|
||||||
while @pool <= @pools
|
while @pool <= @pools
|
||||||
matches = roundRobin(weight.wrestlers, weight, tournament, matches)
|
matches += roundRobin(weight.wrestlers, weight, tournament)
|
||||||
@pool += 1
|
@pool += 1
|
||||||
end
|
end
|
||||||
return matches
|
return matches
|
||||||
end
|
end
|
||||||
|
|
||||||
def roundRobin(wrestlers,weight,tournament,matches)
|
def roundRobin(wrestlers,weight,tournament)
|
||||||
|
matches = []
|
||||||
@wrestlers = wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
@wrestlers = wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
||||||
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
|
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
|
||||||
@poolMatches.each_with_index do |b, index|
|
@poolMatches.each_with_index do |b, index|
|
||||||
@@ -17,8 +19,8 @@ class Pool
|
|||||||
@bout = b.map
|
@bout = b.map
|
||||||
@bout.each do |bout|
|
@bout.each do |bout|
|
||||||
if bout[0] != nil and bout[1] != nil
|
if bout[0] != nil and bout[1] != nil
|
||||||
@match = Match.new(w1: bout[0].id, w2: bout[1].id, weight_id: weight.id, round: round)
|
match = Match.new(w1: bout[0].id, w2: bout[1].id, weight_id: weight.id, round: round)
|
||||||
matches << @match
|
matches << match
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ class Tournamentmatchgen
|
|||||||
|
|
||||||
def buildTournamentWeights
|
def buildTournamentWeights
|
||||||
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
|
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
|
||||||
@matches = Pool.new.generatePools(weight, @tournament.id, @matches)
|
matches = Pool.new.generatePools(weight, @tournament.id)
|
||||||
weight_matches = @matches.select{|m| m.weight_id == weight.id }
|
weight_matches = matches.select{|m| m.weight_id == weight.id }
|
||||||
last_match = weight_matches.sort_by{|m| m.round}.last
|
last_match = weight_matches.sort_by{|m| m.round}.last
|
||||||
highest_round = last_match.round
|
highest_round = last_match.round
|
||||||
@matches = Poolbracket.new.generateBracketMatches(@matches, weight, highest_round)
|
@matches += Poolbracket.new.generateBracketMatches(matches, weight, highest_round)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user