From aac7563767c5fbc5ef67f4d615833e7523a46df7 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sat, 29 May 2021 17:19:56 -0400 Subject: Conditions and states (boons & banes), with `quarrying_draught` --- app/models/character.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'app/models/character.rb') diff --git a/app/models/character.rb b/app/models/character.rb index a5c871b..7e80d65 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -10,6 +10,8 @@ class Character < ApplicationRecord has_many :learned_activities has_many :items, through: :character_items has_many :character_skills + has_many :conditions, through: :states + has_many :states has_many :chat_messages has_many :bazaar_orders validates :name, presence: true @@ -91,6 +93,10 @@ class Character < ApplicationRecord end end + def active_states + self.states.all.select { |s| !s.expired? } + end + def pay_cost_for(activity) CharacterItem.transaction do activity.whatnot[:cost]&.each do |cost| @@ -230,7 +236,8 @@ class Character < ApplicationRecord # TODO: Review this filter_map to see if it can be simplified hearth_amenity_effects = self.hearth.built_hearth_amenities.filter_map { |a| a.effects if a.effects } equipment_effects = self.equipment.filter_map { |a| a.effects if a.effects } - (hearth_amenity_effects + equipment_effects).flatten + state_effects = self.states.filter_map { |a| a.effects if a.effects && !a.expired? } + (hearth_amenity_effects + equipment_effects + state_effects).flatten end def total_stat_change(gid) -- cgit v1.2.3