summaryrefslogtreecommitdiff
path: root/app/models/activity.rb
blob: 7272a3bca502d928871e10434225cb4e43692116 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Activity < ApplicationRecord
  include HasWhatnot

  belongs_to :location, optional: true
  validates :gid, :name, :description, presence: true

  attribute :innate, :boolean, default: false

  def cost_string
    requirements = []
    self.whatnot[:cost].each do |cost|
      case cost[:type]
      when "item"
        requirements.push "#{cost[:quantity]} #{Item.find_by_gid(cost[:gid]).name}"
      end
    end
    requirements.join(", ")
  end
end