mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added a bout board
This commit is contained in:
@@ -23,6 +23,7 @@ module GeneratesTournamentMatches
|
||||
def generateMatches
|
||||
assignBouts
|
||||
assignLoserNames
|
||||
assignFirstMatchesToMats
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
class Mat < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :matches
|
||||
|
||||
def assignNextMatch
|
||||
t_matches = tournament.matches.where(mat_id: nil)
|
||||
match = t_matches.order(:bout_number).first
|
||||
match.mat_id = self.id
|
||||
match.save
|
||||
end
|
||||
|
||||
def unfinishedMatches
|
||||
matches.where(finished: nil).order(:bout_number)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Match < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
belongs_to :weight
|
||||
belongs_to :mat
|
||||
|
||||
|
||||
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
|
||||
|
||||
@@ -40,5 +40,13 @@ class Tournament < ActiveRecord::Base
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
|
||||
def assignFirstMatchesToMats
|
||||
until mats.order(:id).last.matches.count == 4
|
||||
mats.order(:id).each do |m|
|
||||
m.assignNextMatch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user