summaryrefslogtreecommitdiff
path: root/app/models/equipment.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-23 21:11:26 -0400
committerDavid Gay <david@davidgay.org>2021-06-23 21:11:26 -0400
commit6baf94683cc5e723a5a61bd9effbfd0b4fa4eccd (patch)
treeaf12632846ef618fccb5aaa24f10ac45554f3e92 /app/models/equipment.rb
parent619647bc749049a6717b8e6d4b7f99b5b6c6fd9d (diff)
Change breakage mechanics
Diffstat (limited to 'app/models/equipment.rb')
-rw-r--r--app/models/equipment.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/models/equipment.rb b/app/models/equipment.rb
index e1dc7a3..f5dd530 100644
--- a/app/models/equipment.rb
+++ b/app/models/equipment.rb
@@ -5,6 +5,17 @@ class Equipment < ApplicationRecord
:left_ring, :right_ring, :waist, :legs, :feet, :curio]
validates :slot, presence: true, uniqueness: { scope: :character }
+ def self.random_break_slot
+ roll = rand
+ if roll >= 0.9998
+ [:neck, :left_ring, :right_ring].sample
+ elsif roll >= 0.9996
+ [:back, :waist, :curio].sample
+ elsif roll >= 0.999
+ [:mainhand, :offhand, :head, :torso, :grip, :legs, :feet].sample
+ end
+ end
+
def slot
self[:slot].to_sym
end
@@ -14,14 +25,6 @@ class Equipment < ApplicationRecord
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