mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added most decision points and quickest pin to the tiebreakers
This commit is contained in:
@@ -27,6 +27,17 @@ class Match < ActiveRecord::Base
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def pinTime
|
||||
if self.win_type == "Pin"
|
||||
time = self.score.delete("")
|
||||
minInSeconds = time.partition(':').first.to_i * 60
|
||||
sec = time.partition(':').last.to_i
|
||||
return minInSeconds + sec
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def advance_wrestlers
|
||||
if self.w1 && self.w2
|
||||
|
||||
@@ -49,6 +49,8 @@ class PoolOrder
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostFalls }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostDecisionPointsScored }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { fastestPin }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||
end
|
||||
|
||||
@@ -87,6 +89,44 @@ class PoolOrder
|
||||
end
|
||||
end
|
||||
|
||||
def mostDecisionPointsScored
|
||||
pointsArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
pointsArray << w.decisionPointsScored
|
||||
end
|
||||
mostPoints = pointsArray.max
|
||||
wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decisionPointsScored == mostPoints}
|
||||
addPointsToWrestlersAhead(wrestlersWithMostPoints.first)
|
||||
wrestlersWithMostPoints.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
secondPoints = pointsArray.sort[-2]
|
||||
wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decisionPointsScored == secondPoints}
|
||||
addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first)
|
||||
wrestlersWithSecondMostPoints.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
end
|
||||
|
||||
def fastestPin
|
||||
timeArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
timeArray << w.fastestPin
|
||||
end
|
||||
fastest = timeArray.max
|
||||
wrestlersWithFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == fastest}
|
||||
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
|
||||
wrestlersWithFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
secondFastest = timeArray.sort[-2]
|
||||
wrestlersWithSecondFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == secondFastest}
|
||||
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
|
||||
wrestlersWithSecondFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
end
|
||||
|
||||
def teamPoints
|
||||
pointsArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
|
||||
@@ -157,6 +157,29 @@ class Wrestler < ActiveRecord::Base
|
||||
matchesWon.select{|m| m.win_type == "Major" }
|
||||
end
|
||||
|
||||
def decisionWins
|
||||
matchesWon.select{|m| m.win_type == "Decision" }
|
||||
end
|
||||
|
||||
def decisionPointsScored
|
||||
pointsScored = 0
|
||||
decisionWins.each do |m|
|
||||
scoreOfMatch = m.score.delete(" ")
|
||||
scoreOne = scoreOfMatch.partition('-').first.to_i
|
||||
scoreTwo = scoreOfMatch.partition('-').last.to_i
|
||||
if scoreOne > scoreTwo
|
||||
pointsScored = pointsScored + scoreOne
|
||||
elsif scoreTwo > scoreOne
|
||||
pointsScored = pointsScored + scoreTwo
|
||||
end
|
||||
end
|
||||
pointsScored
|
||||
end
|
||||
|
||||
def fastestPin
|
||||
pinWins.sort_by{|m| m.pinTime}.reverse.first
|
||||
end
|
||||
|
||||
def seasonWinPercentage
|
||||
win = self.season_win.to_f
|
||||
loss = self.season_loss.to_f
|
||||
|
||||
@@ -118,6 +118,26 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
deduct.save
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchExtraPoints(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatchExtraPoints(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy9",matches)
|
||||
endMatch(3004,"Guy7",matches)
|
||||
endMatchExtraPoints(3005,"Guy3",matches)
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeQuickestPin
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchWithQuickPin(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatchWithQuickPin(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy9",matches)
|
||||
endMatch(3004,"Guy7",matches)
|
||||
endMatchWithQuickestPin(3005,"Guy3",matches)
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeTeamPoints
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1004,"Guy9",matches)
|
||||
@@ -197,6 +217,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Decision"
|
||||
match.score = 1-0
|
||||
#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 endMatchExtraPoints(bout,winner,matches)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Decision"
|
||||
match.score = 0-2
|
||||
#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
|
||||
@@ -208,6 +241,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Major"
|
||||
match.score = 8-0
|
||||
#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
|
||||
@@ -230,6 +264,31 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "5:00"
|
||||
#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 endMatchWithQuickestPin(bout,winner,matches)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "0:20"
|
||||
#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 endMatchWithQuickPin(bout,winner,matches)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "1:20"
|
||||
#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
|
||||
@@ -288,6 +347,32 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
assert_equal 6001, wrestler.boutByRound(6)
|
||||
end
|
||||
|
||||
|
||||
|
||||
test "nine man pool 2 mostDecisionPointsScored tie breaker finalist guy 3" do
|
||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||
nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||
assert_equal 6000, wrestler.boutByRound(6)
|
||||
end
|
||||
|
||||
test "nine man conso finals mostDecisionPointsScored tie breaker guy 9" do
|
||||
nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||
assert_equal 6001, wrestler.boutByRound(6)
|
||||
end
|
||||
|
||||
test "nine man pool 2 QuickestPin tie breaker finalist guy 3" do
|
||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||
nineManBracketPoolTwoGuyThreeQuickestPin
|
||||
assert_equal 6000, wrestler.boutByRound(6)
|
||||
end
|
||||
|
||||
test "nine man conso finals QuickestPin tie breaker guy 9" do
|
||||
nineManBracketPoolTwoGuyThreeQuickestPin
|
||||
wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||
assert_equal 6001, wrestler.boutByRound(6)
|
||||
end
|
||||
|
||||
test "nine man pool 2 teamPoints tie breaker finalist guy 3" do
|
||||
wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||
nineManBracketPoolTwoGuyThreeTeamPoints
|
||||
|
||||
Reference in New Issue
Block a user