mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Removed score from school table and added attr_accessor
This commit is contained in:
@@ -1,29 +1,11 @@
|
||||
class School < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :wrestlers, dependent: :destroy
|
||||
attr_accessor :score
|
||||
|
||||
#calculate score here
|
||||
def score
|
||||
@score = 0
|
||||
self.wrestlers.each do |wrestler|
|
||||
@match_wins = Match.where(winner_id: wrestler.id)
|
||||
@match_wins.each do |m|
|
||||
@score = @score + 2
|
||||
if m.win_type == "Major"
|
||||
@score = @score + 1
|
||||
elsif m.win_type == "Tech Fall"
|
||||
@score = @score + 1.5
|
||||
elsif m.win_type == "Pin"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Forfeit"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Injury Default"
|
||||
@score = @score + 2
|
||||
elsif m.win_type == "Default"
|
||||
@score = @score + 2
|
||||
end
|
||||
end
|
||||
end
|
||||
self.score = @score
|
||||
@matches = self.tournament.upcomingMatches
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user