summaryrefslogtreecommitdiff
path: root/app/views/application/_timer.html.erb
blob: ea710e3f528086e026266b0bd5a8effaae3a8031 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<% if current_char %>
  <% if current_char.activity %>
    <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2>
    <div data-controller="timer"
         data-timer-time-remaining-value="<%= current_char.activity_time_remaining %>"
         data-timer-activity-duration-value="<%= current_char.activity_duration - current_char.rested_duration_to_spend_on_activity %>"
         data-timer-post-url-value="<%= finish_activity_url %>">
      <div class="text-center">
        <span data-timer-target="timer" class="text-xl text-display"></span>
      </div>
      <div class="border border-gray-800 h-4 my-1">
        <div data-timer-target="progressBar" class="bg-gray-600 h-full"
             style="width: <%= current_char.percentage_of_activity_completed %>%">
        </div>
      </div>
    </div>

    <% required_character_skills = current_char.activity.whatnot[:requirements]&.filter_map { |r| current_char.character_skills.find_by(skill: Skill.find_by_gid(r[:gid])) if r[:type] == "skill" } %>
    <div class="text-center text-sm">
      <% required_character_skills&.each do |cs| %>
        <div class="space-y-1">
          <div class="text-xs"><%= cs.skill.name %> level <%= cs.level %></div>
          <div><%= cs.xp_to_next_level %> XP to next level</div>
        </div>
      <% end %>
    </div>

    <div class="text-center text-sm my-2">
      <% if current_char.queued_actions %>
        <div class="my-1">
          <%= pluralize(current_char.queued_actions + 1, "action") %> remaining.
        </div>
      <% end %>
      <%= button_to "Stop", stop_activity_path, class: "text-sm" %>
    </div>

    <div class="text-center text-xs my-2">
      <% if current_char.activity.gid.include?("beastslay") %>
        <%= current_char.wounds %> / <%= pluralize(current_char.max_wounds, "wound") %>
      <% end %>
      <% current_char.active_states.each do |state| %>
        <div>
          <%= state.condition.name %>
        </div>
        <div>
          (expires in <%= distance_of_time_in_words_to_now(state.expires_at) %>)
        </div>
      <% end %>
    </div>

  <% else %>
    <div class="text-center">
      <% if current_char.resting? %>
        <p>You're resting.</p>
      <% else %>
        <p>You're not doing anything.</p>
      <% end %>

      <div class="my-2">
        <%= button_to current_char.resting? ? "Stop Resting" : "Start Resting", toggle_resting_path %>
      </div>

      <div class="text-xs">
      You have <%= distance_of_time_in_words_to_now(current_char.rested_until) %> of rested time.
        <% if current_char.resting? %>
          This does not include time from your current rest. That time will be added when you stop resting.
        <% end %>
      </div>
    </div>
  <% end %>
<% end %>