diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/game_controller.rb | 6 | ||||
-rw-r--r-- | app/errors/too_many_wounds_error.rb | 2 |
2 files changed, 7 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 diff --git a/app/errors/too_many_wounds_error.rb b/app/errors/too_many_wounds_error.rb new file mode 100644 index 0000000..a2e61f2 --- /dev/null +++ b/app/errors/too_many_wounds_error.rb @@ -0,0 +1,2 @@ +class TooManyWoundsError < StandardError +end |