From 6baf94683cc5e723a5a61bd9effbfd0b4fa4eccd Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 23 Jun 2021 21:11:26 -0400 Subject: Change breakage mechanics --- app/models/equipment.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'app/models/equipment.rb') 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 -- cgit v1.2.3