1
0
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:
RJ Osborne
2015-05-23 06:15:44 -04:00
parent 399923b949
commit aec47ddf13
2 changed files with 12 additions and 8 deletions

View File

@@ -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

View File

@@ -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