diff options
author | David Gay <david@davidgay.org> | 2021-05-04 17:55:28 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-04 17:57:12 -0400 |
commit | 73744a9c6840fb0ba6f285ca81f9fba75ec22d5f (patch) | |
tree | 837333e9e46c5ccc6cf50214a94c2b9b6d0bb7f3 /app/views | |
parent | dddbf75428477f5e073584939d098e55d6324be3 (diff) |
Initial draft of timer setup, with results outputting and items being awarded
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/activities/_results.html.erb | 7 | ||||
-rw-r--r-- | app/views/activities/_timer.html.erb | 8 | ||||
-rw-r--r-- | app/views/activities/show.html.erb | 11 | ||||
-rw-r--r-- | app/views/game/finish_activity.js.erb | 12 | ||||
-rw-r--r-- | app/views/locations/show.html.erb | 3 |
5 files changed, 40 insertions, 1 deletions
diff --git a/app/views/activities/_results.html.erb b/app/views/activities/_results.html.erb new file mode 100644 index 0000000..baa4ab0 --- /dev/null +++ b/app/views/activities/_results.html.erb @@ -0,0 +1,7 @@ +<div> + <% results.each do |result| %> + <% if result[:type] == "item" %> + <p>You got <%= result[:quantity] %> <%= result[:item].name %>.</p> + <% end %> + <% end %> +</div> diff --git a/app/views/activities/_timer.html.erb b/app/views/activities/_timer.html.erb new file mode 100644 index 0000000..418c378 --- /dev/null +++ b/app/views/activities/_timer.html.erb @@ -0,0 +1,8 @@ +<% if current_char.activity %> + <div data-controller="activities--timer" + data-activities--timer-start-value="<%= current_char.activity_time_remaining.ceil %>" + class="text-center"> + <span data-activities--timer-target="timer" class="text-3xl"></span> + </div> + <%= link_to "Stop", location_path(current_char.activity.location) %> +<% end %> diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb new file mode 100644 index 0000000..4e77061 --- /dev/null +++ b/app/views/activities/show.html.erb @@ -0,0 +1,11 @@ +<h1 class="text-2xl"><%= @activity.name %></h1> +<p><%= @activity.description %></p> + +<div class="border-gray-800 rounded p-2" id="result_output"> +</div> + +<div id="result_controls"> + <%= render "timer" %> +</div> + +<%= link_to "Start", start_activity_path(@activity), method: :post %> diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb new file mode 100644 index 0000000..99d200c --- /dev/null +++ b/app/views/game/finish_activity.js.erb @@ -0,0 +1,12 @@ +var resultOutputDiv = document.getElementById("result_output"); +var resultControlsDiv = document.getElementById("result_controls"); + +var outputHTML = "<%= j render(partial: "activities/results", locals: { results: @results }) %>" + +if (resultOutputDiv) { + resultOutputDiv.innerHTML += outputHTML; +} + +if (resultControlsDiv) { + resultControlsDiv.innerHTML = "<%= j render(partial: "activities/timer") %>" +} diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index c3a75e1..bc63541 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -2,6 +2,7 @@ <ul> <% @location.activities.each do |activity| %> - <li><span class="font-bold"><%= link_to activity.name, "#" %></span> – <%= activity.description %></li> + <li><span class="font-bold"><%= link_to activity.name, activity_path(activity) %></span> + – <%= activity.description %></li> <% end %> </ul> |