1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-31 11:35:45 +00:00

Assigned four pools correctly

This commit is contained in:
2015-02-09 10:26:56 -05:00
parent d52d462d77
commit b7122fda8b
2 changed files with 20 additions and 39 deletions

View File

@@ -16,7 +16,7 @@ class Bout
def giveBout(matches)
@matches = matches.sort_by{|x|[x.weight_max]}
@matches.each_with_index do |m, i|
bout = m.round * 100 + i
bout = m.round * 1000 + i
m.boutNumber = bout
m.save
end

View File

@@ -8,9 +8,7 @@ class Pool
end
def twoPools(wrestlers,weight_id,tournament)
#wrestlers.sort_by{|x|[x.original_seed]}
def twoPools(wrestlers,weight_id,tournament)
pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.each do |w|
if w.original_seed == 3
@@ -35,12 +33,24 @@ class Pool
def fourPools(wrestlers,weight_id,tournament)
@pool = 1
wrestlers.sort_by{|x|[x.original_seed]}.each do |w|
w.poolNumber = @pool
w.save
wrestlers.sort_by{|x|[x.original_seed]}.reverse.each do |w|
if w.original_seed == 3
w.poolNumber = 3
w.save
elsif w.original_seed == 4
w.poolNumber = 4
w.save
elsif w.original_seed == 1
w.poolNumber = 1
w.save
elsif w.original_seed == 2
w.poolNumber = 2
w.save
else
w.poolNumber = @pool
w.save
end
if @pool < 4
@pool = @pool + 1
else
@@ -55,17 +65,11 @@ class Pool
def roundRobin(pool,tournament_id,weight_id)
@wrestlers = Wrestler.where(weight_id: weight_id, poolNumber: pool).to_a
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
@poolMatches = RoundRobinTournament.schedule(@wrestlers)
@poolMatches.each_with_index do |b,index|
@bout = b.map
@bout.each do |b|
if b[0] != nil and b[1] != nil
# puts "Start Map Here"
# puts b[0].name
# puts " vs "
# puts b[1].name
# puts "Round "
# puts index + 1
@match = Match.new
@match.r_id = b[0].id
@match.g_id = b[1].id
@@ -77,27 +81,4 @@ class Pool
end
end
# def roundRobin(pool,tournament,weight_id)
# @wrestlers = Wrestler.where(weight_id: weight_id, poolNumber: pool)
# @wrestlers.sort_by{|x|[x.original_seed]}.to_a
# @wrestlers.each_with_index do |w,index|
# next_guy_index = index+1
# while index < @wrestlers.length && next_guy_index < @wrestlers.length
# other_guy = @wrestlers[next_guy_index]
# createMatch(w.id,other_guy.id,tournament)
# index += 1
# next_guy_index += 1
# end
# end
# end
# def createMatch(w1,w2,tournament)
# @match = Match.new
# @match.r_id = w1
# @match.g_id = w2
# @match.tournament_id = tournament
# @match.save
# end
end