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

Do not award bye points if they get bye's all the way to the finals and win by bye

This commit is contained in:
2021-12-21 00:39:40 +00:00
parent efeea574ed
commit a6cc05424c
3 changed files with 116 additions and 4 deletions

View File

@@ -51,21 +51,21 @@ class CalculateWrestlerTeamScore
end
end
if @tournament.tournament_type.include? "Regular Double Elimination"
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2"}.size > 0
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2" and m.win_type != "BYE"}.size > 0
# if they have a win in the championship round or if they got a bye all the way to finals and won the finals
points += @wrestler.championship_byes.size * 2
end
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "3/4"}.size > 0
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "3/4" and m.win_type != "BYE"}.size > 0
# if they have a win in the consolation round or if they got a bye all the way to 3rd/4th match and won
points += @wrestler.consolation_byes.size * 1
end
end
if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2"}.size > 0
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2" and m.win_type != "BYE"}.size > 0
# if they have a win in the championship round or if they got a bye all the way to finals and won the finals
points += @wrestler.championship_byes.size * 2
end
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "5/6"}.size > 0
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "5/6" and m.win_type != "BYE"}.size > 0
# if they have a win in the consolation round or if they got a bye all the way to 5th/6th match and won
# since the consolation bracket goes to 5/6 in a modified tournament
points += @wrestler.consolation_byes.size * 1

View File

@@ -53,4 +53,60 @@ class DoubleEliminationWrestlerScore < ActionDispatch::IntegrationTest
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 2
end
test "Wrestlers do not get bye points if they get byes to 1st/2nd and win by bye" do
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}.first
quarter = matches.select{|m| m.bracket_position == "Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Semis"}.first
final = matches.select{|m| m.bracket_position == "1/2"}.first
winner_by_name_by_bye("Test1", round1)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name_by_bye("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 0
end
test "Wrestlers do not get bye points if they get byes to 3rd/4th and win by bye" do
matches = @tournament.matches.reload
round2 = matches.select{|m| m.round == 2 and m.bracket_position == "Conso"}.first
quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Conso Semis"}.first
final = matches.select{|m| m.bracket_position == "3/4"}.first
winner_by_name_by_bye("Test1", round2)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name_by_bye("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 0
end
test "Wrestlers do not get bye points if they get byes to 1st/2nd and win by decision" do
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}.first
quarter = matches.select{|m| m.bracket_position == "Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Semis"}.first
final = matches.select{|m| m.bracket_position == "1/2"}.first
winner_by_name_by_bye("Test1", round1)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 6
end
test "Wrestlers do not get bye points if they get byes to 3rd/4th and win by decision" do
matches = @tournament.matches.reload
round2 = matches.select{|m| m.round == 2 and m.bracket_position == "Conso"}.first
quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Conso Semis"}.first
final = matches.select{|m| m.bracket_position == "3/4"}.first
winner_by_name_by_bye("Test1", round2)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 3
end
end

View File

@@ -53,4 +53,60 @@ class ModifiedDoubleEliminationWrestlerScore < ActionDispatch::IntegrationTest
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 2
end
test "Wrestlers do not get bye points if they get byes to 1st/2nd and win by bye" do
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}.first
quarter = matches.select{|m| m.bracket_position == "Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Semis"}.first
final = matches.select{|m| m.bracket_position == "1/2"}.first
winner_by_name_by_bye("Test1", round1)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name_by_bye("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 0
end
test "Wrestlers do not get bye points if they get byes to 5th/6th and win by bye" do
matches = @tournament.matches.reload
round2 = matches.select{|m| m.round == 2 and m.bracket_position == "Conso"}.first
quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Conso Semis"}.first
final = matches.select{|m| m.bracket_position == "5/6"}.first
winner_by_name_by_bye("Test1", round2)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name_by_bye("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 0
end
test "Wrestlers do not get bye points if they get byes to 1st/2nd and win by decision" do
matches = @tournament.matches.reload
round1 = matches.select{|m| m.round == 1}.first
quarter = matches.select{|m| m.bracket_position == "Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Semis"}.first
final = matches.select{|m| m.bracket_position == "1/2"}.first
winner_by_name_by_bye("Test1", round1)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 6
end
test "Wrestlers do not get bye points if they get byes to 5th/6th and win by decision" do
matches = @tournament.matches.reload
round2 = matches.select{|m| m.round == 2 and m.bracket_position == "Conso"}.first
quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.first
semi = matches.select{|m| m.bracket_position == "Conso Semis"}.first
final = matches.select{|m| m.bracket_position == "5/6"}.first
winner_by_name_by_bye("Test1", round2)
winner_by_name_by_bye("Test1", quarter)
winner_by_name_by_bye("Test1", semi)
winner_by_name("Test1", final)
wrestler_points_calc = CalculateWrestlerTeamScore.new(get_wretler_by_name("Test1"))
assert wrestler_points_calc.byePoints == 3
end
end