From 9ab7dfd99e7015513bfe1a092f257c1c7a7afb1b Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 18 May 2021 18:35:49 -0400 Subject: Display hearth foundation requirements --- app/models/hearth_amenity.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/models') 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 -- cgit v1.2.3