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

Fixed random seeding for double elimination. Since bracket positions are already evenly distributed on top half and bottom half of the bracket, I only need to pick odd or even bracket line numbers.

This commit is contained in:
2026-01-23 17:35:16 -05:00
parent 556090c16b
commit 9c2a9d62ad
2 changed files with 24 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ class RandomSeedingTest < ActionDispatch::IntegrationTest
end
def clean_up_original_seeds(tournament)
tournament.wrestlers.select{|w| w.original_seed > 12}.each do |wrestler|
tournament.wrestlers.each do |wrestler|
wrestler.original_seed = nil
wrestler.save
end
@@ -33,4 +33,23 @@ class RandomSeedingTest < ActionDispatch::IntegrationTest
round_one_bottom_half = round_one_matches.select{|m| !m.w1.nil? and !m.w2.nil? and m.bracket_position_number > 8}
assert round_one_top_half.size == round_one_bottom_half.size
end
test "There are the same number of matches in the top half and bottom half of a double elimination tournament in round 1 in a 6 man bracket" do
create_double_elim_tournament_single_weight(6, "Regular Double Elimination 1-8")
clean_up_original_seeds(@tournament)
round_one_matches = @tournament.matches.reload.select{|m| m.round == 1}
# 8 man bracket there are 4 matches so top half is bracket_position_number 1-2 and bottom is 3-4
round_one_top_half = round_one_matches.select{|m| !m.w1.nil? and !m.w2.nil? and m.bracket_position_number < 3}
round_one_bottom_half = round_one_matches.select{|m| !m.w1.nil? and !m.w2.nil? and m.bracket_position_number > 2}
assert round_one_top_half.size == round_one_bottom_half.size
end
test "There are no double byes in a double elimination tournament in a 6 man bracket" do
create_double_elim_tournament_single_weight(6, "Regular Double Elimination 1-8")
clean_up_original_seeds(@tournament)
round_one_matches = @tournament.matches.reload.select{|m| m.round == 1}
conso_round_one_matches = @tournament.matches.reload.select{|m| m.bracket_position == "Conso Quarter"}
assert round_one_matches.select{|m| m.w1.nil? and m.w2.nil? }.size == 0
assert conso_round_one_matches.select{|m| m.loser1_name == "BYE" and m.loser2_name == "BYE" }.size == 0
end
end