diff options
Diffstat (limited to 'app/models/character.rb')
-rw-r--r-- | app/models/character.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 9db3f8c..a26fb93 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -162,6 +162,10 @@ class Character < ApplicationRecord self.equipment.find_by(item: item) end + def equipment_with_tag(tag) + self.equipment.all.find { |e| e.item.has_tag?(tag) } + end + def open_slots_for(item) full_slots = self.equipment.map { |e| e.slot } item.equip_slots.reject { |slot| full_slots.include?(slot) } @@ -297,7 +301,11 @@ class Character < ApplicationRecord activity.whatnot[:requirements]&.each do |requirement| case requirement[:type] when "equipment" - return false unless self.equipment_with_gid(requirement[:gid]) + if requirement[:tag] + return false unless self.equipment_with_tag(requirement[:tag]) + else + return false unless self.equipment_with_gid(requirement[:gid]) + end when "stat" # TODO: HACK: This won't work with built-in stats! Need to change this to work with power and whatnot. return false unless self.total_stat_change(requirement[:gid]) >= requirement[:value] |