summaryrefslogtreecommitdiff
path: root/app/models/character.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-05 20:04:30 -0400
committerDavid Gay <david@davidgay.org>2021-06-05 20:12:33 -0400
commitfe644bfc268b92daedbb16e00fd46b19ae082487 (patch)
treef21eedff7de4a729d7f06b78f1adb41d4080ca06 /app/models/character.rb
parent771a7672876ff2c9649c919395a4d23f2a66f16f (diff)
Add resistance stats and rejigger character sheet layout
Diffstat (limited to 'app/models/character.rb')
-rw-r--r--app/models/character.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index f4c9bc2..74dbe9f 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -320,6 +320,13 @@ class Character < ApplicationRecord
self.wounds < max_wounds
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
+ [total_stat_change("#{damage_type}_resistance"), 0].max
+ end
+
def max_wounds
[1 + total_stat_change("max_wounds"), 0].max
end