1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-01 03:55:44 +00:00

Changed database column for wrestlers seed to bracket_line

This commit is contained in:
2018-09-17 14:29:00 +00:00
parent 1cfe818d14
commit 436e716cd4
11 changed files with 149 additions and 144 deletions

View File

@@ -61,7 +61,7 @@ class Weight < ActiveRecord::Base
def poolSeedOrder(pool)
# wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
return wrestlersForPool(pool).sort_by{|w|w.seed}
return wrestlersForPool(pool).sort_by{|w|w.bracket_line}
end

View File

@@ -14,14 +14,14 @@ class TournamentSeeding
def randomSeeding(weight)
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed}
if wrestlerWithSeeds.size > 0
highestSeed = wrestlerWithSeeds.last.seed
highestSeed = wrestlerWithSeeds.last.bracket_line
seed = highestSeed + 1
else
seed = 1
end
wrestlersWithoutSeed = weight.wrestlers.select{|w| w.original_seed == nil }
wrestlersWithoutSeed.shuffle.each do |w|
w.seed = seed
w.bracket_line = seed
w.save
seed += 1
end
@@ -30,14 +30,14 @@ class TournamentSeeding
def setOriginalSeeds(weight)
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }
wrestlerWithSeeds.each do |w|
w.seed = w.original_seed
w.bracket_line = w.original_seed
w.save
end
end
def resetAllSeeds(weight)
weight.wrestlers.each do |w|
w.seed = nil
w.bracket_line = nil
w.save
end
end

View File

@@ -1,77 +1,77 @@
class GeneratePoolNumbers
def initialize( weight )
@weight = weight
end
def savePoolNumbers
if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool)
end
end
def saveOnePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.seed }.each do |w|
w.pool = 1
w.save
end
end
def saveTwoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 2
elsif w.seed == 4
w.pool = 1
else
w.pool = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
w.save
end
end
def saveFourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.seed }.reverse.each do |w|
if w.seed == 1
w.pool = 1
elsif w.seed == 2
w.pool = 2
elsif w.seed == 3
w.pool = 3
elsif w.seed == 4
w.pool = 4
elsif w.seed == 8
w.pool = 1
elsif w.seed == 7
w.pool = 2
elsif w.seed == 6
w.pool = 3
elsif w.seed == 5
w.pool = 4
else
w.pool = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
w.save
end
end
class GeneratePoolNumbers
def initialize( weight )
@weight = weight
end
def savePoolNumbers
if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool)
elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool)
end
end
def saveOnePoolNumbers(poolWrestlers)
poolWrestlers.sort_by{|x| x.bracket_line }.each do |w|
w.pool = 1
w.save
end
end
def saveTwoPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.bracket_line }.reverse.each do |w|
if w.bracket_line == 1
w.pool = 1
elsif w.bracket_line == 2
w.pool = 2
elsif w.bracket_line == 3
w.pool = 2
elsif w.bracket_line == 4
w.pool = 1
else
w.pool = pool
end
if pool < 2
pool = pool + 1
else
pool = 1
end
w.save
end
end
def saveFourPoolNumbers(poolWrestlers)
pool = 1
poolWrestlers.sort_by{|x| x.bracket_line }.reverse.each do |w|
if w.bracket_line == 1
w.pool = 1
elsif w.bracket_line == 2
w.pool = 2
elsif w.bracket_line == 3
w.pool = 3
elsif w.bracket_line == 4
w.pool = 4
elsif w.bracket_line == 8
w.pool = 1
elsif w.bracket_line == 7
w.pool = 2
elsif w.bracket_line == 6
w.pool = 3
elsif w.bracket_line == 5
w.pool = 4
else
w.pool = pool
end
if pool < 4
pool = pool + 1
else
pool = 1
end
w.save
end
end
end

View File

@@ -10,18 +10,18 @@ class SwapWrestlers
w3 = Wrestler.new
w3.weight_id = w1.weight_id
w3.original_seed = w1.original_seed
w3.seed = w1.seed
w3.bracket_line = w1.bracket_line
w3.pool = w1.pool
swapWrestlerMatches(w1.allMatches,w1.id,w3.id)
#Swap wrestler 1 and wrestler 2
swapWrestlerMatches(w2.allMatches,w2.id,w1.id)
w1.seed = w2.seed
w1.bracket_line = w2.bracket_line
w1.pool = w2.pool
swapWrestlerMatches(w3.allMatches,w3.id,w2.id)
w2.seed = w3.seed
w2.bracket_line = w3.bracket_line
w2.pool = w3.pool

View File

@@ -15,7 +15,7 @@
</tr>
</thead>
<tbody>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.seed}.each do |w| %>
<% @wrestlers.select{|w| w.pool == @pool}.sort_by{|w| w.bracket_line}.each do |w| %>
<tr>
<td><%= w.original_seed %> <%= w.name %> <%= w.season_win %>-<%= w.season_loss %> <%= w.school.name %></td>
<% @round = 1 %>