mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Test 5 match rule for bracket size 5-16
This commit is contained in:
@@ -40,10 +40,6 @@ class StaticPagesController < ApplicationController
|
|||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = Tournament.find(@weight.tournament_id)
|
||||||
@matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id}
|
@matches = @tournament.upcomingMatches.select{|m| m.weight_id == @weight.id}
|
||||||
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
||||||
#@poolOneWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 1}
|
|
||||||
#@poolTwoWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 2}
|
|
||||||
#@poolThreeWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 3}
|
|
||||||
#@poolFourWrestlers = @wrestlers.select{|w| w.generatePoolNumber == 4}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class Weight < ActiveRecord::Base
|
|||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
has_many :wrestlers, dependent: :destroy
|
has_many :wrestlers, dependent: :destroy
|
||||||
|
|
||||||
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds
|
attr_accessor :pools, :bracket_size, :bracket_type, :poolRounds, :totalRounds
|
||||||
|
|
||||||
def pools
|
def pools
|
||||||
@wrestlers = self.wrestlers
|
@wrestlers = self.wrestlers
|
||||||
@@ -95,7 +95,7 @@ class Weight < ActiveRecord::Base
|
|||||||
elsif self.wrestlers.size == 11 || self.wrestlers.size == 12
|
elsif self.wrestlers.size == 11 || self.wrestlers.size == 12
|
||||||
return "fourPoolsToQuarter"
|
return "fourPoolsToQuarter"
|
||||||
elsif self.wrestlers.size > 12 && self.wrestlers.size <= 16
|
elsif self.wrestlers.size > 12 && self.wrestlers.size <= 16
|
||||||
return "fourPoolsToSemi"
|
return "fourPoolsToSemi"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,4 +117,9 @@ class Weight < ActiveRecord::Base
|
|||||||
return @poolMatches.sort_by{|m| m.round}.last.round
|
return @poolMatches.sort_by{|m| m.round}.last.round
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def totalRounds(matches)
|
||||||
|
@matchups = matches.select{|m| m.weight_id == self.id}
|
||||||
|
return @matchups.sort_by{|m| m.round}.last.round
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
2
test/fixtures/schools.yml
vendored
2
test/fixtures/schools.yml
vendored
@@ -9,3 +9,5 @@ two:
|
|||||||
id: 2
|
id: 2
|
||||||
name: Grove City
|
name: Grove City
|
||||||
tournament_id: 1
|
tournament_id: 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
test/fixtures/tournaments.yml
vendored
2
test/fixtures/tournaments.yml
vendored
@@ -9,3 +9,5 @@ one:
|
|||||||
matchups_array:
|
matchups_array:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
test/fixtures/weights.yml
vendored
1
test/fixtures/weights.yml
vendored
@@ -27,4 +27,3 @@ five:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,61 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
|||||||
@genMatchups = @tournament.generateMatchups
|
@genMatchups = @tournament.generateMatchups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def createTournament(numberOfWrestlers)
|
||||||
|
@count = 1
|
||||||
|
@id = 6000 + numberOfWrestlers
|
||||||
|
@tournament3 = Tournament.new
|
||||||
|
@tournament3.id = @id
|
||||||
|
@tournament3.name = "Something"
|
||||||
|
@tournament3.address = "Some Place"
|
||||||
|
@tournament3.director = "Some Guy"
|
||||||
|
@tournament3.director_email = "test@test.com"
|
||||||
|
@tournament3.save
|
||||||
|
@school3 = School.new
|
||||||
|
@school3.id = @id
|
||||||
|
@school3.name = "Shit Show"
|
||||||
|
@school3.tournament_id = @id
|
||||||
|
@school3.save
|
||||||
|
@weight3 = Weight.new
|
||||||
|
@weight3.id = @id
|
||||||
|
@weight3.max = 350
|
||||||
|
@weight3.tournament_id = @id
|
||||||
|
@weight3.save
|
||||||
|
until @count > numberOfWrestlers do
|
||||||
|
@wrestler2 = Wrestler.new
|
||||||
|
@wrestler2.name = "Guy #{@count}"
|
||||||
|
@wrestler2.school_id = @id
|
||||||
|
@wrestler2.weight_id = @id
|
||||||
|
@wrestler2.original_seed = @count
|
||||||
|
@wrestler2.season_loss = 0
|
||||||
|
@wrestler2.season_win = 0
|
||||||
|
@wrestler2.criteria = nil
|
||||||
|
@wrestler2.save
|
||||||
|
@count = @count + 1
|
||||||
|
end
|
||||||
|
return @tournament3
|
||||||
|
end
|
||||||
|
|
||||||
|
def checkForByeInPool(tournament)
|
||||||
|
@matchups = tournament.generateMatchups
|
||||||
|
tournament.weights.each do |w|
|
||||||
|
w.wrestlers.each do |wr|
|
||||||
|
@round = 1
|
||||||
|
if w.totalRounds(@matchups) > 5
|
||||||
|
until @round > w.poolRounds(@matchups) do
|
||||||
|
if wr.boutByRound(@round,@matchups) == "BYE"
|
||||||
|
@message = "BYE"
|
||||||
|
end
|
||||||
|
@round = @round + 1
|
||||||
|
end
|
||||||
|
assert_equal "BYE", @message
|
||||||
|
@message = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
test "the truth" do
|
test "the truth" do
|
||||||
assert true
|
assert true
|
||||||
end
|
end
|
||||||
@@ -58,5 +113,14 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
|||||||
assert_equal @genMatchup.w1_name, @matchup.w1_name
|
assert_equal @genMatchup.w1_name, @matchup.w1_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "test if a wrestler can exceed five matches" do
|
||||||
|
@count = 5
|
||||||
|
until @count > 16 do
|
||||||
|
@tournament2 = createTournament(@count)
|
||||||
|
checkForByeInPool(@tournament2)
|
||||||
|
@count = @count + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#todo test crazy movements through each bracket?
|
#todo test crazy movements through each bracket?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user