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
|
class Pool
|
||||||
def generatePools(weight, tournament)
|
def initialize(weight)
|
||||||
matches = []
|
@weight = weight
|
||||||
@pools = weight.pools
|
|
||||||
@pool = 1
|
@pool = 1
|
||||||
while @pool <= @pools
|
end
|
||||||
matches += roundRobin(weight.wrestlers, weight, tournament)
|
|
||||||
|
def generatePools
|
||||||
|
matches = []
|
||||||
|
pools = @weight.pools
|
||||||
|
while @pool <= pools
|
||||||
|
matches += roundRobin(@weight)
|
||||||
@pool += 1
|
@pool += 1
|
||||||
end
|
end
|
||||||
return matches
|
return matches
|
||||||
end
|
end
|
||||||
|
|
||||||
def roundRobin(wrestlers,weight,tournament)
|
def roundRobin(weight)
|
||||||
matches = []
|
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 = RoundRobinTournament.schedule(@wrestlers).reverse
|
||||||
@poolMatches.each_with_index do |b, index|
|
@poolMatches.each_with_index do |b, index|
|
||||||
round = index + 1
|
round = index + 1
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ 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 = Pool.new(weight).generatePools()
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user