diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/characters/hearth_controller.rb | 2 | ||||
-rw-r--r-- | app/models/character.rb | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb index d195571..8e32ab0 100644 --- a/app/controllers/characters/hearth_controller.rb +++ b/app/controllers/characters/hearth_controller.rb @@ -9,7 +9,7 @@ class Characters::HearthController < ApplicationController } Activity.where("gid like ?", "craft_%").each do |activity| - next unless current_char.can_do_activity?(activity, ignore_cost: true) + next unless current_char.can_do_activity?(activity, ignore_cost: true, ignore_requirements: true) activity.whatnot[:requirements]&.each do |requirement_data| if requirement_data[:type] == "hearth_amenity" case requirement_data[:gid] diff --git a/app/models/character.rb b/app/models/character.rb index 9eb34cf..1ff0a06 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -128,7 +128,7 @@ class Character < ApplicationRecord duration - (Time.now - self.activity_started_at) end - def can_do_activity?(activity, ignore_cost: false) + def can_do_activity?(activity, ignore_cost: false, ignore_requirements: false) return false unless activity.innate? || self.learned_activities.exists?(activity: activity) unless ignore_cost activity.whatnot[:cost]&.each do |cost| @@ -138,10 +138,14 @@ class Character < ApplicationRecord end end end - activity.whatnot[:requirements]&.each do |requirement| - case requirement[:type] - when "hearth_amenity" - return false unless self.hearth.has_amenity?(requirement[:gid], requirement[:level]) + unless ignore_requirements + activity.whatnot[:requirements]&.each do |requirement| + case requirement[:type] + when "skill" + return false unless self.skill_level(requirement[:gid]) >= requirement[:level] + when "hearth_amenity" + return false unless self.hearth.has_amenity?(requirement[:gid], requirement[:level]) + end end end true |