summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/character.rb11
-rw-r--r--app/models/monster.rb17
2 files changed, 22 insertions, 6 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index 74dbe9f..0f434cf 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -321,10 +321,17 @@ class Character < 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
- [total_stat_change("#{damage_type}_resistance"), 0].max
+ res = total_stat_change("#{damage_type}_resistance")
+ 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, 0].max
end
def max_wounds
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