diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/activity.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/app/models/activity.rb b/app/models/activity.rb index 7272a3b..562abf4 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -6,14 +6,29 @@ class Activity < ApplicationRecord attribute :innate, :boolean, default: false - def cost_string - requirements = [] + def costs + costs = [] self.whatnot[:cost].each do |cost| case cost[:type] when "item" - requirements.push "#{cost[:quantity]} #{Item.find_by_gid(cost[:gid]).name}" + costs.push "#{cost[:quantity]} #{Item.find_by_gid(cost[:gid]).name}" + end + end + costs + end + + def requirements + requirements = [] + self.whatnot[:requirements].each do |req| + case req[:type] + when "skill" + requirements.push "level #{req[:level]} #{Skill.find_by_gid(req[:gid]).name}" + when "hearth_amenity" + requirements.push "level #{req[:level]} #{HearthAmenity.find_by_gid(req[:gid]).name}" + else + raise "Invalid requirement type string (#{req[:type]})" end end - requirements.join(", ") + requirements end end |