diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/state.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/state.rb b/app/models/state.rb index 29b3f42..52767e7 100644 --- a/app/models/state.rb +++ b/app/models/state.rb @@ -21,10 +21,12 @@ class State < ApplicationRecord # Don't allow duplicate conditions; just destroy the old one. character.states.where(condition: condition).where.not(id: id).destroy_all - # Only allow one food condition. Destroy the old one. - if condition.tags.include?("food") - character.states.each do |state| - state.destroy if state.id != id && state.condition.tags.include?("food") + # Only allow one food condition and one drink condition. Destroy any old ones. + %w[food drink].each do |tag| + if condition.tags.include?(tag) + character.states.each do |state| + state.destroy if state.id != id && state.condition.tags.include?(tag) + end end end end |