summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-28 11:26:44 -0400
committerDavid Gay <david@davidgay.org>2021-05-28 11:26:54 -0400
commit5ae89950fb330fd623634b98a77de259ab174b53 (patch)
tree3ec11fae10758379761f5b824586b1c22bc57c12 /app/controllers/application_controller.rb
parentc522bc8efa0378e0fcbcfdd137d6cd2ae4010d5b (diff)
Lockbox unlocking, and with it items that start activities when used
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 94859d1..0fc78a8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,4 +14,17 @@ class ApplicationController < ActionController::Base
def roll(sides)
rand(sides) + 1
end
+
+ private
+ def start_activity(activity)
+ if current_char.start_activity(activity, queued_actions: params[:queued_actions])
+ redirect_to look_path
+ else
+ message = "You can't do that."
+ message += " (requires #{activity.requirements&.join(", ")})" if activity.requirements.any?
+ message += " (costs #{activity.costs&.join(", ")})" if activity.costs.any?
+ flash[:alert] = message
+ redirect_back(fallback_location: character_path(current_char))
+ end
+ end
end