summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-03 19:58:16 -0400
committerDavid Gay <david@davidgay.org>2021-06-03 19:58:16 -0400
commit94418789939af680ed72bf31c62762046da33dfd (patch)
tree73410770d4e0af61c84883bfbefa7cd6c35dca62 /app
parent2cb92046ebe697d6e17c78e968ec1bcf528487f0 (diff)
Only allow one drink condition, too
Diffstat (limited to 'app')
-rw-r--r--app/models/state.rb10
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