mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-13 00:26:31 +00:00
Made onePool and twoPool views. Also implemented round robin gem.
This commit is contained in:
@@ -3,7 +3,11 @@ class Tournament < ActiveRecord::Base
|
||||
has_many :weights, dependent: :destroy
|
||||
has_many :matches, dependent: :destroy
|
||||
has_many :mats, dependent: :destroy
|
||||
attr_accessor :upcomingMatches
|
||||
attr_accessor :upcomingMatches, :unfinishedMatches
|
||||
|
||||
def self.unfinishedMatches
|
||||
|
||||
end
|
||||
|
||||
def upcomingMatches
|
||||
@matches = Match.where(tournament_id: self.id)
|
||||
@@ -17,7 +21,7 @@ class Tournament < ActiveRecord::Base
|
||||
self.weights.each do |weight|
|
||||
weight.generatePool
|
||||
end
|
||||
assignRound
|
||||
# assignRound
|
||||
assignBouts
|
||||
end
|
||||
|
||||
@@ -28,34 +32,13 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def assignRound
|
||||
@matches = Match.where(tournament_id: self.id)
|
||||
@matches.sort_by{|x|[x.id]}
|
||||
@matches.each do |match|
|
||||
@round = 1
|
||||
@w1 = Wrestler.find(match.r_id)
|
||||
@w2 = Wrestler.find(match.g_id)
|
||||
until wrestlingThisRound(@w1,@w2,@round) == false do
|
||||
@round += 1
|
||||
end
|
||||
match.round = @round
|
||||
match.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def assignBouts
|
||||
@bouts = Bout.new
|
||||
@bouts.assignBouts(self.id)
|
||||
end
|
||||
|
||||
def wrestlingThisRound(w1,w2,round)
|
||||
if w1.isWrestlingThisRound(round) == true or
|
||||
w2.isWrestlingThisRound(round) == true
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user