blob: 1bd54a54d63b1551971d01f11ff01f2ec32fec55 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
class Hearth < ApplicationRecord
belongs_to :character
has_many :built_hearth_amenities
has_many :hearth_amenities, through: :built_hearth_amenities
def has_amenity?(hearth_amenity, level = 1)
hearth_amenity = HearthAmenity.find_by_gid(hearth_amenity) if hearth_amenity.is_a? String
bhi = self.built_hearth_amenities.find_by(hearth_amenity: hearth_amenity)
return false unless bhi
bhi.level >= level
end
def amenity_level(hearth_amenity)
hearth_amenity = HearthAmenity.find_by_gid(hearth_amenity) if hearth_amenity.is_a? String
bhi = self.built_hearth_amenities.find_by(hearth_amenity: hearth_amenity)
bhi ? bhi.level : 0
end
end
|