summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/character.rb24
-rw-r--r--app/models/item_infix.rb4
2 files changed, 28 insertions, 0 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index 5ff067c..0f2c5b3 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -116,6 +116,30 @@ class Character < ApplicationRecord
end
end
+ def do_skill_based_equipment_break_checks(skill)
+ skill = Skill.find_by_gid(skill) if skill.is_a? String
+ broken_items = []
+ # TODO: HACK: Should check other stats besides speed stat in the future.
+ # TODO: HACK: May not want a chance to break if speed is _reduced_. Though no equipment does this yet.
+ equipment.all.select { |eq| eq.effects.select { |ef| ef[:gid] == "#{skill.gid}_speed" }.any? }.each do |equipment|
+ if equipment.break_check
+ broken_items.push(equipment.item)
+ end
+ end
+ broken_items
+ end
+
+ def do_skill_based_item_infix_break_checks(skill)
+ skill = Skill.find_by_gid(skill) if skill.is_a? String
+ broken_items = []
+ item_infixes.where(skill: skill).each do |ii|
+ if ii.break_check
+ broken_items.push(ii.item)
+ end
+ end
+ broken_items
+ end
+
def do_equipment_break_checks(exclude_slots: [])
broken_items = []
equipment.where.not(slot: exclude_slots).each do |equipment|
diff --git a/app/models/item_infix.rb b/app/models/item_infix.rb
index 3167320..47b6aa4 100644
--- a/app/models/item_infix.rb
+++ b/app/models/item_infix.rb
@@ -9,6 +9,10 @@ class ItemInfix < ApplicationRecord
self.item.whatnot[:infix_effects]
end
+ def break_check
+ rand > 0.999 ? destroy : false
+ end
+
private
def check_max_infixes
current_infixes = character.item_infixes.where(skill: skill)