From 6bf84733db22f6c5d5105acc3565b075fcc65917 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 23 May 2021 19:24:51 -0400 Subject: Don't allow fighting if a character has too many wounds --- app/controllers/game_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers') 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 -- cgit v1.2.3