mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Compare commits
6 Commits
9d51ef7b51
...
e36de59971
| Author | SHA1 | Date | |
|---|---|---|---|
| e36de59971 | |||
| 329c01db79 | |||
| 4cdc9e7df1 | |||
| 1f43fdf8fa | |||
| f6aff5a753 | |||
| 3dabc16a82 |
@@ -29,7 +29,7 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket","Modified 16 Man Double Elimination 1-6","Modified 16 Man Double Elimination 1-8","Regular Double Elimination 1-6"]
|
||||
["Pool to bracket","Modified 16 Man Double Elimination 1-6","Modified 16 Man Double Elimination 1-8","Regular Double Elimination 1-6","Regular Double Elimination 1-8"]
|
||||
end
|
||||
|
||||
def number_of_placers
|
||||
|
||||
@@ -10,6 +10,7 @@ class SixteenManDoubleEliminationGenerateLoserNames
|
||||
conso_round_3(matches_by_weight)
|
||||
conso_round_5(matches_by_weight)
|
||||
fifth_sixth(matches_by_weight)
|
||||
seventh_eighth(matches_by_weight)
|
||||
save_matches(matches_by_weight)
|
||||
matches_by_weight = @weight.matches.reload
|
||||
advance_bye_matches_championship(matches_by_weight)
|
||||
@@ -64,6 +65,13 @@ class SixteenManDoubleEliminationGenerateLoserNames
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def seventh_eighth(matches)
|
||||
matches.select{|m| m.bracket_position == "7/8"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
match.loser1_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.first.bout_number}"
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def advance_bye_matches_championship(matches)
|
||||
matches.select{|m| m.round == 1 and m.bracket_position == "Bracket"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
|
||||
@@ -58,6 +58,9 @@ class SixteenManDoubleEliminationMatchGeneration
|
||||
create_matchup(nil,nil,"1/2",1,6,weight)
|
||||
create_matchup(nil,nil,"3/4",1,6,weight)
|
||||
create_matchup(nil,nil,"5/6",1,6,weight)
|
||||
if @number_of_placers >= 8
|
||||
create_matchup(nil,nil,"7/8",1,6,weight)
|
||||
end
|
||||
end
|
||||
|
||||
def wrestler_with_seed(seed,weight)
|
||||
|
||||
@@ -20,7 +20,7 @@ class DoubleEliminationPlacementPoints
|
||||
elsif won_bracket_position_size("7/8") > 0
|
||||
return PlacementPoints.new(@number_of_placers).seventhPlace
|
||||
elsif bracket_position_size("Conso Quarter") > 0 and @number_of_placers >= 8
|
||||
return PlacementPoints.new(@number_of_placers).eigthPlace
|
||||
return PlacementPoints.new(@number_of_placers).eighthPlace
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<li>Tournament Types
|
||||
<ul>
|
||||
<li>Pool to bracket (adhears to 5 match per day rule)</li>
|
||||
<li>Double elimination 16 man and 8 man</li>
|
||||
<li>Regular Double Elimination 16 man and 8 man. Options for placing 1st-6th or 1st-8th.</li>
|
||||
<li>Modified 16 Man Double Elimination 1-6. Options for placing 1st-6th or 1st-8th. Adhears to 5 match per day rule.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Team point calculation</li>
|
||||
@@ -60,9 +61,23 @@
|
||||
<li>Eight pools of 3 (2 matches each) to a quarter final bracket - 17-24 wrestlers, place 1-8.</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Double Elimination Information</h3>
|
||||
<h3>Regular Double Elimination Information</h3>
|
||||
<p>Right now, double elimination brackets only support 8 and 16 man brackets (4-16 wrestlers). Cross bracketing will happen every other round. 16 man in quarter finals, 8 man in semi finals.</p>
|
||||
<h4>Double elimination scoring</h4>
|
||||
<p>Regular Double Elimination 1-6 places 1st through 6th. Regular Double Elimination 1-8 places 1st through 8th.</p>
|
||||
<h4>Regular Double Elimination scoring</h4>
|
||||
<ul>
|
||||
<li>Championship win: 2pt</li>
|
||||
<li>Consolation win: 1pt</li>
|
||||
<li>Win by major: 1pt extra</li>
|
||||
<li>Win by tech: 1.5pt extra</li>
|
||||
<li>Win by fall, default, dq, etc: 2pt extra</li>
|
||||
<li>BYE points: 2pts if you have a bye in the championship bracket and win the next match. 1pt if you have a bye in the consolation bracket and win the next match.</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Modified 16 Man Double Elimination Information</h3>
|
||||
<p>Adhears to 5 match per day rule. Allows a 16 man bracket without anyone wrestling more than 5 matches. Semi Final losers wrestle for 3rd. Anyone who loses before the Semi Finals wrestle a consolation bracket for 5th.</p>
|
||||
<p>Modified 16 Man Double Elimination 1-6 places 1st through 6th. Modified 16 Man Double Elimination 1-8 places 1st through 8th.</p>
|
||||
<h4>Modified 16 Man Double Elimination scoring (same as Regular Double Elimination)</h4>
|
||||
<ul>
|
||||
<li>Championship win: 2pt</li>
|
||||
<li>Consolation win: 1pt</li>
|
||||
@@ -127,7 +142,7 @@
|
||||
<br>
|
||||
<h3>Future Plans</h3>
|
||||
<br>
|
||||
<p>Future development plans to support 32 and 64 man double elimination as well as modified (5 per day match rule) 16 and 32 man double elimination brackets are underway.</p>
|
||||
<p>Future development plans to support 32 and 64 man regulard double elimination, modified (5 per day match rule) 32 man double elimination, and true second double elimination brackets are underway.</p>
|
||||
<br>
|
||||
<h3>Contact</h3>
|
||||
<br>
|
||||
|
||||
@@ -110,7 +110,7 @@ table.smallText tr td { font-size: 10px; }
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
|
||||
</td>
|
||||
<% elsif @tournament.tournament_type == "Double Elimination 1-6" %>
|
||||
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<%= render 'double_elimination_bracket' %>
|
||||
</td>
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
<%= f.label :tournament_type %><br>
|
||||
<%= f.select :tournament_type, @tournament.tournament_types %>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
See About page for information on tournament types: <%= link_to "About", "/static_pages/about" %>
|
||||
<p>For double elimination tournaments, 1-6 places 1st through 6th and 1-8 places 1st through 8th.</p>
|
||||
</div>
|
||||
<%= f.hidden_field :user_id, :value => current_user.id %>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
require 'test_helper'
|
||||
|
||||
class EightManDoubleEliminationSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "8 man double elimination" do
|
||||
create_double_elim_tournament_single_weight_1_6(6)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test3", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test4"
|
||||
assert semis.second.reload.wrestler1.name == "Test3"
|
||||
assert semis.second.reload.wrestler2.name == "Test2"
|
||||
winner_by_name("Test4",semis.first)
|
||||
winner_by_name("Test2",semis.second)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.loser1_name == "BYE"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.loser2_name == "BYE"
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test3"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test6"
|
||||
winner_by_name("Test5",conso_semis.first)
|
||||
winner_by_name("Test1",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test4"
|
||||
assert first_finals.reload.wrestler2.name == "Test2"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test5"
|
||||
assert third_finals.reload.wrestler2.name == "Test1"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test3"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test6"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManMatchGeneration < ActionDispatch::IntegrationTest
|
||||
class DoubleEliminationSixteenManSixPlacesMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight_1_6(14)
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
||||
class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
@@ -13,57 +13,7 @@ class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
||||
match.save
|
||||
end
|
||||
|
||||
test "8 man double elimination" do
|
||||
create_double_elim_tournament_single_weight_1_6(6)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test3", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test4"
|
||||
assert semis.second.reload.wrestler1.name == "Test3"
|
||||
assert semis.second.reload.wrestler2.name == "Test2"
|
||||
winner_by_name("Test4",semis.first)
|
||||
winner_by_name("Test2",semis.second)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.loser1_name == "BYE"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.loser2_name == "BYE"
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test3"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test6"
|
||||
winner_by_name("Test5",conso_semis.first)
|
||||
winner_by_name("Test1",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test4"
|
||||
assert first_finals.reload.wrestler2.name == "Test2"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test5"
|
||||
assert third_finals.reload.wrestler2.name == "Test1"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test3"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test6"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
|
||||
test "16 man double elimination" do
|
||||
test "16 man double elimination placing 6 run through" do
|
||||
create_double_elim_tournament_single_weight_1_6(14)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManEightPlacesMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
|
||||
end
|
||||
|
||||
test "Match generation works" do
|
||||
assert @tournament.matches.count == 30
|
||||
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 == "Bracket" and m.round == 1}.count == 8
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.count == 4
|
||||
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" and m.round == 3}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count == 2
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count == 2
|
||||
end
|
||||
|
||||
test "Seeded wrestlers have correct first line" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert match1.wrestler1.bracket_line == 1
|
||||
assert match1.loser2_name == "BYE"
|
||||
|
||||
assert match2.wrestler1.bracket_line == 8
|
||||
assert match2.wrestler2.bracket_line == 9
|
||||
|
||||
assert match3.wrestler1.bracket_line == 5
|
||||
assert match3.wrestler2.bracket_line == 12
|
||||
|
||||
assert match4.wrestler1.bracket_line == 4
|
||||
assert match4.wrestler2.bracket_line == 14
|
||||
|
||||
assert match5.wrestler1.bracket_line == 3
|
||||
assert match5.wrestler2.bracket_line == 13
|
||||
|
||||
assert match6.wrestler1.bracket_line == 6
|
||||
assert match6.wrestler2.bracket_line == 11
|
||||
|
||||
assert match7.wrestler1.bracket_line == 7
|
||||
assert match7.wrestler2.bracket_line == 10
|
||||
|
||||
assert match8.wrestler1.bracket_line == 2
|
||||
assert match8.loser2_name == "BYE"
|
||||
end
|
||||
|
||||
test "Byes are advanced correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
|
||||
assert match1.wrestler1.name == "Test1"
|
||||
assert match2.wrestler2.name == "Test2"
|
||||
end
|
||||
|
||||
test "Loser names set up correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser1_name == "BYE"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{match2.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser1_name == "Loser of #{match3.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser2_name == "Loser of #{match4.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser1_name == "Loser of #{match5.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser2_name == "Loser of #{match6.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser1_name == "Loser of #{match7.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser2_name == "BYE"
|
||||
|
||||
quarter1 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
quarter2 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 2}.first
|
||||
quarter3 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 3}.first
|
||||
quarter4 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
consoround2match1 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 1}.first
|
||||
consoround2match2 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 2}.first
|
||||
consoround2match3 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 3}.first
|
||||
consoround2match4 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 4}.first
|
||||
|
||||
assert consoround2match1.loser1_name == "Loser of #{quarter4.bout_number}"
|
||||
assert consoround2match2.loser1_name == "Loser of #{quarter3.bout_number}"
|
||||
assert consoround2match3.loser1_name == "Loser of #{quarter2.bout_number}"
|
||||
assert consoround2match4.loser1_name == "Loser of #{quarter1.bout_number}"
|
||||
|
||||
semis1 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 1}.first
|
||||
semis2 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 2}.first
|
||||
consosemis1 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 1}.first
|
||||
consosemis2 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 2}.first
|
||||
|
||||
assert consosemis1.loser1_name == "Loser of #{semis1.bout_number}"
|
||||
assert consosemis2.loser1_name == "Loser of #{semis2.bout_number}"
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{consosemis1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{consosemis2.bout_number}"
|
||||
|
||||
consoquarters1 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.bracket_position_number == 1}.first
|
||||
consoquarters2 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.bracket_position_number == 2}.first
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{consoquarters1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{consoquarters2.bout_number}"
|
||||
end
|
||||
|
||||
test "Placement points are given when moving through bracket" do
|
||||
match = @tournament.matches.select{|m| m.bracket_position == "Semis"}.first
|
||||
wrestler = get_wrestler_by_name("Test1")
|
||||
match.w1 = wrestler.id
|
||||
match.save
|
||||
|
||||
match2 = @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.first
|
||||
wrestler2 = get_wrestler_by_name("Test2")
|
||||
match2.w1 = wrestler2.id
|
||||
match2.save
|
||||
|
||||
match3 = @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.first
|
||||
wrestler3 = get_wrestler_by_name("Test3")
|
||||
match3.w1 = wrestler3.id
|
||||
match3.save
|
||||
|
||||
assert wrestler.reload.placement_points == 3
|
||||
assert wrestler2.reload.placement_points == 3
|
||||
assert wrestler3.reload.placement_points == 1
|
||||
end
|
||||
|
||||
test "Run through all matches works" do
|
||||
@tournament.matches.sort_by{ |match| match.bout_number }.each do |match|
|
||||
match.reload
|
||||
if match.finished != 1 and match.w1 and match.w2
|
||||
match.winner_id = match.w1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.finished = 1
|
||||
match.save
|
||||
end
|
||||
end
|
||||
assert @tournament.matches.reload.select{|m| m.finished == 0}.count == 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,118 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "16 man double elimination place 1-8" do
|
||||
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test5", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 4}.first)
|
||||
winner_by_name("Test13", round1.select{|m| m.bracket_position_number == 5}.first)
|
||||
winner_by_name("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||
|
||||
quarter = matches.select{|m| m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert quarter.first.reload.wrestler1.name == "Test1"
|
||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||
|
||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round2.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||
|
||||
winner_by_name("Test1", quarter.first)
|
||||
winner_by_name("Test5", quarter.second)
|
||||
winner_by_name("Test13", quarter.third)
|
||||
winner_by_name("Test10", quarter.fourth)
|
||||
winner_by_name("Test12", conso_round2.second)
|
||||
winner_by_name("Test3", conso_round2.third)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test5"
|
||||
assert semis.second.reload.wrestler1.name == "Test13"
|
||||
assert semis.second.reload.wrestler2.name == "Test10"
|
||||
|
||||
conso_round3 = matches.select{|m| m.bracket_position == "Conso" and m.round == 3}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round3.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_round3.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round3.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_round3.second.reload.wrestler2.name == "Test12"
|
||||
assert conso_round3.third.reload.wrestler1.name == "Test4"
|
||||
assert conso_round3.third.reload.wrestler2.name == "Test3"
|
||||
assert conso_round3.fourth.reload.wrestler1.name == "Test9"
|
||||
assert conso_round3.fourth.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test2", conso_round3.first)
|
||||
winner_by_name("Test6", conso_round3.second)
|
||||
winner_by_name("Test3", conso_round3.third)
|
||||
winner_by_name("Test9", conso_round3.fourth)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test6"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test3"
|
||||
assert conso_quarter.second.reload.wrestler2.name == "Test9"
|
||||
|
||||
winner_by_name("Test5",semis.first)
|
||||
winner_by_name("Test10",semis.second)
|
||||
winner_by_name("Test2", conso_quarter.first)
|
||||
winner_by_name("Test3", conso_quarter.second)
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test13"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
||||
|
||||
winner_by_name("Test2",conso_semis.first)
|
||||
winner_by_name("Test3",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
seventh_finals = matches.select{|m| m.bracket_position == "7/8"}.first
|
||||
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test5"
|
||||
assert first_finals.reload.wrestler2.name == "Test10"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test2"
|
||||
assert third_finals.reload.wrestler2.name == "Test3"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test1"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test13"
|
||||
|
||||
assert seventh_finals.reload.wrestler1.name == "Test6"
|
||||
assert seventh_finals.reload.wrestler2.name == "Test9"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user