summaryrefslogtreecommitdiff
path: root/app/models/item_infix.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-16 20:49:59 -0400
committerGitHub <noreply@github.com>2021-06-16 20:49:59 -0400
commit6dfaa7453591910e1373d92d8a09ddf384ebe834 (patch)
treeccec71ec425808ea82a3bfbcd36490f1cdcb666d /app/models/item_infix.rb
parent007896b0057b8aecbf74dddd269b57efe3f6e0e6 (diff)
parent0d6a82102061ff58b7ba34b09c4be9687c21ab2a (diff)
Merge pull request #16 from dtgay/0.1.11
0.1.11
Diffstat (limited to 'app/models/item_infix.rb')
-rw-r--r--app/models/item_infix.rb21
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..b59ccdb
--- /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 effects
+ self.item.whatnot[:infix_effects]
+ end
+
+ def break_check
+ rand > 0.998 ? destroy : false
+ 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