summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-23 19:24:51 -0400
committerDavid Gay <david@davidgay.org>2021-05-23 19:26:54 -0400
commit6bf84733db22f6c5d5105acc3565b075fcc65917 (patch)
tree97b42c4af56b7221b3db15c998f033897866283b /app/controllers
parent8bfc5c129b8eca0de7b65f192478e52462f8571f (diff)
Don't allow fighting if a character has too many wounds
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/game_controller.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb
index 0e6e37b..cb9bbcb 100644
--- a/app/controllers/game_controller.rb
+++ b/app/controllers/game_controller.rb
@@ -14,6 +14,7 @@ class GameController < ApplicationController
type = result[:type]
case type
when "monster"
+ raise TooManyWoundsError unless current_char.can_fight?
next if rand > (result[:chance] || 1)
table_roll = rand
result[:table].sort_by { |t| -t[:score] }.each do |table_entry|
@@ -88,7 +89,10 @@ class GameController < ApplicationController
end
end
rescue ItemQuantityError
- @results.replace({ type: "error", message: "You don't have enough items to complete this activity." })
+ @results.replace([{ type: "error", message: "You don't have enough items to complete this activity." }])
+ rescue TooManyWoundsError
+ @results.replace([{ type: "error",
+ message: "You can't fight in your condition. You'll have to heal a wound." }])
end
private