diff options
Diffstat (limited to 'app/models/character.rb')
-rw-r--r-- | app/models/character.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index b7b323d..84583a8 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -106,6 +106,10 @@ class Character < ApplicationRecord case cost[:type] when "item" self.shift_item(cost[:gid], -(cost[:quantity] || 1)) + when "hearth_planting" + hp = hearth.ripe_hearth_plantings_of(cost[:gid]).first + raise HearthPlantingError unless hp + hp.destroy end end end @@ -217,6 +221,8 @@ class Character < ApplicationRecord case cost[:type] when "item" return false unless self.has_item?(cost[:gid], cost[:quantity] || 1) + when "hearth_planting" + return false unless hearth.ripe_hearth_plantings_of(cost[:gid]).first else raise "Invalid cost type string (#{cost[:type]})" end @@ -288,6 +294,10 @@ class Character < ApplicationRecord effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" && e[:gid] == gid }.sum end + def planting_spots + [total_stat_change("planting_spots"), 0].max + end + def can_fight? self.wounds < max_wounds end |