summaryrefslogtreecommitdiff
path: root/app/controllers/activities_controller.rb
blob: a1a183557a4c6770702f5a28be2aa86d11ff6127 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class ActivitiesController < ApplicationController
  def show
    @activity = Activity.find(params[:id])
  end

  def start
    @activity = Activity.find(params[:id])
    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
      message += " (costs #{@activity.costs&.join(", ")})" if @activity.costs
      flash[:alert] = message
      redirect_back(fallback_location: character_path(current_char))
    end
  end
end