mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-12 16:25:41 +00:00
Tie breaker for team score
This commit is contained in:
@@ -45,6 +45,7 @@ class Poolorder
|
|||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { headToHead }
|
||||||
end
|
end
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { deductedPoints }
|
||||||
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { teamPoints }
|
||||||
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -83,6 +84,19 @@ class Poolorder
|
|||||||
end
|
end
|
||||||
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
|
def coinFlip
|
||||||
wrestler = wrestlersWithSamePoints.sample
|
wrestler = wrestlersWithSamePoints.sample
|
||||||
addPointsToWrestlersAhead(wrestler)
|
addPointsToWrestlersAhead(wrestler)
|
||||||
|
|||||||
@@ -6,14 +6,21 @@ class School < ActiveRecord::Base
|
|||||||
|
|
||||||
#calculate score here
|
#calculate score here
|
||||||
def score
|
def score
|
||||||
#Add score per wrestler. Calculate score in wrestler model.
|
calcScore
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def calcScore
|
def calcScore
|
||||||
#calc and save score
|
totalWrestlerPoints - totalDeductedPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def totalWrestlerPoints
|
||||||
|
points = 0
|
||||||
|
self.wrestlers.each do |w|
|
||||||
|
points = points + w.totalTeamPoints
|
||||||
|
end
|
||||||
|
points
|
||||||
|
end
|
||||||
|
|
||||||
def totalDeductedPoints
|
def totalDeductedPoints
|
||||||
points = 0
|
points = 0
|
||||||
self.deductedPoints.each do |d|
|
self.deductedPoints.each do |d|
|
||||||
@@ -21,48 +28,4 @@ class School < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
points
|
points
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class Wrestler < ActiveRecord::Base
|
|||||||
allMatches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last
|
allMatches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def totalTeamPoints
|
||||||
|
points = 0.0
|
||||||
|
points = points + (poolWins.size * 1) + (pinWins.size * 2) + (techWins.size * 1.5) + (majorWins.size * 1)
|
||||||
|
end
|
||||||
|
|
||||||
def totalDeductedPoints
|
def totalDeductedPoints
|
||||||
points = 0
|
points = 0
|
||||||
self.deductedPoints.each do |d|
|
self.deductedPoints.each do |d|
|
||||||
@@ -81,9 +86,27 @@ class Wrestler < ActiveRecord::Base
|
|||||||
def finishedPoolMatches
|
def finishedPoolMatches
|
||||||
finishedMatches.select{|m| m.bracket_position == "Pool"}
|
finishedMatches.select{|m| m.bracket_position == "Pool"}
|
||||||
end
|
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
|
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
|
def seasonWinPercentage
|
||||||
@win = self.season_win.to_f
|
@win = self.season_win.to_f
|
||||||
@loss = self.season_loss.to_f
|
@loss = self.season_loss.to_f
|
||||||
|
|||||||
@@ -67,6 +67,16 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
deduct.save
|
deduct.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
|
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||||
|
endMatch(1004,"Guy9",matches)
|
||||||
|
endMatch(1005,"Guy7",matches)
|
||||||
|
endMatchWithMajor(2004,"Guy3",matches)
|
||||||
|
endMatch(2005,"Guy9",matches)
|
||||||
|
endMatch(3004,"Guy7",matches)
|
||||||
|
endMatch(3005,"Guy3",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
|
||||||
@@ -77,6 +87,18 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
|||||||
match.mat_id = mat.id
|
match.mat_id = mat.id
|
||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def endMatchWithMajor(bout,winner,matches)
|
||||||
|
match = matches.select{|m| m.bout_number == bout}.first
|
||||||
|
match.finished = 1
|
||||||
|
match.winner_id = translateNameToId(winner)
|
||||||
|
match.win_type = "Major"
|
||||||
|
#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
|
||||||
@@ -128,4 +150,16 @@ 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 teamPoints tie breaker finalist guy 3" do
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy3").first
|
||||||
|
nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
|
assert_equal 6000, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "nine man conso finals teamPoints tie breaker guy 9" do
|
||||||
|
nineManBracketPoolTwoGuyThreeTeamPoints
|
||||||
|
wrestler = Wrestler.where("name = ?", "Guy9").first
|
||||||
|
assert_equal 6001, wrestler.boutByRound(6)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user