1
0
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:
2015-02-05 09:53:08 -05:00
parent 7183935b60
commit e9cf73f9d5
6 changed files with 132 additions and 52 deletions

View File

@@ -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