diff --git a/app/models/pool_order.rb b/app/models/pool_order.rb index cf87713..97155d4 100644 --- a/app/models/pool_order.rb +++ b/app/models/pool_order.rb @@ -130,10 +130,10 @@ class PoolOrder def teamPoints pointsArray = [] wrestlersWithSamePoints.each do |w| - pointsArray << w.totalTeamPoints + pointsArray << w.teamPointsEarned end mostPoints = pointsArray.max - wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.totalTeamPoints == mostPoints} + wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.teamPointsEarned == mostPoints} addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) wrestlersWithLeastDeductedPoints.each do |wr| addPoints(wr) diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index dd78e58..a891a38 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -16,7 +16,11 @@ class Wrestler < ActiveRecord::Base end def totalTeamPoints - teamPointsEarned - totalDeductedPoints + if self.extra + return 0 + else + teamPointsEarned - totalDeductedPoints + end end def teamPointsEarned diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index 5d027f5..c78ff71 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -212,6 +212,15 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest endMatch(6007,"Guy19",matches) 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) match = Match.where(bout_number: bout).first match.finished = 1 @@ -541,5 +550,14 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest assert_equal 3, wrestler.placementPoints 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