mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-18 19:18:27 +00:00
Simplify construction a bit on some methods
This commit is contained in:
@@ -3,7 +3,7 @@ class Pool
|
||||
@pools = weight.pools
|
||||
@pool = 1
|
||||
while @pool <= @pools
|
||||
matches = roundRobin(weight.wrestlers, weight, tournament , matches)
|
||||
matches = roundRobin(weight.wrestlers, weight, tournament, matches)
|
||||
@pool += 1
|
||||
end
|
||||
return matches
|
||||
@@ -12,19 +12,16 @@ class Pool
|
||||
def roundRobin(wrestlers,weight,tournament,matches)
|
||||
@wrestlers = wrestlers.select{|w| w.generatePoolNumber == @pool}.to_a
|
||||
@poolMatches = RoundRobinTournament.schedule(@wrestlers).reverse
|
||||
@poolMatches.each_with_index do |b,index|
|
||||
@poolMatches.each_with_index do |b, index|
|
||||
round = index + 1
|
||||
@bout = b.map
|
||||
@bout.each do |bout|
|
||||
if bout[0] != nil and bout[1] != nil
|
||||
@match = Match.new
|
||||
@match.w1 = bout[0].id
|
||||
@match.w2 = bout[1].id
|
||||
@match.weight_id = weight.id
|
||||
@match.round = index + 1
|
||||
@match = Match.new(w1: bout[0].id, w2: bout[1].id, weight_id: weight.id, round: round)
|
||||
matches << @match
|
||||
end
|
||||
end
|
||||
end
|
||||
return matches
|
||||
matches
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,6 @@ class Wrestler < ActiveRecord::Base
|
||||
|
||||
def generatePoolNumber
|
||||
@pool = self.weight.returnPoolNumber(self)
|
||||
return @pool
|
||||
end
|
||||
|
||||
def boutByRound(round,matches)
|
||||
|
||||
@@ -7,7 +7,6 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
def createTournament(numberOfWrestlers)
|
||||
@count = 1
|
||||
@id = 6000 + numberOfWrestlers
|
||||
@tournament3 = Tournament.new
|
||||
@tournament3.id = @id
|
||||
@@ -26,17 +25,18 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
@weight3.id = @id
|
||||
@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
|
||||
numberOfWrestlers.times do |x|
|
||||
count = x + 1
|
||||
@wrestler2 = Wrestler.new(
|
||||
name: "Guy #{count}",
|
||||
school_id: @id,
|
||||
weight_id: @id,
|
||||
original_seed: count,
|
||||
season_loss: 0,
|
||||
season_win: 0,
|
||||
criteria: nil
|
||||
)
|
||||
@wrestler2.save
|
||||
@count = @count + 1
|
||||
end
|
||||
return @tournament3
|
||||
end
|
||||
@@ -61,11 +61,6 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
|
||||
test "found tournament" do
|
||||
refute_nil @tournament
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user