diff options
author | David Gay <david@davidgay.org> | 2021-05-23 20:15:03 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-23 20:15:03 -0400 |
commit | 82eec1f68172857b3b39e6ab3e3b837de16c1198 (patch) | |
tree | a1edb49f55ad01c3acaf41070bf09f207fcfaf22 /app/models | |
parent | 6bf84733db22f6c5d5105acc3565b075fcc65917 (diff) |
Item usage
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character.rb | 2 | ||||
-rw-r--r-- | app/models/item.rb | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index a6e8ff6..ef8768e 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -145,7 +145,7 @@ class Character < ApplicationRecord def equipment_stats stats = {} self.equipment.each do |eq| - eq.item.whatnot[:effects]&.each do |effect| + eq.item.whatnot[:equip_effects]&.each do |effect| if effect[:type] == "stat" stats[effect[:gid]] ||= 0 stats[effect[:gid]] += effect[:modifier] diff --git a/app/models/item.rb b/app/models/item.rb index 5e60f04..1ef5d7d 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -4,12 +4,15 @@ class Item < ApplicationRecord enum equip_slot: [:mainhand, :offhand, :head, :neck, :back, :torso, :grip, :left_ring, :right_ring, :waist, :legs, :feet, :curio] validates :gid, :name, :description, presence: true - validates :usable, inclusion: { in: [true, false] } def equipment? self.whatnot && self.whatnot[:equip_slots]&.any? end + def usable? + self.whatnot && self.whatnot[:use_effects]&.any? + end + def equip_slots return [] unless self.equipment? self.whatnot[:equip_slots].map { |data| data.to_sym } |