mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-13 09:09:18 +00:00
Updated double elim match generation and loser name to use hashes instead of structs as well as fixing the matchup of 4v13 and 3v14 in 16 man brackets.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class DoubleEliminationGenerateLoserNames
|
class DoubleEliminationGenerateLoserNames
|
||||||
def initialize( tournament )
|
def initialize(tournament)
|
||||||
@tournament = tournament
|
@tournament = tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -11,29 +11,67 @@ class DoubleEliminationGenerateLoserNames
|
|||||||
end
|
end
|
||||||
|
|
||||||
def define_losername_championship_mappings(bracket_size)
|
def define_losername_championship_mappings(bracket_size)
|
||||||
# [conso_round, conso_bracket_position, championship_round, championship_bracket_position, cross_bracket, both_wrestlers]
|
# Use hashes instead of arrays for mappings
|
||||||
# cross_bracket is true or false. crossing should happen every other round.
|
|
||||||
# both_wrestlers defines if you're filling out loser1_name and loser2_name or just loser1_name
|
|
||||||
# don't need to define 3/4, 5/6, or 7/8 those happen in the assign_loser_names_for_weight method
|
|
||||||
# except for bracket_size of 4
|
|
||||||
case bracket_size
|
case bracket_size
|
||||||
when 4 then
|
when 4
|
||||||
return [
|
[
|
||||||
[@tournament.total_rounds, "3/4", 1, "Semis", false, true]
|
{
|
||||||
|
conso_round: @tournament.total_rounds,
|
||||||
|
conso_bracket_position: "3/4",
|
||||||
|
championship_round: 1,
|
||||||
|
championship_bracket_position: "Semis",
|
||||||
|
cross_bracket: false,
|
||||||
|
both_wrestlers: true
|
||||||
|
}
|
||||||
]
|
]
|
||||||
when 8 then
|
when 8
|
||||||
return [
|
[
|
||||||
[2, "Conso Quarter", 1, "Quarter", false, true],
|
{
|
||||||
[3, "Conso Semis", 2, "Semis", true, false]
|
conso_round: 2,
|
||||||
|
conso_bracket_position: "Conso Quarter",
|
||||||
|
championship_round: 1,
|
||||||
|
championship_bracket_position: "Quarter",
|
||||||
|
cross_bracket: false,
|
||||||
|
both_wrestlers: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
conso_round: 3,
|
||||||
|
conso_bracket_position: "Conso Semis",
|
||||||
|
championship_round: 2,
|
||||||
|
championship_bracket_position: "Semis",
|
||||||
|
cross_bracket: true,
|
||||||
|
both_wrestlers: false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
when 16 then
|
when 16
|
||||||
return [
|
[
|
||||||
[2, "Conso", 1, "Bracket", false, true],
|
{
|
||||||
[3, "Conso", 2, "Quarter", true, false],
|
conso_round: 2,
|
||||||
[5, "Conso Semis", 4, "Semis", false, false]
|
conso_bracket_position: "Conso",
|
||||||
|
championship_round: 1,
|
||||||
|
championship_bracket_position: "Bracket",
|
||||||
|
cross_bracket: false,
|
||||||
|
both_wrestlers: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
conso_round: 3,
|
||||||
|
conso_bracket_position: "Conso",
|
||||||
|
championship_round: 2,
|
||||||
|
championship_bracket_position: "Quarter",
|
||||||
|
cross_bracket: true,
|
||||||
|
both_wrestlers: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
conso_round: 5,
|
||||||
|
conso_bracket_position: "Conso Semis",
|
||||||
|
championship_round: 4,
|
||||||
|
championship_bracket_position: "Semis",
|
||||||
|
cross_bracket: false,
|
||||||
|
both_wrestlers: false
|
||||||
|
}
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -45,76 +83,85 @@ class DoubleEliminationGenerateLoserNames
|
|||||||
loser_name_championship_mappings = define_losername_championship_mappings(bracket_size)
|
loser_name_championship_mappings = define_losername_championship_mappings(bracket_size)
|
||||||
|
|
||||||
loser_name_championship_mappings.each do |mapping|
|
loser_name_championship_mappings.each do |mapping|
|
||||||
conso_round = mapping[0]
|
conso_round = mapping[:conso_round]
|
||||||
conso_bracket_position = mapping[1]
|
conso_bracket_position = mapping[:conso_bracket_position]
|
||||||
championship_round = mapping[2]
|
championship_round = mapping[:championship_round]
|
||||||
championship_bracket_position = mapping[3]
|
championship_bracket_position = mapping[:championship_bracket_position]
|
||||||
cross_bracket = mapping[4]
|
cross_bracket = mapping[:cross_bracket]
|
||||||
both_wrestlers = mapping[5]
|
both_wrestlers = mapping[:both_wrestlers]
|
||||||
|
|
||||||
conso_matches = matches_by_weight.select{|match| match.round == conso_round && match.bracket_position == conso_bracket_position}.sort_by{|match| match.bracket_position_number}
|
conso_matches = matches_by_weight.select do |match|
|
||||||
championship_matches = matches_by_weight.select{|match| match.round == championship_round && match.bracket_position == championship_bracket_position}.sort_by{|match| match.bracket_position_number}
|
match.round == conso_round && match.bracket_position == conso_bracket_position
|
||||||
if cross_bracket
|
end.sort_by(&:bracket_position_number)
|
||||||
conso_matches = conso_matches.reverse!
|
|
||||||
end
|
championship_matches = matches_by_weight.select do |match|
|
||||||
|
match.round == championship_round && match.bracket_position == championship_bracket_position
|
||||||
|
end.sort_by(&:bracket_position_number)
|
||||||
|
|
||||||
|
conso_matches.reverse! if cross_bracket
|
||||||
|
|
||||||
championship_bracket_position_number = 1
|
championship_bracket_position_number = 1
|
||||||
conso_matches.each do |match|
|
conso_matches.each do |match|
|
||||||
bout_number1 = championship_matches.select{|bout_match| bout_match.bracket_position_number == championship_bracket_position_number}.first.bout_number
|
bout_number1 = championship_matches.find do |bout_match|
|
||||||
|
bout_match.bracket_position_number == championship_bracket_position_number
|
||||||
|
end.bout_number
|
||||||
|
|
||||||
match.loser1_name = "Loser of #{bout_number1}"
|
match.loser1_name = "Loser of #{bout_number1}"
|
||||||
if both_wrestlers
|
if both_wrestlers
|
||||||
championship_bracket_position_number += 1
|
championship_bracket_position_number += 1
|
||||||
bout_number2 = championship_matches.select{|bout_match| bout_match.bracket_position_number == championship_bracket_position_number}.first.bout_number
|
bout_number2 = championship_matches.find do |bout_match|
|
||||||
|
bout_match.bracket_position_number == championship_bracket_position_number
|
||||||
|
end.bout_number
|
||||||
match.loser2_name = "Loser of #{bout_number2}"
|
match.loser2_name = "Loser of #{bout_number2}"
|
||||||
end
|
end
|
||||||
championship_bracket_position_number += 1
|
championship_bracket_position_number += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
conso_semi_matches = matches_by_weight.select{|match| match.bracket_position == "Conso Semis"}
|
conso_semi_matches = matches_by_weight.select { |match| match.bracket_position == "Conso Semis" }
|
||||||
conso_quarter_matches = matches_by_weight.select{|match| match.bracket_position == "Conso Quarter"}
|
conso_quarter_matches = matches_by_weight.select { |match| match.bracket_position == "Conso Quarter" }
|
||||||
|
|
||||||
if number_of_placers >= 6 && weight.wrestlers.size >= 5
|
if number_of_placers >= 6 && weight.wrestlers.size >= 5
|
||||||
five_six_match = matches_by_weight.select{|match| match.bracket_position == "5/6"}.first
|
five_six_match = matches_by_weight.find { |match| match.bracket_position == "5/6" }
|
||||||
bout_number1 = conso_semi_matches.select{|match| match.bracket_position_number == 1}.first.bout_number
|
bout_number1 = conso_semi_matches.find { |match| match.bracket_position_number == 1 }.bout_number
|
||||||
bout_number2 = conso_semi_matches.select{|match| match.bracket_position_number == 2}.first.bout_number
|
bout_number2 = conso_semi_matches.find { |match| match.bracket_position_number == 2 }.bout_number
|
||||||
five_six_match.loser1_name = "Loser of #{bout_number1}"
|
five_six_match.loser1_name = "Loser of #{bout_number1}"
|
||||||
five_six_match.loser2_name = "Loser of #{bout_number2}"
|
five_six_match.loser2_name = "Loser of #{bout_number2}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if number_of_placers >= 8 && weight.wrestlers.size >= 7
|
if number_of_placers >= 8 && weight.wrestlers.size >= 7
|
||||||
seven_eight_match = matches_by_weight.select{|match| match.bracket_position == "7/8"}.first
|
seven_eight_match = matches_by_weight.find { |match| match.bracket_position == "7/8" }
|
||||||
bout_number1 = conso_quarter_matches.select{|match| match.bracket_position_number == 1}.first.bout_number
|
bout_number1 = conso_quarter_matches.find { |match| match.bracket_position_number == 1 }.bout_number
|
||||||
bout_number2 = conso_quarter_matches.select{|match| match.bracket_position_number == 2}.first.bout_number
|
bout_number2 = conso_quarter_matches.find { |match| match.bracket_position_number == 2 }.bout_number
|
||||||
seven_eight_match.loser1_name = "Loser of #{bout_number1}"
|
seven_eight_match.loser1_name = "Loser of #{bout_number1}"
|
||||||
seven_eight_match.loser2_name = "Loser of #{bout_number2}"
|
seven_eight_match.loser2_name = "Loser of #{bout_number2}"
|
||||||
end
|
end
|
||||||
|
|
||||||
save_matches(matches_by_weight)
|
save_matches(matches_by_weight)
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_matches(matches)
|
def save_matches(matches)
|
||||||
matches.each do |m|
|
matches.each(&:save!)
|
||||||
m.save!
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def advance_bye_matches_championship(matches)
|
def advance_bye_matches_championship(matches)
|
||||||
matches.select{|m| m.round == 1 and (m.bracket_position == "Bracket" or m.bracket_position == "Quarter")}.sort_by{|m| m.bracket_position_number}.each do |match|
|
matches.select do |m|
|
||||||
if match.w1 == nil or match.w2 == nil
|
m.round == 1 && %w[Bracket Quarter].include?(m.bracket_position)
|
||||||
|
end.sort_by(&:bracket_position_number).each do |match|
|
||||||
|
next unless match.w1.nil? || match.w2.nil?
|
||||||
|
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
match.win_type = "BYE"
|
match.win_type = "BYE"
|
||||||
if match.w1 != nil
|
if match.w1
|
||||||
match.winner_id = match.w1
|
match.winner_id = match.w1
|
||||||
match.loser2_name = "BYE"
|
match.loser2_name = "BYE"
|
||||||
match.score = ""
|
elsif match.w2
|
||||||
match.save
|
|
||||||
match.advance_wrestlers
|
|
||||||
elsif match.w2 != nil
|
|
||||||
match.winner_id = match.w2
|
match.winner_id = match.w2
|
||||||
match.loser1_name = "BYE"
|
match.loser1_name = "BYE"
|
||||||
|
end
|
||||||
match.score = ""
|
match.score = ""
|
||||||
match.save
|
match.save
|
||||||
match.advance_wrestlers
|
match.advance_wrestlers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
BracketMatchups = Struct.new(:round_one_matchups, :championship_rounds, :consolation_rounds)
|
|
||||||
|
|
||||||
class DoubleEliminationMatchGeneration
|
class DoubleEliminationMatchGeneration
|
||||||
def initialize( tournament )
|
def initialize(tournament)
|
||||||
@tournament = tournament
|
@tournament = tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -12,33 +10,42 @@ class DoubleEliminationMatchGeneration
|
|||||||
end
|
end
|
||||||
|
|
||||||
def define_bracket_matches(bracket_size)
|
def define_bracket_matches(bracket_size)
|
||||||
# Defined at the top of the file
|
# Use a hash instead of Struct
|
||||||
# BracketMatchups = Struct.new(:round_one_matchups, :championship_rounds, :consolation_rounds)
|
|
||||||
# round_one_matchups are the matchups by seed in the correct order for bracket position.
|
|
||||||
# championship_rounds define [round_number, number_of_matches_in_round, bracket_position]
|
|
||||||
# consolation_rounds define [round_number, number_of_matches_in_round, bracket_position]
|
|
||||||
|
|
||||||
case bracket_size
|
case bracket_size
|
||||||
when 4 then
|
when 4
|
||||||
return BracketMatchups.new(
|
{
|
||||||
[[1, 4, "Semis"], [2, 3, "Semis"]],
|
round_one_matchups: [[1, 4, "Semis"], [2, 3, "Semis"]],
|
||||||
[[2, 1, "1/2"]],
|
championship_rounds: [[2, 1, "1/2"]],
|
||||||
[[2, 1, "3/4"]]
|
consolation_rounds: [[2, 1, "3/4"]]
|
||||||
)
|
}
|
||||||
when 8 then
|
when 8
|
||||||
return BracketMatchups.new(
|
{
|
||||||
[[1, 8, "Quarter"], [4, 5, "Quarter"], [3, 6, "Quarter"], [2, 7, "Quarter"]],
|
round_one_matchups: [
|
||||||
[[2, 2, "Semis"], [4, 1, "1/2"]],
|
[1, 8, "Quarter"], [4, 5, "Quarter"], [3, 6, "Quarter"], [2, 7, "Quarter"]
|
||||||
[[2, 2, "Conso Quarter"], [3, 2, "Conso Semis"], [4, 1, "3/4"]]
|
],
|
||||||
)
|
championship_rounds: [
|
||||||
when 16 then
|
[2, 2, "Semis"], [4, 1, "1/2"]
|
||||||
return BracketMatchups.new(
|
],
|
||||||
[[1, 16, "Bracket"], [8, 9, "Bracket"], [5, 12, "Bracket"], [4, 14, "Bracket"], [3, 13, "Bracket"], [6, 11, "Bracket"], [7, 10, "Bracket"], [2, 15, "Bracket"]],
|
consolation_rounds: [
|
||||||
[[2, 4, "Quarter"], [4, 2, "Semis"], [6, 1, "1/2"]],
|
[2, 2, "Conso Quarter"], [3, 2, "Conso Semis"], [4, 1, "3/4"]
|
||||||
[[2, 4, "Conso"], [3, 4, "Conso"], [4, 2, "Conso Quarter"], [5, 2, "Conso Semis"], [6, 1, "3/4"]]
|
]
|
||||||
)
|
}
|
||||||
|
when 16
|
||||||
|
{
|
||||||
|
round_one_matchups: [
|
||||||
|
[1, 16, "Bracket"], [8, 9, "Bracket"], [5, 12, "Bracket"], [4, 13, "Bracket"],
|
||||||
|
[3, 14, "Bracket"], [6, 11, "Bracket"], [7, 10, "Bracket"], [2, 15, "Bracket"]
|
||||||
|
],
|
||||||
|
championship_rounds: [
|
||||||
|
[2, 4, "Quarter"], [4, 2, "Semis"], [6, 1, "1/2"]
|
||||||
|
],
|
||||||
|
consolation_rounds: [
|
||||||
|
[2, 4, "Conso"], [3, 4, "Conso"], [4, 2, "Conso Quarter"],
|
||||||
|
[5, 2, "Conso Semis"], [6, 1, "3/4"]
|
||||||
|
]
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -48,8 +55,8 @@ class DoubleEliminationMatchGeneration
|
|||||||
bracket_matches = define_bracket_matches(bracket_size)
|
bracket_matches = define_bracket_matches(bracket_size)
|
||||||
|
|
||||||
# Generate round 1 matches
|
# Generate round 1 matches
|
||||||
bracket_matches.round_one_matchups.each_with_index do |matchup, index|
|
bracket_matches[:round_one_matchups].each_with_index do |matchup, index|
|
||||||
matches_this_round = bracket_matches.round_one_matchups.size
|
matches_this_round = bracket_matches[:round_one_matchups].size
|
||||||
bracket_position = matchup[2]
|
bracket_position = matchup[2]
|
||||||
create_matchup_from_seed(
|
create_matchup_from_seed(
|
||||||
matchup[0],
|
matchup[0],
|
||||||
@@ -62,7 +69,7 @@ class DoubleEliminationMatchGeneration
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Generate remaining championship rounds
|
# Generate remaining championship rounds
|
||||||
bracket_matches.championship_rounds.each do |matchup|
|
bracket_matches[:championship_rounds].each do |matchup|
|
||||||
round = matchup[0]
|
round = matchup[0]
|
||||||
matches_this_round = matchup[1]
|
matches_this_round = matchup[1]
|
||||||
bracket_position = matchup[2]
|
bracket_position = matchup[2]
|
||||||
@@ -73,7 +80,7 @@ class DoubleEliminationMatchGeneration
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Generate consolation matches
|
# Generate consolation matches
|
||||||
bracket_matches.consolation_rounds.each do |matchup|
|
bracket_matches[:consolation_rounds].each do |matchup|
|
||||||
round = matchup[0]
|
round = matchup[0]
|
||||||
matches_this_round = matchup[1]
|
matches_this_round = matchup[1]
|
||||||
bracket_position = matchup[2]
|
bracket_position = matchup[2]
|
||||||
@@ -81,7 +88,7 @@ class DoubleEliminationMatchGeneration
|
|||||||
matches_this_round.times do |bracket_position_number|
|
matches_this_round.times do |bracket_position_number|
|
||||||
create_matchup(nil, nil, bracket_position, bracket_position_number + 1, round, weight)
|
create_matchup(nil, nil, bracket_position, bracket_position_number + 1, round, weight)
|
||||||
end
|
end
|
||||||
if weight.wrestlers.size >=5
|
if weight.wrestlers.size >= 5
|
||||||
create_matchup(nil, nil, "5/6", 1, round, weight) if @tournament.number_of_placers >= 6 && matches_this_round == 1
|
create_matchup(nil, nil, "5/6", 1, round, weight) if @tournament.number_of_placers >= 6 && matches_this_round == 1
|
||||||
end
|
end
|
||||||
if weight.wrestlers.size >= 7
|
if weight.wrestlers.size >= 7
|
||||||
@@ -90,20 +97,23 @@ class DoubleEliminationMatchGeneration
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def wrestler_with_seed(seed,weight)
|
def wrestler_with_seed(seed, weight)
|
||||||
wrestler = Wrestler.where("weight_id = ? and bracket_line = ?", weight.id, seed).first
|
wrestler = Wrestler.where("weight_id = ? and bracket_line = ?", weight.id, seed).first
|
||||||
if wrestler
|
wrestler&.id
|
||||||
return wrestler.id
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_matchup_from_seed(w1_seed, w2_seed, bracket_position, bracket_position_number,round,weight)
|
def create_matchup_from_seed(w1_seed, w2_seed, bracket_position, bracket_position_number, round, weight)
|
||||||
create_matchup(wrestler_with_seed(w1_seed,weight),wrestler_with_seed(w2_seed,weight), bracket_position, bracket_position_number,round,weight)
|
create_matchup(
|
||||||
|
wrestler_with_seed(w1_seed, weight),
|
||||||
|
wrestler_with_seed(w2_seed, weight),
|
||||||
|
bracket_position,
|
||||||
|
bracket_position_number,
|
||||||
|
round,
|
||||||
|
weight
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_matchup(w1, w2, bracket_position, bracket_position_number,round,weight)
|
def create_matchup(w1, w2, bracket_position, bracket_position_number, round, weight)
|
||||||
weight.tournament.matches.create(
|
weight.tournament.matches.create(
|
||||||
w1: w1,
|
w1: w1,
|
||||||
w2: w2,
|
w2: w2,
|
||||||
@@ -128,15 +138,11 @@ class DoubleEliminationMatchGeneration
|
|||||||
return nil if bracket_size <= 0 || !bracket_size.is_a?(Integer)
|
return nil if bracket_size <= 0 || !bracket_size.is_a?(Integer)
|
||||||
|
|
||||||
championship_rounds = calculate_championship_rounds(bracket_size)
|
championship_rounds = calculate_championship_rounds(bracket_size)
|
||||||
if championship_rounds == 2
|
return 1 if championship_rounds == 2
|
||||||
return 1
|
return 0 if championship_rounds == 1
|
||||||
elsif
|
|
||||||
championship_rounds == 1
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
extra_powers_of_two = championship_rounds - 3
|
|
||||||
consolation_rounds = championship_rounds + extra_powers_of_two
|
|
||||||
|
|
||||||
consolation_rounds
|
extra_powers_of_two = championship_rounds - 3
|
||||||
|
championship_rounds + extra_powers_of_two
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -40,10 +40,10 @@ class DoubleEliminationSixteenManSixPlacesMatchGeneration < ActionDispatch::Inte
|
|||||||
assert match3.wrestler2.bracket_line == 12
|
assert match3.wrestler2.bracket_line == 12
|
||||||
|
|
||||||
assert match4.wrestler1.bracket_line == 4
|
assert match4.wrestler1.bracket_line == 4
|
||||||
assert match4.wrestler2.bracket_line == 14
|
assert match4.wrestler2.bracket_line == 13
|
||||||
|
|
||||||
assert match5.wrestler1.bracket_line == 3
|
assert match5.wrestler1.bracket_line == 3
|
||||||
assert match5.wrestler2.bracket_line == 13
|
assert match5.wrestler2.bracket_line == 14
|
||||||
|
|
||||||
assert match6.wrestler1.bracket_line == 6
|
assert match6.wrestler1.bracket_line == 6
|
||||||
assert match6.wrestler2.bracket_line == 11
|
assert match6.wrestler2.bracket_line == 11
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
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("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("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("Test14", 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("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
assert quarter.third.reload.wrestler1.name == "Test14"
|
||||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||||
@@ -38,14 +38,14 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
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.first.reload.wrestler2.name == "Test8"
|
||||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
assert conso_round2.second.reload.wrestler2.name == "Test13"
|
||||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||||
|
|
||||||
winner_by_name("Test1", quarter.first)
|
winner_by_name("Test1", quarter.first)
|
||||||
winner_by_name("Test5", quarter.second)
|
winner_by_name("Test5", quarter.second)
|
||||||
winner_by_name("Test13", quarter.third)
|
winner_by_name("Test14", quarter.third)
|
||||||
winner_by_name("Test10", quarter.fourth)
|
winner_by_name("Test10", quarter.fourth)
|
||||||
winner_by_name("Test12", conso_round2.second)
|
winner_by_name("Test12", conso_round2.second)
|
||||||
winner_by_name("Test3", conso_round2.third)
|
winner_by_name("Test3", conso_round2.third)
|
||||||
@@ -53,7 +53,7 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
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.wrestler1.name == "Test1"
|
||||||
assert semis.first.reload.wrestler2.name == "Test5"
|
assert semis.first.reload.wrestler2.name == "Test5"
|
||||||
assert semis.second.reload.wrestler1.name == "Test13"
|
assert semis.second.reload.wrestler1.name == "Test14"
|
||||||
assert semis.second.reload.wrestler2.name == "Test10"
|
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}
|
conso_round3 = matches.select{|m| m.bracket_position == "Conso" and m.round == 3}.sort_by{|m| m.bracket_position_number}
|
||||||
@@ -85,7 +85,7 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
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.wrestler1.name == "Test1"
|
||||||
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
||||||
assert conso_semis.second.reload.wrestler1.name == "Test13"
|
assert conso_semis.second.reload.wrestler1.name == "Test14"
|
||||||
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
||||||
|
|
||||||
winner_by_name("Test2",conso_semis.first)
|
winner_by_name("Test2",conso_semis.first)
|
||||||
@@ -102,7 +102,7 @@ class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::Integrati
|
|||||||
assert third_finals.reload.wrestler2.name == "Test3"
|
assert third_finals.reload.wrestler2.name == "Test3"
|
||||||
|
|
||||||
assert fifth_finals.reload.wrestler1.name == "Test1"
|
assert fifth_finals.reload.wrestler1.name == "Test1"
|
||||||
assert fifth_finals.reload.wrestler2.name == "Test13"
|
assert fifth_finals.reload.wrestler2.name == "Test14"
|
||||||
|
|
||||||
# DEBUG
|
# DEBUG
|
||||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ class DoubleEliminationSixteenManEightPlacesMatchGeneration < ActionDispatch::In
|
|||||||
assert match3.wrestler2.bracket_line == 12
|
assert match3.wrestler2.bracket_line == 12
|
||||||
|
|
||||||
assert match4.wrestler1.bracket_line == 4
|
assert match4.wrestler1.bracket_line == 4
|
||||||
assert match4.wrestler2.bracket_line == 14
|
assert match4.wrestler2.bracket_line == 13
|
||||||
|
|
||||||
assert match5.wrestler1.bracket_line == 3
|
assert match5.wrestler1.bracket_line == 3
|
||||||
assert match5.wrestler2.bracket_line == 13
|
assert match5.wrestler2.bracket_line == 14
|
||||||
|
|
||||||
assert match6.wrestler1.bracket_line == 6
|
assert match6.wrestler1.bracket_line == 6
|
||||||
assert match6.wrestler2.bracket_line == 11
|
assert match6.wrestler2.bracket_line == 11
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
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("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("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("Test14", 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("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
assert quarter.third.reload.wrestler1.name == "Test14"
|
||||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||||
@@ -38,14 +38,14 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
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.first.reload.wrestler2.name == "Test8"
|
||||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
assert conso_round2.second.reload.wrestler2.name == "Test13"
|
||||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||||
|
|
||||||
winner_by_name("Test1", quarter.first)
|
winner_by_name("Test1", quarter.first)
|
||||||
winner_by_name("Test5", quarter.second)
|
winner_by_name("Test5", quarter.second)
|
||||||
winner_by_name("Test13", quarter.third)
|
winner_by_name("Test14", quarter.third)
|
||||||
winner_by_name("Test10", quarter.fourth)
|
winner_by_name("Test10", quarter.fourth)
|
||||||
winner_by_name("Test12", conso_round2.second)
|
winner_by_name("Test12", conso_round2.second)
|
||||||
winner_by_name("Test3", conso_round2.third)
|
winner_by_name("Test3", conso_round2.third)
|
||||||
@@ -53,7 +53,7 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
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.wrestler1.name == "Test1"
|
||||||
assert semis.first.reload.wrestler2.name == "Test5"
|
assert semis.first.reload.wrestler2.name == "Test5"
|
||||||
assert semis.second.reload.wrestler1.name == "Test13"
|
assert semis.second.reload.wrestler1.name == "Test14"
|
||||||
assert semis.second.reload.wrestler2.name == "Test10"
|
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}
|
conso_round3 = matches.select{|m| m.bracket_position == "Conso" and m.round == 3}.sort_by{|m| m.bracket_position_number}
|
||||||
@@ -85,7 +85,7 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
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.wrestler1.name == "Test1"
|
||||||
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
||||||
assert conso_semis.second.reload.wrestler1.name == "Test13"
|
assert conso_semis.second.reload.wrestler1.name == "Test14"
|
||||||
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
||||||
|
|
||||||
winner_by_name("Test2",conso_semis.first)
|
winner_by_name("Test2",conso_semis.first)
|
||||||
@@ -104,7 +104,7 @@ class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::Integra
|
|||||||
assert third_finals.reload.wrestler2.name == "Test3"
|
assert third_finals.reload.wrestler2.name == "Test3"
|
||||||
|
|
||||||
assert fifth_finals.reload.wrestler1.name == "Test1"
|
assert fifth_finals.reload.wrestler1.name == "Test1"
|
||||||
assert fifth_finals.reload.wrestler2.name == "Test13"
|
assert fifth_finals.reload.wrestler2.name == "Test14"
|
||||||
|
|
||||||
assert seventh_finals.reload.wrestler1.name == "Test6"
|
assert seventh_finals.reload.wrestler1.name == "Test6"
|
||||||
assert seventh_finals.reload.wrestler2.name == "Test9"
|
assert seventh_finals.reload.wrestler2.name == "Test9"
|
||||||
|
|||||||
Reference in New Issue
Block a user