1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00
Files
wrestlingdev.com/app/models/pool.rb
2015-05-26 19:26:15 -04:00

39 lines
746 B
Ruby

class Pool
def initialize(weight)
@weight = weight
@tournament = @weight.tournament
@pool = 1
end
def generatePools
matches = []
pools = @weight.pools
while @pool <= pools
matches += roundRobin()
@pool += 1
end
return matches
end
def roundRobin
matches = []
wrestlers = @weight.wrestlers_for_pool(@pool)
poolMatches = RoundRobinTournament.schedule(wrestlers).reverse
poolMatches.each_with_index do |b, index|
round = index + 1
bouts = b.map
bouts.each do |bout|
if bout[0] != nil and bout[1] != nil
match = @tournament.matches.create(
w1: bout[0].id,
w2: bout[1].id,
weight_id: @weight.id,
round: round)
matches << match
end
end
end
matches
end
end