summaryrefslogtreecommitdiff
path: root/app/models/hearth.rb
blob: 5d244ec5535390a45744089df86496d598ea1eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
end