mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-09 15:42:09 +00:00
Put finals in same round
This commit is contained in:
@@ -21,9 +21,19 @@ module GeneratesTournamentMatches
|
|||||||
end
|
end
|
||||||
|
|
||||||
def generateMatches
|
def generateMatches
|
||||||
|
moveFinalsMatchesToLastRound
|
||||||
assignBouts
|
assignBouts
|
||||||
assignLoserNames
|
assignLoserNames
|
||||||
assignFirstMatchesToMats
|
assignFirstMatchesToMats
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -50,6 +50,6 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def totalRounds
|
def totalRounds
|
||||||
self.matches.sort_by{|m| m.bout_number}.last.round
|
self.matches.sort_by{|m| m.round}.last.round
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
def showMatches
|
def showMatches
|
||||||
matches = Match.where(weight_id: 5)
|
matches = Match.where(weight_id: 4)
|
||||||
# matches = @matches.select{|m| m.weight_id == 4}
|
# matches = @matches.select{|m| m.weight_id == 4}
|
||||||
matches.each do |m|
|
matches.each do |m|
|
||||||
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}"
|
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
|
def elevenManBracketToFinals
|
||||||
elevenManBracketToSemis
|
elevenManBracketToSemis
|
||||||
matches = @matches
|
matches = @matches
|
||||||
endMatch(5006,"Guy11",matches)
|
endMatch(5004,"Guy11",matches)
|
||||||
endMatch(5007,"Guy12",matches)
|
endMatch(5005,"Guy12",matches)
|
||||||
endMatch(5008,"Guy16",matches)
|
endMatch(5006,"Guy16",matches)
|
||||||
endMatch(5009,"Guy17",matches)
|
endMatch(5007,"Guy17",matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
def elevenManBracketFinished
|
def elevenManBracketFinished
|
||||||
elevenManBracketToFinals
|
elevenManBracketToFinals
|
||||||
matches = @matches
|
matches = @matches
|
||||||
endMatch(6002,"Guy11",matches)
|
endMatch(6004,"Guy11",matches)
|
||||||
endMatch(6003,"Guy14",matches)
|
endMatch(6005,"Guy14",matches)
|
||||||
endMatch(6004,"Guy16",matches)
|
endMatch(6006,"Guy16",matches)
|
||||||
endMatch(6005,"Guy19",matches)
|
endMatch(6007,"Guy19",matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
def endMatch(bout,winner,matches)
|
def endMatch(bout,winner,matches)
|
||||||
@@ -457,5 +457,4 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -248,5 +248,13 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
|||||||
matches = @tournament.matches.order(:bout_number)
|
matches = @tournament.matches.order(:bout_number)
|
||||||
assert_equal 'Mat1', matches.first.mat.name
|
assert_equal 'Mat1', matches.first.mat.name
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user