summaryrefslogtreecommitdiff
path: root/app/models/hearth.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/hearth.rb')
-rw-r--r--app/models/hearth.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/hearth.rb b/app/models/hearth.rb
index 8885a08..5d244ec 100644
--- a/app/models/hearth.rb
+++ b/app/models/hearth.rb
@@ -1,3 +1,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