1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Put finals in same round

This commit is contained in:
2015-12-07 15:24:42 +00:00
parent 5a09c60a41
commit d28e95ed31
4 changed files with 28 additions and 11 deletions

View File

@@ -21,9 +21,19 @@ module GeneratesTournamentMatches
end
def generateMatches
moveFinalsMatchesToLastRound
assignBouts
assignLoserNames
assignFirstMatchesToMats
end
def moveFinalsMatchesToLastRound
finalsRound = self.totalRounds
finalsMatches = self.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
finalsMatches. each do |m|
m.round = finalsRound
m.save
end
end
end

View File

@@ -50,6 +50,6 @@ class Tournament < ActiveRecord::Base
end
def totalRounds
self.matches.sort_by{|m| m.bout_number}.last.round
self.matches.sort_by{|m| m.round}.last.round
end
end

View File

@@ -9,7 +9,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
end
def showMatches
matches = Match.where(weight_id: 5)
matches = Match.where(weight_id: 4)
# matches = @matches.select{|m| m.weight_id == 4}
matches.each do |m|
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}"
@@ -177,19 +177,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
def elevenManBracketToFinals
elevenManBracketToSemis
matches = @matches
endMatch(5006,"Guy11",matches)
endMatch(5007,"Guy12",matches)
endMatch(5008,"Guy16",matches)
endMatch(5009,"Guy17",matches)
endMatch(5004,"Guy11",matches)
endMatch(5005,"Guy12",matches)
endMatch(5006,"Guy16",matches)
endMatch(5007,"Guy17",matches)
end
def elevenManBracketFinished
elevenManBracketToFinals
matches = @matches
endMatch(6002,"Guy11",matches)
endMatch(6003,"Guy14",matches)
endMatch(6004,"Guy16",matches)
endMatch(6005,"Guy19",matches)
endMatch(6004,"Guy11",matches)
endMatch(6005,"Guy14",matches)
endMatch(6006,"Guy16",matches)
endMatch(6007,"Guy19",matches)
end
def endMatch(bout,winner,matches)
@@ -457,5 +457,4 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
end
end

View File

@@ -248,5 +248,13 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
matches = @tournament.matches.order(:bout_number)
assert_equal 'Mat1', matches.first.mat.name
end
test "finals matches in last round" do
lastRound = @tournament.totalRounds
finalsMatches = @tournament.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
finalsMatches.each do |m|
assert_equal lastRound, m.round
end
end
end