diff options
author | David Gay <david@davidgay.org> | 2021-06-03 20:50:58 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-03 20:51:17 -0400 |
commit | 7f129f24e351cafafdb4bc58a44ca0d714e30af6 (patch) | |
tree | e74f989bbeb8c1ea84a43262f97719d80d4010e6 /app/views/application | |
parent | db41c035bfdd0e97662b80d02fbae4a99ed547c2 (diff) |
Move timer and results to new game containers which are always visible
Diffstat (limited to 'app/views/application')
-rw-r--r-- | app/views/application/_results.html.erb | 32 | ||||
-rw-r--r-- | app/views/application/_timer.html.erb | 18 |
2 files changed, 50 insertions, 0 deletions
diff --git a/app/views/application/_results.html.erb b/app/views/application/_results.html.erb new file mode 100644 index 0000000..1da0af7 --- /dev/null +++ b/app/views/application/_results.html.erb @@ -0,0 +1,32 @@ +<div> + <% results.each do |result| %> + <% case result[:type] %> + <% when "item" %> + <p>You got <%= result[:quantity] %> <%= link_to result[:item].name, item_path(result[:item])%>. + <% if result[:xp]&.any? %> + (<%= result[:xp].map { |award| "#{award[:amount] * result[:quantity]} #{award[:skill].name} XP" }.join(", ") %>) + <% end %> + </p> + <% when "hearth_amenity" %> + <p>You constructed <%= result[:hearth_amenity].name %>.</p> + <% when "hearth_planting" %> + <p>You planted <%= link_to result[:hearth_planting].item.name, + item_path(result[:hearth_planting].item) %> in the loam.</p> + <% when "activity" %> + <p>You realized how to <%= result[:activity].name %>!</p> + <% when "monster" %> + <p>You encountered a <%= result[:monster].name %>.</p> + <p class="text-xs italic"><%= result[:monster].description %></p> + <% when "xp" %> + <p class="text-xs">You gained <%= result[:xp] %> <%= result[:skill].name %> XP.</p> + <% when "title" %> + <p>You earned the title <%= render "application/components/text/title", title: result[:title] %>!</p> + <% when "message" %> + <p><%= result[:body] %></p> + <% when "error" %> + <p class="text-red-500"><%= result[:message] %></p> + <% when "br" %> + <br /> + <% end %> + <% end %> +</div> diff --git a/app/views/application/_timer.html.erb b/app/views/application/_timer.html.erb new file mode 100644 index 0000000..908689b --- /dev/null +++ b/app/views/application/_timer.html.erb @@ -0,0 +1,18 @@ +<% if current_char.activity %> + <div data-controller="timer" + data-timer-start-value="<%= current_char.activity_time_remaining.ceil %>" + data-timer-post-url-value="<%= finish_activity_url %>" + class="text-center"> + <span data-timer-target="timer" class="text-3xl"></span> + </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-4"> + <%= button_to "Stop", stop_activity_path %> + </div> +<% end %> |