summaryrefslogtreecommitdiff
path: root/app/models/character.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/character.rb')
-rw-r--r--app/models/character.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index d1faeb0..073a986 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -175,8 +175,21 @@ class Character < ApplicationRecord
stats
end
+ def effects
+ # TODO: Review this filter_map to see if it can be simplified
+ self.hearth.built_hearth_amenities.filter_map { |a| a.effects if a.effects }.flatten
+ end
+
+ def total_stat_change(stat)
+ effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" }.sum
+ end
+
def can_fight?
- self.wounds < 1
+ self.wounds < max_wounds
+ end
+
+ def max_wounds
+ 1 + total_stat_change("max_wounds")
end
def max_hp