diff options
author | David Gay <david@davidgay.org> | 2021-05-26 21:26:58 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-26 21:26:58 -0400 |
commit | 7247a6fb0b3b374f3dac651bd2b133bcb5303534 (patch) | |
tree | b8d27ff62025494ce39fed0cc9b3f77309658cab /app | |
parent | 8cec9b3f6f277399c6da23a04d8afb0c68cf8a2b (diff) |
Simple effect checking allows listern font level 2 to have an effect
Diffstat (limited to 'app')
-rw-r--r-- | app/models/built_hearth_amenity.rb | 4 | ||||
-rw-r--r-- | app/models/character.rb | 15 | ||||
-rw-r--r-- | app/views/characters/show.html.erb | 4 |
3 files changed, 20 insertions, 3 deletions
diff --git a/app/models/built_hearth_amenity.rb b/app/models/built_hearth_amenity.rb index 39b6679..a1e35e8 100644 --- a/app/models/built_hearth_amenity.rb +++ b/app/models/built_hearth_amenity.rb @@ -28,4 +28,8 @@ class BuiltHearthAmenity < ApplicationRecord seconds_until_cooled_down = cooldown - (Time.now - self.last_used_at) [0, seconds_until_cooled_down].max end + + def effects + self.hearth_amenity.whatnot[:effects]&.reject { |e| e[:level] > self.level } + end end 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 diff --git a/app/views/characters/show.html.erb b/app/views/characters/show.html.erb index 84e1ff5..382cdc7 100644 --- a/app/views/characters/show.html.erb +++ b/app/views/characters/show.html.erb @@ -29,8 +29,8 @@ <table class="table-auto"> <tbody> <tr> - <th class="table-cell-padded text-right">Current Wounds</th> - <td class="table-cell-padded"><%= @character.wounds %></td> + <th class="table-cell-padded text-right">Wounds</th> + <td class="table-cell-padded"><%= @character.wounds %> / <%= @character.max_wounds %></td> </tr> <tr> <th class="table-cell-padded text-right">Max HP</th> |