summaryrefslogtreecommitdiff
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
parent2cb92046ebe697d6e17c78e968ec1bcf528487f0 (diff)
Only allow one drink condition, too
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/models/state.rb10
2 files changed, 8 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea00707..b15c280 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ amenities, etc that are added unless they are special in some way.
### Added
- Spicework has been implemented. You can now craft food and drugs in your hearth, once you build a spicebench.
+ A character can only have one food condition and one drink condition at a time. If a second food or drink condition
+ is gained, the old one is lost. There is no limit to the number of drug conditions a character can have at once.
- New hearth amenities: spicebench level 1, spicebench level 2
- New items: bluster powder, mudtub mash, midoras spice, midoras mudtub mash
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