<% foundation = @all_amenities.find_by_gid("foundation") %>

Hearth

<% if current_char.hearth.has_amenity?(foundation) %>

Here is your hearth, your safe haven and stronghold against all that ravages and thrashes in these realms. Amidst this great dream of planar chaos and destruction, you have built something.

<% @all_amenities.each do |ha| %>

<%= 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 @amenity_activities[ha.gid.to_sym] %> <%= form_with url: start_activity_path, method: :post do |f| %> <%= f.select :id, @amenity_activities[ha.gid.to_sym].map { |a| [a.name, a.id] } %> <%= f.submit "Go" %> <% end %> <% end %> <% if built_amenity.usable? %> <%= button_to "Use", hearth_amenity_use_path(built_amenity.hearth_amenity) %> <% 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.hidden_field :queued_actions, value: 0 %> <%= f.submit construct_activity.name %> <% end %>
(costs <%= construct_activity.cost_string %>)
<% end %>
<% end %>
<% else %>

You haven't built your hearth yet. First, you'll need to start with a foundation.

<% construct_activity = foundation.construct_activity(1) %> <%= form_with url: start_activity_path do |f| %> <%= f.hidden_field :id, value: construct_activity.id %> <%= f.hidden_field :queued_actions, value: 0 %> <%= f.submit construct_activity.name %> <% end %> (costs <%= construct_activity.cost_string %>) <% end %>