diff options
author | David Gay <david@davidgay.org> | 2021-05-18 18:35:49 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-18 18:35:49 -0400 |
commit | 9ab7dfd99e7015513bfe1a092f257c1c7a7afb1b (patch) | |
tree | db536029ff1031d33468899e22b3c26dfcddbe2d /app/models | |
parent | 4a6c06eb681575dbf1ee58d3b1f667e79051b1e2 (diff) |
Display hearth foundation requirements
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/hearth_amenity.rb | 12 |
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 |