mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-04 05:43:47 +00:00
Refactored match generation so I can eventually support multiple types of tournaments
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
class Tournament < ActiveRecord::Base
|
||||
|
||||
include GeneratesLoserNames
|
||||
include GeneratesTournamentMatches
|
||||
belongs_to :user
|
||||
has_many :schools, dependent: :destroy
|
||||
has_many :weights, dependent: :destroy
|
||||
@@ -24,10 +22,6 @@ class Tournament < ActiveRecord::Base
|
||||
time
|
||||
end
|
||||
|
||||
def resetSchoolScores
|
||||
schools.update_all("score = 0.0")
|
||||
end
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket"]
|
||||
end
|
||||
@@ -50,19 +44,6 @@ class Tournament < ActiveRecord::Base
|
||||
def matchesByRound(round)
|
||||
matches.joins(:weight).where(round: round).order("weights.max")
|
||||
end
|
||||
|
||||
def assignBouts
|
||||
bout_counts = Hash.new(0)
|
||||
matches.each do |m|
|
||||
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
||||
bout_counts[m.round] += 1
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
|
||||
def assignFirstMatchesToMats
|
||||
assignMats(mats)
|
||||
end
|
||||
|
||||
def totalRounds
|
||||
self.matches.sort_by{|m| m.round}.last.round
|
||||
|
||||
Reference in New Issue
Block a user