mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-01 12:15:25 +00:00
Added tests for modified double elimination, added a 1-8 place modified double elimination, and renamed regular double elimination
This commit is contained in:
@@ -29,7 +29,15 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket","Modified 16 Man Double Elimination","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"]
|
||||
end
|
||||
|
||||
def number_of_placers
|
||||
if self.tournament_type.include? "1-8"
|
||||
return 8
|
||||
elsif self.tournament_type.include? "1-6"
|
||||
return 6
|
||||
end
|
||||
end
|
||||
|
||||
def create_pre_defined_weights(weight_classes)
|
||||
@@ -112,7 +120,7 @@ class Tournament < ActiveRecord::Base
|
||||
|
||||
def modified_sixteen_man_number_of_wrestlers
|
||||
error_string = ""
|
||||
if self.tournament_type == "Modified 16 Man Double Elimination"
|
||||
if self.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
|
||||
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 12}
|
||||
weights_with_too_many_wrestlers.each do |weight|
|
||||
|
||||
@@ -15,8 +15,8 @@ class AdvanceWrestler
|
||||
|
||||
def advance_raw
|
||||
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
||||
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type == "Modified 16 Man Double Elimination" or
|
||||
@tournament.tournament_type == "Double Elimination 1-6"
|
||||
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or
|
||||
@tournament.tournament_type.include? "Regular Double Elimination"
|
||||
end
|
||||
|
||||
def pool_to_bracket_advancement
|
||||
|
||||
@@ -33,12 +33,12 @@ class GenerateTournamentMatches
|
||||
def generate_raw
|
||||
standardStartingActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket"
|
||||
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
postMatchCreationActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket"
|
||||
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
end
|
||||
|
||||
def standardStartingActions
|
||||
|
||||
@@ -10,6 +10,7 @@ class ModifiedSixteenManGenerateLoserNames
|
||||
conso_round_2(matches_by_weight)
|
||||
conso_round_3(matches_by_weight)
|
||||
third_fourth(matches_by_weight)
|
||||
seventh_eighth(matches_by_weight)
|
||||
save_matches(matches_by_weight)
|
||||
matches_by_weight = @tournament.matches.where(weight_id: w.id).reload
|
||||
advance_bye_matches_championship(matches_by_weight)
|
||||
@@ -55,11 +56,17 @@ class ModifiedSixteenManGenerateLoserNames
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "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 Semis"}.first.bout_number}"
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.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|
|
||||
if match.w1 == nil or match.w2 == nil
|
||||
puts match.bout_number
|
||||
match.finished = 1
|
||||
match.win_type = "BYE"
|
||||
if match.w1 != nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ModifiedSixteenManMatchGeneration
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
@number_of_placers = @tournament.number_of_placers
|
||||
end
|
||||
|
||||
def generate_matches
|
||||
@@ -57,6 +58,9 @@ class ModifiedSixteenManMatchGeneration
|
||||
create_matchup(nil,nil,"1/2",1,5,weight)
|
||||
create_matchup(nil,nil,"3/4",1,5,weight)
|
||||
create_matchup(nil,nil,"5/6",1,5,weight)
|
||||
if @number_of_placers >= 8
|
||||
create_matchup(nil,nil,"7/8",1,5,weight)
|
||||
end
|
||||
end
|
||||
|
||||
def wrestler_with_seed(seed,weight)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class SixteenManDoubleEliminationMatchGeneration
|
||||
def initialize( weight )
|
||||
@weight = weight
|
||||
@number_of_placers = @weight.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def generate_matches_for_weight
|
||||
|
||||
@@ -26,8 +26,8 @@ class CalculateWrestlerTeamScore
|
||||
|
||||
def placement_points
|
||||
return PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
|
||||
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
class DoubleEliminationPlacementPoints
|
||||
def initialize(wrestler)
|
||||
@wrestler = wrestler
|
||||
if wrestler.tournament.tournament_type == "Double Elimination 1-6"
|
||||
@number_of_placers = 6
|
||||
end
|
||||
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def calc_points
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class ModifiedSixteenManPlacementPoints
|
||||
def initialize(wrestler)
|
||||
@wrestler = wrestler
|
||||
@number_of_placers = 6
|
||||
@wrestler = wrestler
|
||||
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def calc_points
|
||||
@@ -17,6 +18,10 @@ class ModifiedSixteenManPlacementPoints
|
||||
return PlacementPoints.new(@number_of_placers).fifthPlace
|
||||
elsif bracket_position_size("5/6") > 0
|
||||
return PlacementPoints.new(@number_of_placers).sixthPlace
|
||||
elsif won_bracket_position_size("7/8") > 0
|
||||
return PlacementPoints.new(@number_of_placers).seventhPlace
|
||||
elsif bracket_position_size("Conso Semis") > 0 and @number_of_placers >= 8
|
||||
return PlacementPoints.new(@number_of_placers).eighthPlace
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -106,7 +106,7 @@ table.smallText tr td { font-size: 10px; }
|
||||
<%= render 'fourPoolSemiBracket' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" %>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
|
||||
</td>
|
||||
|
||||
@@ -1,131 +1,48 @@
|
||||
<h4>Championship Bracket</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-1">
|
||||
<% @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name_round_one %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name_round_one %><span></span></li>
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-2">
|
||||
<% @matches.select{|m|m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-5">
|
||||
<li></li>
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
1st
|
||||
<li></li>
|
||||
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 2-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Quarter"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 3-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Semis"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 4-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "1/2"} %>
|
||||
<% @winner_place = "1st" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<h4>3/4 place match</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<li> </li>
|
||||
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
3rd
|
||||
|
||||
<li> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "3/4"} %>
|
||||
<% @winner_place = "3rd" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<h4>Consolation Bracket</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-1">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
<li> </li>
|
||||
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-2">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-5">
|
||||
<li> </li>
|
||||
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
5th
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso" and m.round == 2} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 2-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Quarter"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 3-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Semis"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 4-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
|
||||
<% @winner_place = "5th" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<% if @tournament.number_of_placers >= 8 %>
|
||||
<h4>7/8 place match</h4>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>
|
||||
<% @winner_place = "7th" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -3,6 +3,6 @@
|
||||
<% end %>
|
||||
<% if @tournament.tournament_type == "Pool to bracket" %>
|
||||
<%= render 'pool_bracket_director_actions' %>
|
||||
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" or @tournament.tournament_type == "Double Elimination 1-6" %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<%= render 'bracket_director_actions' %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user