mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-16 21:11:38 +00:00
Added error for double elimination tournament
This commit is contained in:
@@ -129,9 +129,25 @@ class Tournament < ActiveRecord::Base
|
|||||||
return error_string
|
return error_string
|
||||||
end
|
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
|
def match_generation_error
|
||||||
errorString = "There is a tournament error."
|
errorString = "There is a tournament error."
|
||||||
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
|
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
|
if pool_to_bracket_weights_with_too_many_wrestlers != nil
|
||||||
errorString = errorString + " The following weights have too many wrestlers "
|
errorString = errorString + " The following weights have too many wrestlers "
|
||||||
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
|
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
|
||||||
@@ -140,11 +156,10 @@ class Tournament < ActiveRecord::Base
|
|||||||
return errorString
|
return errorString
|
||||||
elsif modified_sixteen_man_error.length > 0
|
elsif modified_sixteen_man_error.length > 0
|
||||||
return errorString + modified_sixteen_man_error
|
return errorString + modified_sixteen_man_error
|
||||||
|
elsif double_elim_error.length > 0
|
||||||
|
return error_string + double_elim_error
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user