mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 21:24:25 +00:00
New bracket positions for double elim brackets. Each bracket position will now wrestle during the same round. Made a rake task to migrate previous matches to the new bracket positions.
This commit is contained in:
@@ -71,13 +71,19 @@ class Match < ApplicationRecord
|
||||
end
|
||||
|
||||
def bracket_position_validation
|
||||
if ! BRACKET_POSITIONS.include? bracket_position
|
||||
errors.add(:bracket_position, "can only be one of the following #{BRACKET_POSITIONS.to_s}")
|
||||
end
|
||||
# Allow "Bracket Round of 16", "Bracket Round of 16.1",
|
||||
# "Conso Round of 8", "Conso Round of 8.2", etc.
|
||||
bracket_round_regex = /\A(Bracket|Conso) Round of \d+(\.\d+)?\z/
|
||||
|
||||
unless BRACKET_POSITIONS.include?(bracket_position) || bracket_position.match?(bracket_round_regex)
|
||||
errors.add(:bracket_position,
|
||||
"must be one of #{BRACKET_POSITIONS.to_s} " \
|
||||
"or match the pattern 'Bracket Round of X'/'Conso Round of X'")
|
||||
end
|
||||
end
|
||||
|
||||
def is_consolation_match
|
||||
if self.bracket_position == "Conso" or self.bracket_position == "Conso Quarter" or self.bracket_position == "Conso Semis" or self.bracket_position == "3/4" or self.bracket_position == "5/6" or self.bracket_position == "7/8"
|
||||
if self.bracket_position.include? "Conso" or self.bracket_position == "3/4" or self.bracket_position == "5/6" or self.bracket_position == "7/8"
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@@ -85,7 +91,7 @@ class Match < ApplicationRecord
|
||||
end
|
||||
|
||||
def is_championship_match
|
||||
if self.bracket_position == "Pool" or self.bracket_position == "Quarter" or self.bracket_position == "Semis" or self.bracket_position == "Bracket" or self.bracket_position == "1/2"
|
||||
if self.bracket_position == "Pool" or self.bracket_position == "Quarter" or self.bracket_position == "Semis" or self.bracket_position.include? "Bracket" or self.bracket_position == "1/2"
|
||||
return true
|
||||
else
|
||||
return false
|
||||
|
||||
@@ -164,7 +164,7 @@ class Weight < ApplicationRecord
|
||||
end
|
||||
|
||||
def highest_bracket_round
|
||||
bracket_matches_sorted_by_round_descending = matches.select{|m| m.bracket_position == "Bracket"}.sort_by{|m| m.round}.reverse
|
||||
bracket_matches_sorted_by_round_descending = matches.select{|m| m.bracket_position.include? "Bracket"}.sort_by{|m| m.round}.reverse
|
||||
if bracket_matches_sorted_by_round_descending.size > 0
|
||||
return bracket_matches_sorted_by_round_descending.first.round
|
||||
else
|
||||
@@ -172,12 +172,30 @@ class Weight < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def lowest_bracket_round
|
||||
bracket_matches_sorted_by_round_ascending = matches.select{|m| m.bracket_position.include? "Bracket"}.sort_by{|m| m.round}
|
||||
if bracket_matches_sorted_by_round_ascending.size > 0
|
||||
return bracket_matches_sorted_by_round_ascending.first.round
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def highest_conso_round
|
||||
conso_matches_sorted_by_round_descending = matches.select{|m| m.bracket_position == "Conso"}.sort_by{|m| m.round}.reverse
|
||||
conso_matches_sorted_by_round_descending = matches.select{|m| m.bracket_position.include? "Conso"}.sort_by{|m| m.round}.reverse
|
||||
if conso_matches_sorted_by_round_descending.size > 0
|
||||
return conso_matches_sorted_by_round_descending.first.round
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def lowest_conso_round
|
||||
conso_matches_sorted_by_round_ascending = matches.select{|m| m.bracket_position.include? "Conso"}.sort_by{|m| m.round}
|
||||
if conso_matches_sorted_by_round_ascending.size > 0
|
||||
return conso_matches_sorted_by_round_ascending.first.round
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -160,19 +160,19 @@ class Wrestler < ApplicationRecord
|
||||
end
|
||||
|
||||
def championship_advancement_wins
|
||||
matches_won.select{|m| (m.bracket_position == "Quarter" or m.bracket_position == "Semis" or m.bracket_position == "Bracket") and m.win_type != "BYE"}
|
||||
matches_won.select{|m| (m.bracket_position == "Quarter" or m.bracket_position == "Semis" or m.bracket_position.include? "Bracket") and m.win_type != "BYE"}
|
||||
end
|
||||
|
||||
def consolation_advancement_wins
|
||||
matches_won.select{|m| (m.bracket_position == "Conso Semis" or m.bracket_position == "Conso" or m.bracket_position == "Conso Quarter") and m.win_type != "BYE"}
|
||||
matches_won.select{|m| (m.bracket_position.include? "Conso") and m.win_type != "BYE"}
|
||||
end
|
||||
|
||||
def championship_byes
|
||||
matches_won.select{|m| (m.bracket_position == "Quarter" or m.bracket_position == "Semis" or m.bracket_position == "Bracket") and m.win_type == "BYE"}
|
||||
matches_won.select{|m| (m.bracket_position == "Quarter" or m.bracket_position == "Semis" or m.bracket_position.include? "Bracket") and m.win_type == "BYE"}
|
||||
end
|
||||
|
||||
def consolation_byes
|
||||
matches_won.select{|m| (m.bracket_position == "Conso Semis" or m.bracket_position == "Conso" or m.bracket_position == "Conso Quarter") and m.win_type == "BYE"}
|
||||
matches_won.select{|m| (m.bracket_position.include? "Conso") and m.win_type == "BYE"}
|
||||
end
|
||||
|
||||
def finished_matches
|
||||
|
||||
Reference in New Issue
Block a user