From 432903e7a91671cc6736fc40283c95cffe749b0a Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Mon, 22 Feb 2021 13:42:25 +0000 Subject: [PATCH] Fixed small bug in modified 16 man double elim brackets --- .../bracket_advancement/double_elimination_advance.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/services/bracket_advancement/double_elimination_advance.rb b/app/services/bracket_advancement/double_elimination_advance.rb index 82e301b..1fd6982 100644 --- a/app/services/bracket_advancement/double_elimination_advance.rb +++ b/app/services/bracket_advancement/double_elimination_advance.rb @@ -28,17 +28,18 @@ class DoubleEliminationAdvance update_new_match(new_match, get_wrestler_number) elsif @last_match.bracket_position == "Conso Semis" # if its a regular double elim - if Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@next_match_position_number.ceil,@wrestler.weight_id).first.loser1_name != nil + if @wrestler.tournament.tournament_type.include? "Regular Double Elimination" new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","3/4",@next_match_position_number.ceil,@wrestler.weight_id).first update_new_match(new_match, get_wrestler_number) # if it's a special bracket where consolations wrestler for 5th - else + elsif @wrestler.tournament.tournament_type.include? "Modified 16 Man Double Elimination" new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","5/6",@next_match_position_number.ceil,@wrestler.weight_id).first update_new_match(new_match, get_wrestler_number) end elsif @last_match.bracket_position == "Conso Quarter" next_round_matches = Match.where("weight_id = ? and bracket_position = ?", @wrestler.weight_id, "Conso Semis").sort_by{|m| m.round} this_round_matches = Match.where("weight_id = ? and round = ? and bracket_position = ?", @wrestler.weight_id, @last_match.round, "Conso Quarter") + # bracket position is different depending on if a semi loser is dropping or if there are 4 conso quarter matches if next_round_matches.size == this_round_matches.size # if a semi loser is dropping down new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@last_match.bracket_position_number,@wrestler.weight_id).first