mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-13 00:26:31 +00:00
A Tournament can now generate its own matches.
This was again extracted as a module. Modules get more powerful as they get more generic. This is far from generic.
This commit is contained in:
@@ -1,26 +1,23 @@
|
||||
class Tournament < ActiveRecord::Base
|
||||
|
||||
include GeneratesLoserNames
|
||||
include GeneratesLoserNames
|
||||
include GeneratesTournamentMatches
|
||||
|
||||
has_many :schools, dependent: :destroy
|
||||
has_many :weights, dependent: :destroy
|
||||
has_many :mats, dependent: :destroy
|
||||
has_many :wrestlers, through: :weights
|
||||
|
||||
has_many :matches, dependent: :destroy
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket"]
|
||||
end
|
||||
|
||||
def matches
|
||||
@matches = Match.where(tournament_id: self.id)
|
||||
end
|
||||
|
||||
def createCustomWeights(value)
|
||||
self.weights.destroy_all
|
||||
def createCustomWeights(value)
|
||||
weights.destroy_all
|
||||
if value == 'hs'
|
||||
Weight::HS_WEIGHT_CLASSES.each do |w|
|
||||
self.weights.create(max: w)
|
||||
weights.create(max: w)
|
||||
end
|
||||
else
|
||||
raise "Unspecified behavior"
|
||||
@@ -28,15 +25,7 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def upcomingMatches
|
||||
if matches.nil?
|
||||
return nil
|
||||
else
|
||||
matches
|
||||
end
|
||||
end
|
||||
|
||||
def generateMatchups
|
||||
@matches = Tournamentmatchgen.new(self).genMatches()
|
||||
end
|
||||
|
||||
def destroyAllMatches
|
||||
|
||||
Reference in New Issue
Block a user