diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/activity.rb | 2 | ||||
-rw-r--r-- | app/models/character.rb | 2 | ||||
-rw-r--r-- | app/models/learned_activity.rb | 6 |
3 files changed, 10 insertions, 0 deletions
diff --git a/app/models/activity.rb b/app/models/activity.rb index b8eeed7..7272a3b 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -4,6 +4,8 @@ class Activity < ApplicationRecord 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| diff --git a/app/models/character.rb b/app/models/character.rb index 507548e..41dc951 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -3,6 +3,7 @@ class Character < ApplicationRecord belongs_to :activity, optional: true has_one :hearth has_many :character_items + has_many :learned_activities has_many :items, through: :character_items has_many :character_skills has_many :chat_messages @@ -66,6 +67,7 @@ class Character < ApplicationRecord end def can_do_activity?(activity) + return false unless activity.innate? || self.learned_activities.exists?(activity: activity) activity.whatnot[:cost]&.each do |cost| case cost[:type] when "item" diff --git a/app/models/learned_activity.rb b/app/models/learned_activity.rb new file mode 100644 index 0000000..58a6e93 --- /dev/null +++ b/app/models/learned_activity.rb @@ -0,0 +1,6 @@ +class LearnedActivity < ApplicationRecord + belongs_to :character + belongs_to :activity + + validates :character_id, uniqueness: { scope: :activity_id } +end |