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

Added error for double elimination tournament

This commit is contained in:
2020-02-04 12:24:21 -05:00
parent eac603667b
commit afaae0fd12

View File

@@ -128,10 +128,26 @@ class Tournament < ActiveRecord::Base
end
return error_string
end
def double_elim_number_of_wrestlers
error_string = ""
if self.tournament_type == "Double Elimination 1-6"
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|
error_string = error_string + " The weight class #{weight.max} has more than 16 wrestlers."
end
weight_with_too_few_wrestlers.each do |weight|
error_string = error_string + " The weight class #{weight.max} has less than 4 wrestlers."
end
end
return error_string
end
def match_generation_error
errorString = "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
errorString = errorString + " The following weights have too many wrestlers "
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
@@ -140,11 +156,10 @@ class Tournament < ActiveRecord::Base
return errorString
elsif modified_sixteen_man_error.length > 0
return errorString + modified_sixteen_man_error
elsif double_elim_error.length > 0
return error_string + double_elim_error
else
nil
end
end
end
end