mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-08 15:29:20 +00:00
Added tie breakers for most pins most techs and most majors
This commit is contained in:
@@ -46,6 +46,9 @@ class Poolorder
|
|||||||
end
|
end
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { teamPoints }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { teamPoints }
|
||||||
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostFalls }
|
||||||
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs }
|
||||||
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -97,6 +100,45 @@ class Poolorder
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mostFalls
|
||||||
|
pointsArray = []
|
||||||
|
wrestlersWithSamePoints.each do |w|
|
||||||
|
pointsArray << w.pinWins.size
|
||||||
|
end
|
||||||
|
mostPoints = pointsArray.max
|
||||||
|
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.pinWins.size == mostPoints}
|
||||||
|
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||||
|
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||||
|
addPoints(wr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def mostTechs
|
||||||
|
pointsArray = []
|
||||||
|
wrestlersWithSamePoints.each do |w|
|
||||||
|
pointsArray << w.techWins.size
|
||||||
|
end
|
||||||
|
mostPoints = pointsArray.max
|
||||||
|
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.techWins.size == mostPoints}
|
||||||
|
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||||
|
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||||
|
addPoints(wr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def mostMajors
|
||||||
|
pointsArray = []
|
||||||
|
wrestlersWithSamePoints.each do |w|
|
||||||
|
pointsArray << w.majorWins.size
|
||||||
|
end
|
||||||
|
mostPoints = pointsArray.max
|
||||||
|
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.majorWins.size == mostPoints}
|
||||||
|
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||||
|
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||||
|
addPoints(wr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def coinFlip
|
def coinFlip
|
||||||
wrestler = wrestlersWithSamePoints.sample
|
wrestler = wrestlersWithSamePoints.sample
|
||||||
addPointsToWrestlersAhead(wrestler)
|
addPointsToWrestlersAhead(wrestler)
|
||||||
|
|||||||
@@ -77,6 +77,30 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
endMatch(3005,"Guy3",matches)
|
endMatch(3005,"Guy3",matches)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nineManBracketPoolTwoGuyThreeMostPins
|
||||||
|
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
|
endMatchWithMajor(1004,"Guy9",matches)
|
||||||
|
endMatch(1005,"Guy7",matches)
|
||||||
|
endMatchWithPin(2004,"Guy3",matches)
|
||||||
|
endMatchWithMajor(2005,"Guy9",matches)
|
||||||
|
endMatch(3004,"Guy7",matches)
|
||||||
|
endMatch(3005,"Guy3",matches)
|
||||||
|
end
|
||||||
|
|
||||||
|
def nineManBracketPoolOneGuyEightMostTechs
|
||||||
|
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
|
endMatchWithTech(1002,"Guy8",matches)
|
||||||
|
endMatchWithMajor(1003,"Guy10",matches)
|
||||||
|
endMatchWithMajor(2002,"Guy2",matches)
|
||||||
|
endMatchWithTech(2003,"Guy8",matches)
|
||||||
|
endMatchWithMajor(3002,"Guy10",matches)
|
||||||
|
endMatchWithMajor(3003,"Guy2",matches)
|
||||||
|
endMatch(4002,"Guy8",matches)
|
||||||
|
endMatchWithMajor(4003,"Guy2",matches)
|
||||||
|
endMatchWithMajor(5002,"Guy10",matches)
|
||||||
|
endMatch(5003,"Guy5",matches)
|
||||||
|
end
|
||||||
|
|
||||||
def endMatch(bout,winner,matches)
|
def endMatch(bout,winner,matches)
|
||||||
match = matches.select{|m| m.bout_number == bout}.first
|
match = matches.select{|m| m.bout_number == bout}.first
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
@@ -99,6 +123,28 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def endMatchWithTech(bout,winner,matches)
|
||||||
|
match = matches.select{|m| m.bout_number == bout}.first
|
||||||
|
match.finished = 1
|
||||||
|
match.winner_id = translateNameToId(winner)
|
||||||
|
match.win_type = "Tech Fall"
|
||||||
|
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
||||||
|
mat = @tournament.mats.first
|
||||||
|
match.mat_id = mat.id
|
||||||
|
match.save
|
||||||
|
end
|
||||||
|
|
||||||
|
def endMatchWithPin(bout,winner,matches)
|
||||||
|
match = matches.select{|m| m.bout_number == bout}.first
|
||||||
|
match.finished = 1
|
||||||
|
match.winner_id = translateNameToId(winner)
|
||||||
|
match.win_type = "Pin"
|
||||||
|
#Need to manually assign mat_id because thise weight class is not currently assigned a mat
|
||||||
|
mat = @tournament.mats.first
|
||||||
|
match.mat_id = mat.id
|
||||||
|
match.save
|
||||||
|
end
|
||||||
|
|
||||||
def translateNameToId(wrestler)
|
def translateNameToId(wrestler)
|
||||||
Wrestler.where("name = ?", wrestler).first.id
|
Wrestler.where("name = ?", wrestler).first.id
|
||||||
end
|
end
|
||||||
@@ -162,4 +208,29 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
assert_equal 6001, wrestler.boutByRound(6)
|
assert_equal 6001, wrestler.boutByRound(6)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "nine man pool 2 mostPins tie breaker finalist guy 3" do
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
nineManBracketPoolTwoGuyThreeMostPins
|
||||||
|
assert_equal 6000, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "nine man conso finals mostPins tie breaker guy 9" do
|
||||||
|
nineManBracketPoolTwoGuyThreeMostPins
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
assert_equal 6001, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "nine man pool 1 mostTechs tie breaker finalist guy 8" do
|
||||||
|
nineManBracketPoolOneGuyEightMostTechs
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy8").first
|
||||||
|
assert_equal 6000, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "nine man conso finals mostTechs tie breaker guy 10" do
|
||||||
|
nineManBracketPoolOneGuyEightMostTechs
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy10").first
|
||||||
|
assert_equal 6001, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user