Re-namespacing a bit to clear out some fairly old stuff from the top level
This commit is contained in:
39
oldstuff/map-mash/app/models/mash_tournament.rb
Normal file
39
oldstuff/map-mash/app/models/mash_tournament.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
class MashTournament < ActiveRecord::Base
|
||||
belongs_to :requester
|
||||
has_many :mashes
|
||||
has_many :rounds, :class_name => 'MashTournamentRound'
|
||||
|
||||
def next_unplayed_mash
|
||||
mash = self.mashes.unplayed.first
|
||||
if not mash
|
||||
filled = self.builder.fill_in_next_round
|
||||
if filled
|
||||
return self.mashes.unplayed.first
|
||||
else
|
||||
return nil
|
||||
end
|
||||
else
|
||||
return mash
|
||||
end
|
||||
end
|
||||
|
||||
def total_rounds_options
|
||||
@total_rounds_options ||= [3, 4, 5, 6, 7]
|
||||
end
|
||||
|
||||
def done?
|
||||
self.rounds.collect(&:done?).uniq == [true]
|
||||
end
|
||||
|
||||
def round(number = 0)
|
||||
MashTournamentRound.find_by_mash_tournament_id(self.id,
|
||||
:conditions => {:number => number}
|
||||
)
|
||||
end
|
||||
|
||||
def builder
|
||||
MashTournamentBuilder.new(
|
||||
self, MashTournament, MashTournamentRound, Map, Mash
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user