diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index d23a683..818f4c9 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -124,6 +124,14 @@ class Wrestler < ActiveRecord::Base pool_matches = allMatches.select{|m| m.bracket_position == "Pool"} pool_matches.select{|m| m.poolNumber == self.generatePoolNumber} end + + def hasAPoolBye + if weight.poolRounds(allMatches) > poolMatches.size + return true + else + return false + end + end def championshipAdvancementWins matchesWon.select{|m| m.bracket_position == "Quarter" or m.bracket_position == "Semis"} diff --git a/app/services/wrestler_services/calculate_wrestler_team_score.rb b/app/services/wrestler_services/calculate_wrestler_team_score.rb index fc7b0d8..d63d23f 100644 --- a/app/services/wrestler_services/calculate_wrestler_team_score.rb +++ b/app/services/wrestler_services/calculate_wrestler_team_score.rb @@ -34,7 +34,11 @@ class CalculateWrestlerTeamScore def poolPoints if @tournament.tournament_type == "Pool to bracket" - (@wrestler.poolWins.size * 2) + if @wrestler.poolWins.size >= 1 and @wrestler.hasAPoolBye == true + ((@wrestler.poolWins.size * 2) + 2) + else + (@wrestler.poolWins.size * 2) + end else 0 end diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index cb5382c..613193a 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -402,7 +402,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler2 = Wrestler.where("name = ?", "Guy3").first #Won four in pool - assert_equal 20, wrestler1.totalTeamPoints + assert_equal 22, wrestler1.totalTeamPoints #Won two in pool assert_equal 16, wrestler2.totalTeamPoints end @@ -466,25 +466,25 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "bonus points major" do endMatchWithMajor(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first - assert_equal 3, wrestler1.teamPointsEarned + assert_equal 5, wrestler1.teamPointsEarned end test "bonus points pin" do endMatchWithPin(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first - assert_equal 4, wrestler1.teamPointsEarned + assert_equal 6, wrestler1.teamPointsEarned end test "bonus points tech fall" do endMatchWithTech(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first - assert_equal 3.5, wrestler1.teamPointsEarned + assert_equal 5.5, wrestler1.teamPointsEarned end test "pool team points win" do endMatch(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first - assert_equal 2, wrestler1.teamPointsEarned + assert_equal 4, wrestler1.teamPointsEarned end test "advancement points fourPoolsToQuarter Quarter" do @@ -558,10 +558,10 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "Conso bracket wins are 1pt" do elevenManBracketToSemis - assert_equal 5, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned + assert_equal 7, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned endMatch(5006,"Guy17") - assert_equal 9, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned + assert_equal 11, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned end test "One pool placement points" do