summaryrefslogtreecommitdiff
path: root/app/models/monster.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/monster.rb')
-rw-r--r--app/models/monster.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/models/monster.rb b/app/models/monster.rb
index 523afa7..f4ae7a7 100644
--- a/app/models/monster.rb
+++ b/app/models/monster.rb
@@ -30,12 +30,21 @@ class Monster < ApplicationRecord
end
def resistance(damage_type)
- unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed].include?(damage_type)
+ unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed
+ physical energy].include?(damage_type)
raise "Invalid damage type"
end
- self.whatnot&.each do |resistance|
- return resistance[:base] if resistance[:gid] == damage_type
+ res = 0
+ whatnot[:resistances]&.each do |data|
+ if data[:gid] == damage_type
+ res += data[:base]
+ end
end
- 0
+ if %w[slash pierce bash].include?(damage_type)
+ res += resistance("physical")
+ elsif %w[arcane fire frost lightning acid thunder radiant necrotic].include?(damage_type)
+ res += resistance("energy")
+ end
+ res
end
end