mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-04 05:43:47 +00:00
Tie breaker for team score
This commit is contained in:
@@ -45,6 +45,7 @@ class Poolorder
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
||||
end
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { teamPoints }
|
||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||
end
|
||||
|
||||
@@ -83,6 +84,19 @@ class Poolorder
|
||||
end
|
||||
end
|
||||
|
||||
def teamPoints
|
||||
pointsArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
pointsArray << w.totalTeamPoints
|
||||
end
|
||||
mostPoints = pointsArray.max
|
||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.totalTeamPoints == mostPoints}
|
||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
end
|
||||
|
||||
def coinFlip
|
||||
wrestler = wrestlersWithSamePoints.sample
|
||||
addPointsToWrestlersAhead(wrestler)
|
||||
|
||||
@@ -6,14 +6,21 @@ class School < ActiveRecord::Base
|
||||
|
||||
#calculate score here
|
||||
def score
|
||||
#Add score per wrestler. Calculate score in wrestler model.
|
||||
return 0
|
||||
calcScore
|
||||
end
|
||||
|
||||
def calcScore
|
||||
#calc and save score
|
||||
totalWrestlerPoints - totalDeductedPoints
|
||||
end
|
||||
|
||||
def totalWrestlerPoints
|
||||
points = 0
|
||||
self.wrestlers.each do |w|
|
||||
points = points + w.totalTeamPoints
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def totalDeductedPoints
|
||||
points = 0
|
||||
self.deductedPoints.each do |d|
|
||||
@@ -21,48 +28,4 @@ class School < ActiveRecord::Base
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def poolWins
|
||||
|
||||
end
|
||||
|
||||
def pinDefaultDqWins
|
||||
|
||||
end
|
||||
|
||||
def techFallWins
|
||||
|
||||
end
|
||||
|
||||
def majorWins
|
||||
|
||||
end
|
||||
|
||||
def firstPlace
|
||||
|
||||
end
|
||||
|
||||
def secondPlace
|
||||
|
||||
end
|
||||
|
||||
def thirdPlace
|
||||
|
||||
end
|
||||
|
||||
def fourthPlace
|
||||
|
||||
end
|
||||
|
||||
def fifthPlace
|
||||
|
||||
end
|
||||
|
||||
def sixthPlace
|
||||
|
||||
end
|
||||
|
||||
def seventhPlace
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,6 +14,11 @@ class Wrestler < ActiveRecord::Base
|
||||
allMatches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last
|
||||
end
|
||||
|
||||
def totalTeamPoints
|
||||
points = 0.0
|
||||
points = points + (poolWins.size * 1) + (pinWins.size * 2) + (techWins.size * 1.5) + (majorWins.size * 1)
|
||||
end
|
||||
|
||||
def totalDeductedPoints
|
||||
points = 0
|
||||
self.deductedPoints.each do |d|
|
||||
@@ -81,9 +86,27 @@ class Wrestler < ActiveRecord::Base
|
||||
def finishedPoolMatches
|
||||
finishedMatches.select{|m| m.bracket_position == "Pool"}
|
||||
end
|
||||
def poolWins
|
||||
allMatches.select{|m| m.winner_id == self.id && m.bracket_position == "Pool"}
|
||||
|
||||
def matchesWon
|
||||
allMatches.select{|m| m.winner_id == self.id}
|
||||
end
|
||||
|
||||
def poolWins
|
||||
matchesWon.select{|m| m.bracket_position == "Pool"}
|
||||
end
|
||||
|
||||
def pinWins
|
||||
matchesWon.select{|m| m.win_type == "Pin" || m.win_type == "Forfeit" || m.win_type == "Injury Default" || m.win_type == "Default" || m.win_type == "DQ"}
|
||||
end
|
||||
|
||||
def techWins
|
||||
matchesWon.select{|m| m.win_type == "Tech Fall" }
|
||||
end
|
||||
|
||||
def majorWins
|
||||
matchesWon.select{|m| m.win_type == "Major" }
|
||||
end
|
||||
|
||||
def seasonWinPercentage
|
||||
@win = self.season_win.to_f
|
||||
@loss = self.season_loss.to_f
|
||||
|
||||
Reference in New Issue
Block a user