summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-27 17:27:30 -0400
committerDavid Gay <david@davidgay.org>2021-05-27 17:27:30 -0400
commit25b01cb1df594d0b80adf719ef1cb5dbe9c62ab5 (patch)
treee179a3b37a6490582a4c4f14a9dfb244270f615a
parent20ea3eb09d1c9847984e812df34c12dbdd48789b (diff)
Display activities in amenities even if requisite cost isn't met
-rw-r--r--app/controllers/characters/hearth_controller.rb2
-rw-r--r--app/models/character.rb12
2 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb
index 644c2e5..d195571 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
+ next unless current_char.can_do_activity?(activity, ignore_cost: 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 c973d7d..9eb34cf 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -128,12 +128,14 @@ class Character < ApplicationRecord
duration - (Time.now - self.activity_started_at)
end
- def can_do_activity?(activity)
+ def can_do_activity?(activity, ignore_cost: false)
return false unless activity.innate? || self.learned_activities.exists?(activity: activity)
- activity.whatnot[:cost]&.each do |cost|
- case cost[:type]
- when "item"
- return false unless self.has_item?(cost[:gid], cost[:quantity])
+ unless ignore_cost
+ activity.whatnot[:cost]&.each do |cost|
+ case cost[:type]
+ when "item"
+ return false unless self.has_item?(cost[:gid], cost[:quantity])
+ end
end
end
activity.whatnot[:requirements]&.each do |requirement|