class Equipment < ApplicationRecord belongs_to :character belongs_to :item enum slot: [:mainhand, :offhand, :head, :neck, :back, :torso, :grip, :left_ring, :right_ring, :waist, :legs, :feet, :curio] validates :slot, presence: true, uniqueness: { scope: :character } def slot self[:slot].to_sym end def effects self.item.whatnot[:equip_effects] end def break_check roll = rand if [:neck, :left_ring, :right_ring].include?(slot) destroy and return true if roll > 0.9998 elsif [:back, :waist, :curio].include?(slot) destroy and return true if roll > 0.9996 else destroy and return true if roll > 0.999 end false end end