1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added safeguards for generating pool matches along with tests, updated two errors on about page, and added time saver to create middle school weights

This commit is contained in:
2023-01-24 22:56:22 +00:00
parent 1d0cff0e6f
commit c133a8b051
6 changed files with 131 additions and 23 deletions

View File

@@ -128,17 +128,19 @@ end
end
end
def pool_to_bracket_weights_with_too_many_wrestlers
if self.tournament_type == "Pool to bracket"
weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 24}
if weightsWithTooManyWrestlers.size < 1
return nil
else
return weightsWithTooManyWrestlers
end
else
nil
end
def pool_to_bracket_number_of_wrestlers
error_string = ""
if self.tournament_type.include? "Pool to bracket"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 24}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 2}
weights_with_too_many_wrestlers.each do |weight|
error_string = error_string + " The weight class #{weight.max} has more than 24 wrestlers."
end
weight_with_too_few_wrestlers.each do |weight|
error_string = error_string + " The weight class #{weight.max} has less than 2 wrestlers."
end
end
return error_string
end
def modified_sixteen_man_number_of_wrestlers
@@ -158,7 +160,7 @@ end
def double_elim_number_of_wrestlers
error_string = ""
if self.tournament_type == "Double Elimination 1-6"
if self.tournament_type == "Double Elimination 1-6" or self.tournament_type == "Double Elimination 1-8"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 4}
weights_with_too_many_wrestlers.each do |weight|
@@ -174,14 +176,11 @@ end
def match_generation_error
error_string = "There is a tournament error."
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
double_elim_error = double_elim_number_of_wrestlers
if pool_to_bracket_weights_with_too_many_wrestlers != nil
error_string = error_string + " The following weights have too many wrestlers "
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
error_string = error_string + "#{w.max} "
end
return error_string
elsif modified_sixteen_man_error.length > 0
double_elim_error = double_elim_number_of_wrestlers
pool_to_bracket_error = pool_to_bracket_number_of_wrestlers
if pool_to_bracket_error.length > 0
return error_string + pool_to_bracket_error
elsif modified_sixteen_man_error.length > 0
return error_string + modified_sixteen_man_error
elsif double_elim_error.length > 0
return error_string + double_elim_error

View File

@@ -12,6 +12,7 @@ class Weight < ActiveRecord::Base
# tournament model runs the code via method create_pre_defined_weights
HS_WEIGHT_CLASSES = "106,113,120,126,132,138,144,150,157,165,175,190,215,285"
HS_GIRLS_WEIGHT_CLASSES = "100,105,110,115,120,125,130,135,140,145,155,170,190,235"
MS_WEIGHT_CLASSES = "80,86,92,98,104,110,116,122,128,134,142,150,160,172,205,245"
before_destroy do
self.tournament.destroy_all_matches

View File

@@ -45,6 +45,7 @@
<li><strong>Time Savers</strong></li>
<li><%= link_to "Create Boys High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><%= link_to "Create Girls High School Weights (101-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_GIRLS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><%= link_to "Create Boys Middle School Weights (80-245)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><strong>Tournament Actions</strong></li>
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", :method => :put %></li>
<li><%= link_to "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { confirm: 'Are you sure? This will delete all current matches.' } %></li>

View File

@@ -36,7 +36,7 @@
<li>Most wins by tech fall</li>
<li>Most wins by major</li>
<li>Most points scored in decisions</li>
<li>Quickest pin</li>
<li>Total pin time accumulation</li>
<li>Coin flip</li>
</ul>
<p>If three wrestlers are tied, they will be put through this sequence until two wrestlers are left. Once two wrestlers are left, the pool runner up will be decided by head to head.</p>
@@ -53,8 +53,8 @@
<p>See placement points below (based on the largest bracket of the tournament)</p>
<h4>Pool Types</h4>
<ul>
<li>Single pool round robin - 2-5 wrestlers, place 1-4.</li>
<li>Two Pools of 4 (3 matches each) to a semi final bracket - 6-8 wrestlers, place 1-4.</li>
<li>Single pool round robin - 2-6 wrestlers, place 1-4.</li>
<li>Two Pools of 4 (3 matches each) to a semi final bracket - 7-8 wrestlers, place 1-4.</li>
<li>Two Pools of 5 (4 matches each) to a championship and 3rd/4th match - 8-10 wrestlers, place 1-4.</li>
<li>Four pools of 3 (2 matches each) to a quarter final bracket - 9-12 wrestlers, place 1-8.</li>
<li>Four pools of 4 (3 matches each) to a semi final bracket - 13-16 wrestlers, place 1-8.</li>