From 7f129f24e351cafafdb4bc58a44ca0d714e30af6 Mon Sep 17 00:00:00 2001 From: David Gay Date: Thu, 3 Jun 2021 20:50:58 -0400 Subject: Move timer and results to new game containers which are always visible --- app/views/application/_results.html.erb | 32 ++++++++++++++++++++++++++++++++ app/views/application/_timer.html.erb | 18 ++++++++++++++++++ app/views/game/finish_activity.js.erb | 4 ++-- app/views/layouts/application.html.erb | 11 +++++++---- app/views/look/_results.html.erb | 32 -------------------------------- app/views/look/_timer.html.erb | 18 ------------------ app/views/look/show.html.erb | 8 -------- 7 files changed, 59 insertions(+), 64 deletions(-) create mode 100644 app/views/application/_results.html.erb create mode 100644 app/views/application/_timer.html.erb delete mode 100644 app/views/look/_results.html.erb delete mode 100644 app/views/look/_timer.html.erb (limited to 'app/views') 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 @@ +
+ <% results.each do |result| %> + <% case result[:type] %> + <% when "item" %> +

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 %> +

+ <% when "hearth_amenity" %> +

You constructed <%= result[:hearth_amenity].name %>.

+ <% when "hearth_planting" %> +

You planted <%= link_to result[:hearth_planting].item.name, + item_path(result[:hearth_planting].item) %> in the loam.

+ <% when "activity" %> +

You realized how to <%= result[:activity].name %>!

+ <% when "monster" %> +

You encountered a <%= result[:monster].name %>.

+

<%= result[:monster].description %>

+ <% when "xp" %> +

You gained <%= result[:xp] %> <%= result[:skill].name %> XP.

+ <% when "title" %> +

You earned the title <%= render "application/components/text/title", title: result[:title] %>!

+ <% when "message" %> +

<%= result[:body] %>

+ <% when "error" %> +

<%= result[:message] %>

+ <% when "br" %> +
+ <% end %> + <% end %> +
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 %> +
+ +
+ + <% most_recent_cs = current_char.character_skills.order(:updated_at).last %> +
+
<%= most_recent_cs.skill.name %> level <%= most_recent_cs.level %>
+
<%= most_recent_cs.xp_to_next_level %> XP to next level
+
+ +
+ <%= button_to "Stop", stop_activity_path %> +
+<% end %> diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb index 79659b6..d5772f4 100644 --- a/app/views/game/finish_activity.js.erb +++ b/app/views/game/finish_activity.js.erb @@ -1,7 +1,7 @@ var resultOutputDiv = document.getElementById("result_output"); var resultControlsDiv = document.getElementById("result_controls"); -var outputHTML = "<%= j render(partial: "look/results", locals: { results: @results }) %>" +var outputHTML = "<%= j render(partial: "application/results", locals: { results: @results }) %>" if (resultOutputDiv) { resultOutputDiv.innerHTML += outputHTML; @@ -11,5 +11,5 @@ if (resultOutputDiv) { } if (resultControlsDiv) { - resultControlsDiv.innerHTML = "<%= j render(partial: "look/timer") %>" + resultControlsDiv.innerHTML = "<%= j render(partial: "application/timer") %>" } diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 485aa21..fc627a2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,9 +21,10 @@ <%= render "navbar" %> <% end %>
-
- Results go here. -
+ <% if user_signed_in? %> +
+
+ <% end %>
<%= render "flash_messages" %> <%= yield %> @@ -32,7 +33,9 @@ <% if user_signed_in? %>
- Timer goes here. +
+ <%= render "timer" %> +
diff --git a/app/views/look/_results.html.erb b/app/views/look/_results.html.erb deleted file mode 100644 index 1da0af7..0000000 --- a/app/views/look/_results.html.erb +++ /dev/null @@ -1,32 +0,0 @@ -
- <% results.each do |result| %> - <% case result[:type] %> - <% when "item" %> -

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 %> -

- <% when "hearth_amenity" %> -

You constructed <%= result[:hearth_amenity].name %>.

- <% when "hearth_planting" %> -

You planted <%= link_to result[:hearth_planting].item.name, - item_path(result[:hearth_planting].item) %> in the loam.

- <% when "activity" %> -

You realized how to <%= result[:activity].name %>!

- <% when "monster" %> -

You encountered a <%= result[:monster].name %>.

-

<%= result[:monster].description %>

- <% when "xp" %> -

You gained <%= result[:xp] %> <%= result[:skill].name %> XP.

- <% when "title" %> -

You earned the title <%= render "application/components/text/title", title: result[:title] %>!

- <% when "message" %> -

<%= result[:body] %>

- <% when "error" %> -

<%= result[:message] %>

- <% when "br" %> -
- <% end %> - <% end %> -
diff --git a/app/views/look/_timer.html.erb b/app/views/look/_timer.html.erb deleted file mode 100644 index 908689b..0000000 --- a/app/views/look/_timer.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% if current_char.activity %> -
- -
- - <% most_recent_cs = current_char.character_skills.order(:updated_at).last %> -
-
<%= most_recent_cs.skill.name %> level <%= most_recent_cs.level %>
-
<%= most_recent_cs.xp_to_next_level %> XP to next level
-
- -
- <%= button_to "Stop", stop_activity_path %> -
-<% end %> diff --git a/app/views/look/show.html.erb b/app/views/look/show.html.erb index 2e0af81..4286944 100644 --- a/app/views/look/show.html.erb +++ b/app/views/look/show.html.erb @@ -1,14 +1,6 @@ <% if current_char.activity %>

<%= current_char.activity.name %>

<%= current_char.activity.description %>

- -
-
- -
- <%= render "timer" %> -
<% else %>

You're not currently doing anything. Maybe you'd like to <%= link_to "go somewhere", locations_path %>?

-- cgit v1.2.3