diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 784a783..97a3590 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -93,7 +93,7 @@ class Tournament < ActiveRecord::Base def pool_to_bracket_weights_with_too_many_wrestlers if self.tournament_type == "Pool to bracket" - weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 16} + weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 24} if weightsWithTooManyWrestlers.size < 1 return nil else diff --git a/app/models/weight.rb b/app/models/weight.rb index 7814622..19c88db 100644 --- a/app/models/weight.rb +++ b/app/models/weight.rb @@ -56,6 +56,8 @@ class Weight < ActiveRecord::Base self.pools = 2 elsif (@wrestlers.size > 10) && (@wrestlers.size <= 16) self.pools = 4 + elsif (@wrestlers.size > 16) && (@wrestlers.size <= 24) + self.pools = 8 end end @@ -83,6 +85,8 @@ class Weight < ActiveRecord::Base return "fourPoolsToQuarter" elsif self.wrestlers.size > 12 && self.wrestlers.size <= 16 return "fourPoolsToSemi" + elsif self.wrestlers.size > 16 && self.wrestlers.size <= 24 + return "eightPoolsToQuarter" end end diff --git a/app/services/tournament_services/pool_bracket_generation.rb b/app/services/tournament_services/pool_bracket_generation.rb index 4b42763..e540123 100644 --- a/app/services/tournament_services/pool_bracket_generation.rb +++ b/app/services/tournament_services/pool_bracket_generation.rb @@ -20,6 +20,8 @@ class PoolBracketGeneration return fourPoolsToQuarter() elsif @pool_bracket_type == "fourPoolsToSemi" return fourPoolsToSemi() + elsif @pool_bracket_type == "eightPoolsToQuarter" + return eightPoolsToQuarter() end return [] end @@ -66,6 +68,23 @@ class PoolBracketGeneration createMatchup("", "", "7/8", 1) end + def eightPoolsToQuarter() + createMatchup("Winner Pool 1", "Winner Pool 8", "Quarter", 1) + createMatchup("Winner Pool 4", "Winner Pool 5", "Quarter", 2) + createMatchup("Winner Pool 2", "Winner Pool 7", "Quarter", 3) + createMatchup("Winner Pool 3", "Winner Pool 6", "Quarter", 4) + next_round + createMatchup("", "", "Semis", 1) + createMatchup("", "", "Semis", 2) + createMatchup("", "", "Conso Semis", 1) + createMatchup("", "", "Conso Semis", 2) + next_round + createMatchup("", "", "1/2", 1) + createMatchup("", "", "3/4", 1) + createMatchup("", "", "5/6", 1) + createMatchup("", "", "7/8", 1) + end + def createMatchup(w1_name, w2_name, bracket_position, bracket_position_number) @tournament.matches.create( loser1_name: w1_name, diff --git a/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb index 49b98fc..3ed7a9a 100644 --- a/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb +++ b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb @@ -7,7 +7,7 @@ class PoolToBracketGenerateLoserNames matches_by_weight = @tournament.matches.where(weight_id: weight.id) if weight.pool_bracket_type == "twoPoolsToSemi" twoPoolsToSemiLoser(matches_by_weight) - elsif weight.pool_bracket_type == "fourPoolsToQuarter" + elsif (weight.pool_bracket_type == "fourPoolsToQuarter") or (weight.pool_bracket_type == "eightPoolsToQuarter") fourPoolsToQuarterLoser(matches_by_weight) elsif weight.pool_bracket_type == "fourPoolsToSemi" fourPoolsToSemiLoser(matches_by_weight) @@ -20,8 +20,8 @@ class PoolToBracketGenerateLoserNames @tournament.weights.each do |w| matches_by_weight = @tournament.matches.where(weight_id: w.id) if w.pool_bracket_type == "twoPoolsToSemi" - twoPoolsToSemiLoser(matches_by_weight) - elsif w.pool_bracket_type == "fourPoolsToQuarter" + twoPoolsToSemiLoser(matches_by_weight) + elsif (w.pool_bracket_type == "fourPoolsToQuarter") or (w.pool_bracket_type == "eightPoolsToQuarter") fourPoolsToQuarterLoser(matches_by_weight) elsif w.pool_bracket_type == "fourPoolsToSemi" fourPoolsToSemiLoser(matches_by_weight) diff --git a/app/services/weight_services/generate_pool_numbers.rb b/app/services/weight_services/generate_pool_numbers.rb index 951bd6e..472791a 100644 --- a/app/services/weight_services/generate_pool_numbers.rb +++ b/app/services/weight_services/generate_pool_numbers.rb @@ -10,6 +10,8 @@ class GeneratePoolNumbers saveTwoPoolNumbers(@weight.wrestlers_without_pool_assignment) elsif @weight.pools == 1 saveOnePoolNumbers(@weight.wrestlers_without_pool_assignment) + elsif @weight.pools == 8 + saveEightPoolNumbers(@weight.wrestlers_without_pool_assignment) end end @@ -74,4 +76,35 @@ class GeneratePoolNumbers w.save end end + + def saveEightPoolNumbers(poolWrestlers) + pool = 1 + poolWrestlers.sort_by{|x| x.bracket_line }.reverse.each do |w| + if w.bracket_line == 1 + w.pool = 1 + elsif w.bracket_line == 2 + w.pool = 2 + elsif w.bracket_line == 3 + w.pool = 3 + elsif w.bracket_line == 4 + w.pool = 4 + elsif w.bracket_line == 5 + w.pool = 5 + elsif w.bracket_line == 6 + w.pool = 6 + elsif w.bracket_line == 7 + w.pool = 7 + elsif w.bracket_line == 8 + w.pool = 8 + else + w.pool = pool + end + if pool < 8 + pool = pool + 1 + else + pool = 1 + end + w.save + end + end end \ No newline at end of file diff --git a/app/services/wrestler_services/pool_bracket_placement_points.rb b/app/services/wrestler_services/pool_bracket_placement_points.rb index da24f76..b34305d 100644 --- a/app/services/wrestler_services/pool_bracket_placement_points.rb +++ b/app/services/wrestler_services/pool_bracket_placement_points.rb @@ -10,7 +10,7 @@ class PoolBracketPlacementPoints if @bracket == "twoPoolsToSemi" whilePointsAreZero { @points = twoPoolsToSemi } end - if @bracket == "fourPoolsToQuarter" + if (@bracket == "fourPoolsToQuarter") or (@bracket == "eightPoolsToQuarter") whilePointsAreZero { @points = fourPoolsToQuarter } end if @bracket == "fourPoolsToSemi" diff --git a/app/views/static_pages/about.html.erb b/app/views/static_pages/about.html.erb index 08c79b0..5d7f437 100644 --- a/app/views/static_pages/about.html.erb +++ b/app/views/static_pages/about.html.erb @@ -4,7 +4,7 @@

Features


-

At this moment in time, WrestlingDev supports a pool to bracket type tournament for up to 16 teams. The bracket format follows OHSAA's 5 match per day rule. WrestlingDev will automatically generate brackets, generate bout numbers, generate and update a bout board, track team points, and update brackets.

+

At this moment in time, WrestlingDev supports a pool to bracket type tournament for up to 24 wrestlers per weight. The bracket format follows OHSAA's 5 match per day rule. WrestlingDev will automatically generate brackets, generate bout numbers, generate and update a bout board, track team points, and update brackets.

For pool to bracket tournaments, pool tie breakers are the following:

Finals matches will only recieve extra placement points for placing higher and bonus points for pin, tech, major, etc. Please note, only brackets with four pools place up to 8. Brackets with 1 or 2 pools only place top 4.


+

Pool Types

+ +

Future Plans


-

Future development plans to support normal double elimination brackets are underway and are planned to be finished in time for the 2016-2017 wrestling season.

+

Future development plans to support normal double elimination brackets are underway.


Contact


diff --git a/app/views/tournaments/all_brackets.html.erb b/app/views/tournaments/all_brackets.html.erb index aadef8c..66bdc95 100644 --- a/app/views/tournaments/all_brackets.html.erb +++ b/app/views/tournaments/all_brackets.html.erb @@ -86,7 +86,7 @@ li:first-child,li:last-child { <% if w.pool_bracket_type == "twoPoolsToSemi" %> <%= render 'twoPoolSemiBracket' %> <% end %> - <% if w.pool_bracket_type == "fourPoolsToQuarter" %> + <% if w.pool_bracket_type == "fourPoolsToQuarter" or w.pool_bracket_type == "eightPoolsToQuarter" %> <%= render 'fourPoolQuarterBracket' %> <% end %> <% if w.pool_bracket_type == "fourPoolsToSemi" %> diff --git a/app/views/tournaments/bracket.html.erb b/app/views/tournaments/bracket.html.erb index 98dabe4..2ec9eb3 100644 --- a/app/views/tournaments/bracket.html.erb +++ b/app/views/tournaments/bracket.html.erb @@ -80,6 +80,9 @@ li:first-child,li:last-child { <% if @weight.pool_bracket_type == "fourPoolsToQuarter" %> <%= render 'fourPoolQuarterBracket' %> <% end %> + <% if @weight.pool_bracket_type == "eightPoolsToQuarter" %> + <%= render 'fourPoolQuarterBracket' %> + <% end %> <% if @weight.pool_bracket_type == "fourPoolsToSemi" %> <%= render 'fourPoolSemiBracket' %> <% end %> diff --git a/db/seeds.rb b/db/seeds.rb index 141034b..443ce60 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -19,6 +19,7 @@ Weight.create(id: 202, max: 113, tournament_id: 200 ) Weight.create(id: 203, max: 120, tournament_id: 200 ) Weight.create(id: 204, max: 126, tournament_id: 200 ) + Weight.create(id: 205, max: 138, tournament_id: 200 ) Mat.create(id: 200, name: "1", tournament_id: 200 ) Mat.create(id: 201, name: "2", tournament_id: 200 ) Mat.create(id: 202, name: "3", tournament_id: 200 ) @@ -75,6 +76,31 @@ Wrestler.create(name: 'Guy 50', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') Wrestler.create(name: 'Guy 51', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') Wrestler.create(name: 'Guy 52', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + + Wrestler.create(name: 'Guy 53', school_id: 204, weight_id: 205, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 54', school_id: 204, weight_id: 205, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 55', school_id: 204, weight_id: 205, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 56', school_id: 204, weight_id: 205, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 57', school_id: 204, weight_id: 205, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 58', school_id: 204, weight_id: 205, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 59', school_id: 204, weight_id: 205, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 60', school_id: 204, weight_id: 205, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 61', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 62', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 63', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 64', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 65', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 66', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 67', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 68', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 69', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 70', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 71', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 72', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 73', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 74', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 75', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') + Wrestler.create(name: 'Guy 76', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A') #end diff --git a/test/fixtures/mats.yml b/test/fixtures/mats.yml index c122bd0..37bbebe 100644 --- a/test/fixtures/mats.yml +++ b/test/fixtures/mats.yml @@ -16,3 +16,8 @@ name: 1 tournament_id: 2 id: 2 + + eight_pools_generation_mat: + name: 1 + tournament_id: 4 + id: 3 \ No newline at end of file diff --git a/test/fixtures/schools.yml b/test/fixtures/schools.yml index da62b28..8fb85bf 100644 --- a/test/fixtures/schools.yml +++ b/test/fixtures/schools.yml @@ -20,3 +20,7 @@ swap_wrestlers: name: Central Crossing tournament_id: 3 +eight_pools_generation_school: + id: 5 + name: Central Crossing + tournament_id: 4 \ No newline at end of file diff --git a/test/fixtures/tournaments.yml b/test/fixtures/tournaments.yml index 39dfba1..45c1333 100644 --- a/test/fixtures/tournaments.yml +++ b/test/fixtures/tournaments.yml @@ -29,3 +29,13 @@ swap_wrestlers_tournament: tournament_type: Pool to bracket user_id: 1 date: 2015-12-30 + +eight_pools_generation_tournament: + id: 4 + name: Comet Classic 2 + address: Some Place + director: Jacob Cody Wimer + director_email: jacob.wimer@gmail.com + tournament_type: Pool to bracket + user_id: 1 + date: 2015-12-30 \ No newline at end of file diff --git a/test/fixtures/weights.yml b/test/fixtures/weights.yml index 943d92f..8e5b4fe 100644 --- a/test/fixtures/weights.yml +++ b/test/fixtures/weights.yml @@ -35,3 +35,8 @@ swap_wrestlers: id: 7 max: 138 tournament_id: 3 + +eight_pools_generation_weight: + id: 8 + max: 138 + tournament_id: 4 \ No newline at end of file diff --git a/test/fixtures/wrestlers.yml b/test/fixtures/wrestlers.yml index 37204cc..5ca0229 100644 --- a/test/fixtures/wrestlers.yml +++ b/test/fixtures/wrestlers.yml @@ -771,7 +771,229 @@ swap_wrestlers_wrestler_8: criteria: extra: +eight_pools_generation_wrestler_1: + name: Guy1 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_2: + name: Guy2 + school_id: 5 + weight_id: 8 + original_seed: 2 + season_loss: 0 + season_win: 0 + criteria: + extra: - - - +eight_pools_generation_wrestler_3: + name: Guy3 + school_id: 5 + weight_id: 8 + original_seed: 3 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_4: + name: Guy4 + school_id: 5 + weight_id: 8 + original_seed: 4 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_5: + name: Guy5 + school_id: 5 + weight_id: 8 + original_seed: 5 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_6: + name: Guy6 + school_id: 5 + weight_id: 8 + original_seed: 6 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_7: + name: Guy7 + school_id: 5 + weight_id: 8 + original_seed: 7 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_8: + name: Guy8 + school_id: 5 + weight_id: 8 + original_seed: 8 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_9: + name: Guy9 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_9: + name: Guy9 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_10: + name: Guy10 + school_id: 5 + weight_id: 8 + original_seed: 1 + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_11: + name: Guy11 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_12: + name: Guy12 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_13: + name: Guy13 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_14: + name: Guy14 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_15: + name: Guy15 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_16: + name: Guy16 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_17: + name: Guy17 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_18: + name: Guy18 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_19: + name: Guy19 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_20: + name: Guy20 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_21: + name: Guy21 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_22: + name: Guy22 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_23: + name: Guy23 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: +eight_pools_generation_wrestler_24: + name: Guy24 + school_id: 5 + weight_id: 8 + original_seed: + season_loss: 0 + season_win: 0 + criteria: + extra: diff --git a/test/integration/eight_pool_match_generation_test.rb b/test/integration/eight_pool_match_generation_test.rb new file mode 100644 index 0000000..ebe545b --- /dev/null +++ b/test/integration/eight_pool_match_generation_test.rb @@ -0,0 +1,84 @@ +require 'test_helper' + +class EightPoolMatchGenerationTest < ActionDispatch::IntegrationTest + def setup + @tournament = Tournament.find(4) + end + + test "Match generation works" do + GenerateTournamentMatches.new(@tournament).generate + assert @tournament.matches.count == 36 + assert @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count == 4 + assert @tournament.matches.select{|m| m.bracket_position == "Semis"}.count == 2 + assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count == 2 + assert @tournament.matches.select{|m| m.bracket_position == "1/2"}.count == 1 + assert @tournament.matches.select{|m| m.bracket_position == "3/4"}.count == 1 + assert @tournament.matches.select{|m| m.bracket_position == "5/6"}.count == 1 + assert @tournament.matches.select{|m| m.bracket_position == "7/8"}.count == 1 + assert @tournament.matches.select{|m| m.bracket_position == "Pool"}.count == 24 + assert @tournament.weights.first.pools == 8 + end + + test "Seeded wrestlers go to correct pool" do + GenerateTournamentMatches.new(@tournament).generate + guy10 = @tournament.wrestlers.select{|w| w.name == "Guy10"}.first + guy2 = @tournament.wrestlers.select{|w| w.name == "Guy2"}.first + guy3 = @tournament.wrestlers.select{|w| w.name == "Guy3"}.first + guy4 = @tournament.wrestlers.select{|w| w.name == "Guy4"}.first + guy5 = @tournament.wrestlers.select{|w| w.name == "Guy5"}.first + guy6 = @tournament.wrestlers.select{|w| w.name == "Guy6"}.first + guy7 = @tournament.wrestlers.select{|w| w.name == "Guy7"}.first + guy8 = @tournament.wrestlers.select{|w| w.name == "Guy8"}.first + assert guy10.pool == 1 + assert guy2.pool == 2 + assert guy3.pool == 3 + assert guy4.pool == 4 + assert guy5.pool == 5 + assert guy6.pool == 6 + assert guy7.pool == 7 + assert guy8.pool == 8 + end + + test "Loser names set up correctly" do + GenerateTournamentMatches.new(@tournament).generate + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 1}.first.loser1_name == "Winner Pool 1" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 1}.first.loser2_name == "Winner Pool 8" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 2}.first.loser1_name == "Winner Pool 4" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 2}.first.loser2_name == "Winner Pool 5" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 3}.first.loser1_name == "Winner Pool 2" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 3}.first.loser2_name == "Winner Pool 7" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 4}.first.loser1_name == "Winner Pool 3" + assert @tournament.matches.select{|m| m.bracket_position == "Quarter" && m.bracket_position_number == 4}.first.loser2_name == "Winner Pool 6" + quarters = @tournament.matches.reload.select{|m| m.bracket_position == "Quarter"} + assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{quarters.select{|m| m.bracket_position_number == 1}.first.bout_number}" + assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{quarters.select{|m| m.bracket_position_number == 2}.first.bout_number}" + assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis" && m.bracket_position_number == 2}.first.loser1_name == "Loser of #{quarters.select{|m| m.bracket_position_number == 3}.first.bout_number}" + assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis" && m.bracket_position_number == 2}.first.loser2_name == "Loser of #{quarters.select{|m| m.bracket_position_number == 4}.first.bout_number}" + thirdFourth = @tournament.matches.reload.select{|m| m.bracket_position == "3/4"}.first + seventhEighth = @tournament.matches.reload.select{|m| m.bracket_position == "7/8"}.first + consoSemis = @tournament.matches.reload.select{|m| m.bracket_position == "Conso Semis"} + assert seventhEighth.loser1_name == "Loser of #{consoSemis.select{|m| m.bracket_position_number == 1}.first.bout_number}" + assert seventhEighth.loser2_name == "Loser of #{consoSemis.select{|m| m.bracket_position_number == 2}.first.bout_number}" + end + + test "Each wrestler has two pool matches" do + GenerateTournamentMatches.new(@tournament).generate + @tournament.wrestlers.each do |wrestler| + assert wrestler.pool_matches.size == 2 + end + end + + test "Placement points are given when moving through bracket" do + GenerateTournamentMatches.new(@tournament).generate + match = @tournament.matches.select{|m| m.bracket_position == "Quarter"}.first + wrestler = @tournament.wrestlers.select{|w| w.name == "Guy10"}.first + match.w1 = wrestler.id + match.save + assert wrestler.reload.placement_points == 3 + + match2 = @tournament.matches.select{|m| m.bracket_position == "Semis"}.first + match2.w1 = wrestler.id + match2.save + assert wrestler.reload.placement_points == 9 + end +end