summaryrefslogtreecommitdiff
path: root/app/views/application/_timer.html.erb
blob: d683c6a8c2c7676e4ad2d6270881bd12a3b576b4 (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
<% 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>


  <% most_recent_cs = current_char.character_skills.order(:updated_at).last %>
  <div class="text-center text-sm">
    <div class="text-xs"><%= most_recent_cs.skill.name %> level <%= most_recent_cs.level %></div>
    <div><%= most_recent_cs.xp_to_next_level %> XP to next level</div>
  </div>

  <div class="text-center my-2">
    <%= 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 %>