1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-11 16:01:56 +00:00

Extras do not score points but still get tie breaker criteria

This commit is contained in:
2015-12-30 15:13:09 +00:00
parent 1bfa09d47d
commit 6ed2bdf547
3 changed files with 25 additions and 3 deletions

View File

@@ -130,10 +130,10 @@ class PoolOrder
def teamPoints def teamPoints
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.totalTeamPoints pointsArray << w.teamPointsEarned
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.totalTeamPoints == mostPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.teamPointsEarned == mostPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)

View File

@@ -16,7 +16,11 @@ class Wrestler < ActiveRecord::Base
end end
def totalTeamPoints def totalTeamPoints
teamPointsEarned - totalDeductedPoints if self.extra
return 0
else
teamPointsEarned - totalDeductedPoints
end
end end
def teamPointsEarned def teamPointsEarned

View File

@@ -212,6 +212,15 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
endMatch(6007,"Guy19",matches) endMatch(6007,"Guy19",matches)
end end
def extraDoesNotScoreTeamPoints
matches = @matches
wrestlerName = "Guy22"
wrestler = Wrestler.find(translateNameToId(wrestlerName))
wrestler.extra = true
wrestler.save
endMatch(1013,"Guy22",matches)
end
def endMatch(bout,winner,matches) def endMatch(bout,winner,matches)
match = Match.where(bout_number: bout).first match = Match.where(bout_number: bout).first
match.finished = 1 match.finished = 1
@@ -541,5 +550,14 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
assert_equal 3, wrestler.placementPoints assert_equal 3, wrestler.placementPoints
end end
test "extra does not score points but does get pool criteria" do
extraDoesNotScoreTeamPoints
wrestler = Wrestler.where("name = ?", "Guy22").first
assert_equal 0, wrestler.totalTeamPoints
assert_equal 1, wrestler.teamPointsEarned
end
end end