summaryrefslogtreecommitdiff
path: root/app/controllers/activities_controller.rb
blob: 37403c779eabc0cd72d4321a671bb1224ee16b3a (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 activity_path(@activity)
    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