diff options
Diffstat (limited to 'app/models/monster.rb')
-rw-r--r-- | app/models/monster.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/monster.rb b/app/models/monster.rb index d1e1b99..523afa7 100644 --- a/app/models/monster.rb +++ b/app/models/monster.rb @@ -28,4 +28,14 @@ class Monster < ApplicationRecord def block_value self.whatnot[:block_value][:base] end + + def resistance(damage_type) + unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed].include?(damage_type) + raise "Invalid damage type" + end + self.whatnot&.each do |resistance| + return resistance[:base] if resistance[:gid] == damage_type + end + 0 + end end |