From 5041f03e272e9e1f3726b5f6b21b3d45cd78dd22 Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 25 May 2021 20:00:32 -0400 Subject: Improve hearth view and amenity construction process --- app/views/characters/hearth/index.html.erb | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'app/views/characters') diff --git a/app/views/characters/hearth/index.html.erb b/app/views/characters/hearth/index.html.erb index 6f2c444..e425fee 100644 --- a/app/views/characters/hearth/index.html.erb +++ b/app/views/characters/hearth/index.html.erb @@ -6,30 +6,32 @@ in these realms. Amidst this great dream of planar chaos and destruction, you have built something.

- -
- <% current_char.hearth.built_hearth_amenities.each do |bhi| %> + <% @all_amenities.each do |ha| %>
-

<%= bhi.hearth_amenity.name %>

-

Level <%= bhi.level %>

-

<%= bhi.hearth_amenity.description %>

- <% 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" %> +

<%= ha.name %>

+ <% built_amenity = current_char.hearth.built_hearth_amenities.find_by(hearth_amenity: ha) %> + <% if built_amenity %> +

Level <%= built_amenity.level %>

+

<%= ha.description %>

+ <% if ha.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 %> <% end %> + <% next_level = built_amenity ? built_amenity.level + 1 : 1 %> + <% construct_activity = ha.construct_activity(next_level) %> + <% if construct_activity %> +
+ <%= 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 %>
<% end %>
-- cgit v1.2.3