blob: 562abf42a980bf6fad935505995cfb59657ac0b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
class Activity < ApplicationRecord
include HasWhatnot
belongs_to :location, optional: true
validates :gid, :name, :description, presence: true
attribute :innate, :boolean, default: false
def costs
costs = []
self.whatnot[:cost].each do |cost|
case cost[:type]
when "item"
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
end
end
|