summaryrefslogtreecommitdiff
path: root/app/views/characters/hearth/index.html.erb
blob: 563d4b69613130010bc1be9b50ae2a77f56162bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<% foundation = @all_amenities.find_by_gid("foundation") %>
<h1 class="text-3xl mb-2">Hearth</h1>

<% if current_char.hearth.has_amenity?(foundation) %>
  <p class="mb-2">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.
  </p>

  <div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
    <% @all_amenities.each do |ha| %>
      <div class="border-2 border-gray-800 rounded p-4">
        <h2 class="text-lg font-bold"><%= ha.name %></h2>
        <% built_amenity = current_char.hearth.built_hearth_amenities.find_by(hearth_amenity: ha) %>
        <% if built_amenity %>
          <p class="mb-2">Level <%= built_amenity.level %></p>
          <p class="mb-2"><%= ha.description %></p>
          <% 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 %>
        <% end %>
        <% next_level = built_amenity ? built_amenity.level + 1 : 1 %>
        <% construct_activity = ha.construct_activity(next_level) %>
        <% if construct_activity %>
          <div class="my-3">
            <%= 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 %>
            <div class="text-sm">(costs <%= construct_activity.cost_string %>)</div>
          </div>
        <% 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) %>
  <%= 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 %>