diff options
author | David Gay <david@davidgay.org> | 2021-05-19 21:16:15 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-19 21:16:15 -0400 |
commit | 5afdcd12f04102b5cf5d5a310981bc576a992119 (patch) | |
tree | 2f8a8768856268cf755a6c4eb82f768f8c02affc /app | |
parent | e941a28056142ee239bbba623f03537aab0ae039 (diff) |
Implement crafting from the hearth forge
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/activities_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/characters/hearth_controller.rb | 1 | ||||
-rw-r--r-- | app/views/activities/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/characters/hearth/index.html.erb | 24 |
4 files changed, 25 insertions, 7 deletions
diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index f72bc3a..934f617 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -7,7 +7,7 @@ class ActivitiesController < ApplicationController @activity = Activity.find(params[:id]) if current_char.can_do_activity?(@activity) current_char.start_activity(@activity) - redirect_to action: :show + redirect_to activity_path(@activity) else flash[:alert] = "You can't do that. Make sure you have the items and meet the requirements." redirect_to character_path(current_char) diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb index f2d2bf7..abe8232 100644 --- a/app/controllers/characters/hearth_controller.rb +++ b/app/controllers/characters/hearth_controller.rb @@ -2,5 +2,6 @@ class Characters::HearthController < ApplicationController def index @all_amenities = HearthAmenity.all @construct_activities = Activity.where("gid like ?", "construct_%") + @forge_activities = Activity.where("gid like ?", "craft_%") end end diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 6db2fb2..84c19a4 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -9,4 +9,7 @@ <%= render "timer" %> </div> -<%= link_to "Start", start_activity_path(@activity), method: :post %> +<%= form_with url: start_activity_path do |f| %> + <%= f.hidden_field :id, value: @activity.id %> + <%= f.submit "Start" %> +<% end %> diff --git a/app/views/characters/hearth/index.html.erb b/app/views/characters/hearth/index.html.erb index 487bd46..6f2c444 100644 --- a/app/views/characters/hearth/index.html.erb +++ b/app/views/characters/hearth/index.html.erb @@ -8,8 +8,13 @@ <ul class="my-4"> <% @construct_activities.each do |activity| %> - <li><%= link_to activity.name, start_activity_path(activity), method: :post %> - (costs <%= activity.cost_string %>)</li> + <li> + <%= form_with url: start_activity_path do |f| %> + <%= f.hidden_field :id, value: activity.id %> + <%= f.submit activity.name %> + <% end %> + (costs <%= activity.cost_string %>) + </li> <% end %> </ul> @@ -17,14 +22,23 @@ <% current_char.hearth.built_hearth_amenities.each do |bhi| %> <div class="border-2 border-gray-800 rounded p-4"> <h2 class="text-lg font-bold"><%= bhi.hearth_amenity.name %></h2> - <p>Level <%= bhi.level %></p> - <p><%= bhi.hearth_amenity.description %></p> + <p class="mb-2">Level <%= bhi.level %></p> + <p class="mb-2"><%= bhi.hearth_amenity.description %></p> + <% if bhi.hearth_amenity.gid == "forge" %> + <%= form_with url: start_activity_path, method: :post do |f| %> + <%= f.select :id, @forge_activities.map { |a| [a.name, a.id] } %> + <%= f.submit "Go" %> + <% end %> + <% end %> </div> <% end %> </div> <% else %> <p>You haven't built your hearth yet. First, you'll need to start with a foundation.</p> <% construct_activity = foundation.construct_activity(1) %> - <%= link_to construct_activity.name, start_activity_path(construct_activity), method: :post %> + <%= form_with url: start_activity_path do |f| %> + <%= f.hidden_field :id, value: construct_activity.id %> + <%= f.submit construct_activity.name %> + <% end %> (costs <%= construct_activity.cost_string %>) <% end %> |