mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 13:15:27 +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
|
||||
|
||||
Reference in New Issue
Block a user