summaryrefslogtreecommitdiff
path: root/app/models/hearth_amenity.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/hearth_amenity.rb')
-rw-r--r--app/models/hearth_amenity.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/hearth_amenity.rb b/app/models/hearth_amenity.rb
index ecc136a..16d8f97 100644
--- a/app/models/hearth_amenity.rb
+++ b/app/models/hearth_amenity.rb
@@ -1,2 +1,14 @@
class HearthAmenity < ApplicationRecord
+ include HasWhatnot
+
+ validates :gid, :name, :description, :whatnot, presence: true
+
+ def build_requirements_string(level)
+ requirements = []
+ data = self.whatnot[:constructions].find { |d| d[:level] == level }
+ data[:cost][:items].each do |item_gid, quantity|
+ requirements.push "#{quantity} #{Item.find_by_gid(item_gid).name}"
+ end
+ requirements.join(", ")
+ end
end