From 9fec79398a34d26be1042e35cae429b88f8b96d0 Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 19 May 2021 18:39:35 -0400 Subject: Revise and progress with hearth amenity construction --- app/controllers/activities_controller.rb | 8 ++++++-- app/controllers/game_controller.rb | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index a535f99..a32ffab 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -5,7 +5,11 @@ class ActivitiesController < ApplicationController def start @activity = Activity.find(params[:id]) - current_char.update(activity: @activity, activity_started_at: Time.now) - redirect_to action: :show + if current_char.can_do_activity?(@activity) + redirect_to action: :show + else + flash[:alert] = "You can't do that. Make sure you have the items and meet the requirements." + redirect_to character_path(current_char) + end end end diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index d69645f..147b692 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -2,6 +2,7 @@ class GameController < ApplicationController def finish_activity @results = [] return unless current_char.activity_time_remaining <= 0 + return unless current_char.can_do_activity?(current_char.activity) # TODO: Add error message current_char.update(activity_started_at: Time.now) current_char.activity.whatnot[:results].each do |result| -- cgit v1.2.3