1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-02 21:24:25 +00:00

Testing team points for pool to bracket

This commit is contained in:
2015-11-17 19:03:34 +00:00
parent 61ed7c9d69
commit 67727c6391
4 changed files with 121 additions and 8 deletions

View File

@@ -7,13 +7,19 @@ class Match < ActiveRecord::Base
after_save do
if self.finished == 1
advance_wrestlers
self.wrestler1.school.calcScore
self.wrestler2.school.calcScore
calcSchoolPoints
end
end
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
def calcSchoolPoints
if self.w1? && self.w2?
wrestler1.school.calcScore
wrestler2.school.calcScore
end
end
def advance_wrestlers
if self.w1? && self.w2?
@w1 = wrestler1

View File

@@ -15,6 +15,10 @@ class Wrestler < ActiveRecord::Base
end
def totalTeamPoints
teamPointsEarned - totalDeductedPoints
end
def teamPointsEarned
points = 0.0
points = points + (poolWins.size * 1) + (pinWins.size * 2) + (techWins.size * 1.5) + (majorWins.size * 1) + placementPoints
end

View File

@@ -37,7 +37,7 @@ ActiveRecord::Schema.define(version: 20151117152454) do
add_index "matches", ["mat_id"], name: "index_matches_on_mat_id"
add_index "matches", ["tournament_id"], name: "index_matches_on_tournament_id"
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2", unique: true
add_index "matches", ["w1", "w2"], name: "index_matches_on_w1_and_w2"
create_table "mats", force: :cascade do |t|
t.string "name"
@@ -80,7 +80,6 @@ ActiveRecord::Schema.define(version: 20151117152454) do
end
add_index "tournaments", ["user_id"], name: "index_tournaments_on_user_id"
add_index "tournaments", ["weigh_in_ref"], name: "index_tournaments_on_weigh_in_ref"
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
@@ -124,7 +123,6 @@ ActiveRecord::Schema.define(version: 20151117152454) do
t.decimal "offical_weight"
end
add_index "wrestlers", ["offical_weight"], name: "index_wrestlers_on_offical_weight"
add_index "wrestlers", ["weight_id"], name: "index_wrestlers_on_weight_id"
end

View File

@@ -14,7 +14,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
end
end
def nineManBracketPoolOneOutrightWinner
def nineManBracketPoolOneOutrightWinnerGuyTwo
matches = @tournament.matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
endMatch(1002,"Guy8",matches)
endMatch(1003,"Guy10",matches)
@@ -150,13 +150,13 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
end
test "nine man outright finals advance" do
nineManBracketPoolOneOutrightWinner
nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler = Wrestler.where("name = ?", "Guy2").first
assert_equal 6000, wrestler.boutByRound(6)
end
test "nine man outright conso finals advance" do
nineManBracketPoolOneOutrightWinner
nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler = Wrestler.where("name = ?", "Guy8").first
assert_equal 6001, wrestler.boutByRound(6)
end
@@ -233,4 +233,109 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
assert_equal 6001, wrestler.boutByRound(6)
end
test "twoPoolsToFinal total points finals" do
nineManBracketPoolOneOutrightWinnerGuyTwo
nineManBracketPoolTwoGuyThreeHeadToHead
wrestler1 = Wrestler.where("name = ?", "Guy2").first
wrestler2 = Wrestler.where("name = ?", "Guy3").first
#Won four in pool
assert_equal 16, wrestler1.totalTeamPoints
#Won two in pool but was deducted a point
assert_equal 13, wrestler2.totalTeamPoints
end
test "advancement points 1/2" do
nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 12, wrestler1.placementPoints
end
test "advancement points 3/4" do
nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler1 = Wrestler.where("name = ?", "Guy8").first
assert_equal 9, wrestler1.placementPoints
end
test "advancement points 5/6" do
end
test "advancement points 7/8" do
end
test "advancement points winner 1/2" do
nineManBracketPoolOneOutrightWinnerGuyTwo
nineManBracketPoolTwoGuyThreeHeadToHead
endMatch(6000,"Guy2",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 16, wrestler1.placementPoints
end
test "advancement points winner 3/4" do
nineManBracketPoolOneOutrightWinnerGuyTwo
nineManBracketPoolTwoGuyThreeHeadToHead
endMatch(6001,"Guy8",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy8").first
assert_equal 10, wrestler1.placementPoints
end
test "advancement points winner 5/6" do
end
test "advancement points winner 7/8" do
end
test "bonus points major" do
endMatchWithMajor(2002,"Guy2",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 2, wrestler1.teamPointsEarned
end
test "bonus points pin" do
endMatchWithPin(2002,"Guy2",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 3, wrestler1.teamPointsEarned
end
test "bonus points tech fall" do
endMatchWithTech(2002,"Guy2",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 2.5, wrestler1.teamPointsEarned
end
test "pool team points win" do
endMatch(2002,"Guy2",@tournament.matches)
wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 1, wrestler1.teamPointsEarned
end
test "advancement points fourPoolsToQuarter Quarter" do
end
test "advancement points fourPoolsToQuarter Semis" do
end
test "advancement points twoPoolsToSemi Semis" do
end
test "advancement points twoPoolsToSemi Conso Semis" do
end
test "advancement points fourPoolsToSemi Semis" do
end
test "advancement points fourPoolsToSemi Conso Semis" do
end
end