mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
introduced a constructor for Pool and reduced arguments on roundRobin and generatePools
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
class Pool
|
||||
def generatePools(weight, tournament)
|
||||
matches = []
|
||||
@pools = weight.pools
|
||||
def initialize(weight)
|
||||
@weight = weight
|
||||
@pool = 1
|
||||
while @pool <= @pools
|
||||
matches += roundRobin(weight.wrestlers, weight, tournament)
|
||||
end
|
||||
|
||||
def generatePools
|
||||
matches = []
|
||||
pools = @weight.pools
|
||||
while @pool <= pools
|
||||
matches += roundRobin(@weight)
|
||||
@pool += 1
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
def roundRobin(wrestlers,weight,tournament)
|
||||
def roundRobin(weight)
|
||||
matches = []
|
||||
@wrestlers = wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
||||
@wrestlers = weight.wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
||||
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
|
||||
@poolMatches.each_with_index do |b, index|
|
||||
round = index + 1
|
||||
|
||||
@@ -27,7 +27,7 @@ class Tournamentmatchgen
|
||||
|
||||
def buildTournamentWeights
|
||||
@tournament.weights.sort_by{|x|[x.max]}.each do |weight|
|
||||
matches = Pool.new.generatePools(weight, @tournament.id)
|
||||
matches = Pool.new(weight).generatePools()
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user