From c4ba54f606c0c4cc5eaa78e108f6529187de3d78 Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 25 May 2021 22:02:33 -0400 Subject: Improve hearth crafting selection --- app/models/hearth.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/models') diff --git a/app/models/hearth.rb b/app/models/hearth.rb index 5d244ec..1bd54a5 100644 --- a/app/models/hearth.rb +++ b/app/models/hearth.rb @@ -9,4 +9,10 @@ class Hearth < ApplicationRecord 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 -- cgit v1.2.3