1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-04 22:03:49 +00:00

Calculate matchups for pools. This breaks generating matches.

This commit is contained in:
2015-03-12 15:03:38 -04:00
parent d68cebc6e4
commit dc9639cf1c
5 changed files with 73 additions and 21 deletions

View File

@@ -1,14 +1,16 @@
class Pool
def onePool(wrestlers,weight_id,tournament)
def onePool(wrestlers,weight_id,tournament,matches)
wrestlers.sort_by{|x|[x.original_seed]}.each do |w|
w.poolNumber = 1
w.save
end
roundRobin(1,tournament,weight_id)
matches = roundRobin(1,tournament,weight_id,matches)
return matches
end
def twoPools(wrestlers,weight_id,tournament)
def twoPools(wrestlers,weight_id,tournament,matches)
pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.reverse.each do |w|
if w.original_seed == 3
@@ -27,12 +29,13 @@ class Pool
pool =1
end
end
roundRobin(1,tournament,weight_id)
roundRobin(2,tournament,weight_id)
matches = roundRobin(1,tournament,weight_id,matches)
matches = roundRobin(2,tournament,weight_id,matches)
return matches
end
def fourPools(wrestlers,weight_id,tournament)
def fourPools(wrestlers,weight_id,tournament,matches)
@pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.reverse.each do |w|
if w.original_seed == 3
@@ -57,27 +60,29 @@ class Pool
@pool =1
end
end
roundRobin(1,tournament,weight_id)
roundRobin(2,tournament,weight_id)
roundRobin(3,tournament,weight_id)
roundRobin(4,tournament,weight_id)
matches = roundRobin(1,tournament,weight_id,matches)
matches = roundRobin(2,tournament,weight_id,matches)
matches = roundRobin(3,tournament,weight_id,matches)
matches = roundRobin(4,tournament,weight_id,matches)
return matches
end
def roundRobin(pool,tournament_id,weight_id)
def roundRobin(pool,tournament_id,weight_id,matches)
@wrestlers = Wrestler.where(weight_id: weight_id, poolNumber: pool).to_a
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
@poolMatches.each_with_index do |b,index|
@bout = b.map
@bout.each do |b|
if b[0] != nil and b[1] != nil
@match = Match.new
@match.r_id = b[0].id
@match.g_id = b[1].id
@match.tournament_id = tournament_id
@match = Matchup.new
@match.w1 = b[0].id
@match.w2 = b[1].id
@match.round = index + 1
@match.save
matches << @match
end
end
end
return matches
end
end