mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-14 17:06:46 +00:00
Create bracket views with upcomingMatches
This commit is contained in:
@@ -1,18 +1,6 @@
|
||||
class Matchup
|
||||
attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name
|
||||
|
||||
# def w1
|
||||
# end
|
||||
|
||||
# def w2
|
||||
# end
|
||||
|
||||
# def round
|
||||
# end
|
||||
|
||||
# def weight_id
|
||||
# end
|
||||
|
||||
def weight_max
|
||||
@weight = Weight.find(self.weight_id)
|
||||
return @weight.max
|
||||
|
||||
@@ -10,9 +10,6 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def upcomingMatches
|
||||
# @matches = Match.where(tournament_id: self.id)
|
||||
# @matches.sort_by{|x|[x.boutNumber]}
|
||||
# @matches.sort_by{|x|[x.round,x.weight.max]}
|
||||
@matches = []
|
||||
self.weights.sort_by{|x|[x.max]}.each do |weight|
|
||||
@upcomingMatches = weight.generateMatchups(@matches)
|
||||
@@ -22,16 +19,6 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
|
||||
def generateMatches
|
||||
destroyAllMatches
|
||||
self.weights.each do |weight|
|
||||
weight.generatePool
|
||||
end
|
||||
# assignRound
|
||||
assignBouts
|
||||
end
|
||||
handle_asynchronously :generateMatches
|
||||
|
||||
def destroyAllMatches
|
||||
@matches_all = Match.where(tournament_id: self.id)
|
||||
@matches_all.each do |match|
|
||||
|
||||
@@ -4,21 +4,6 @@ class Weight < ActiveRecord::Base
|
||||
|
||||
attr_accessor :pools, :bracket_size, :bracket_type
|
||||
|
||||
def generatePool
|
||||
@wrestlers = Wrestler.where(weight_id: self.id)
|
||||
#@wrestlers.sort_by{|w| [w.original_seed]}
|
||||
if self.pools == 1
|
||||
@pool = Pool.new
|
||||
@pool.onePool(@wrestlers,self.id,self.tournament_id)
|
||||
elsif self.pools == 2
|
||||
@pool = Pool.new
|
||||
@pool.twoPools(@wrestlers,self.id,self.tournament_id)
|
||||
elsif self.pools == 4
|
||||
@pool = Pool.new
|
||||
@pool.fourPools(@wrestlers,self.id,self.tournament_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pools
|
||||
@wrestlers = self.wrestlers
|
||||
if @wrestlers.size <= 6
|
||||
|
||||
@@ -14,8 +14,9 @@ class Wrestler < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def boutByRound(round)
|
||||
@match = matches_all.select{|m| m.round == round}.first
|
||||
def boutByRound(round,matches)
|
||||
@matches = matches.select{|m| m.w1 == self.id || m.w2 == self.id}
|
||||
@match = @matches.select{|m| m.round == round}.first
|
||||
if @match.blank?
|
||||
return "BYE"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user