diff options
Diffstat (limited to 'app/models/item_infix.rb')
-rw-r--r-- | app/models/item_infix.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/item_infix.rb b/app/models/item_infix.rb new file mode 100644 index 0000000..c484242 --- /dev/null +++ b/app/models/item_infix.rb @@ -0,0 +1,21 @@ +class ItemInfix < ApplicationRecord + belongs_to :character + belongs_to :item + belongs_to :skill + + before_create :check_max_infixes + + def self.break_check + rand >= 0.99 + end + + def effects + self.item.whatnot[:infix_effects] + end + + private + def check_max_infixes + current_infixes = character.item_infixes.where(skill: skill) + raise :abort if current_infixes.count >= character.max_infixes(skill) + end +end |