summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-27 18:41:51 -0400
committerDavid Gay <david@davidgay.org>2021-05-27 18:41:51 -0400
commit65c1ee3dbaf5c0a030dd28a7e3f41d47c7652cb1 (patch)
tree7536a43e8656d7cecc867c9a221fced1f225f731
parent2c2de801b4481695f3d1b6b14527116092cb1197 (diff)
Move active action display with timer and results to a `LookController`
-rw-r--r--app/controllers/activities_controller.rb2
-rw-r--r--app/controllers/look_controller.rb4
-rw-r--r--app/views/activities/show.html.erb23
-rw-r--r--app/views/application/_navbar.html.erb3
-rw-r--r--app/views/game/finish_activity.js.erb4
-rw-r--r--app/views/locations/show.html.erb4
-rw-r--r--app/views/look/_results.html.erb (renamed from app/views/activities/_results.html.erb)0
-rw-r--r--app/views/look/_timer.html.erb (renamed from app/views/activities/_timer.html.erb)4
-rw-r--r--app/views/look/show.html.erb10
-rw-r--r--config/routes.rb1
10 files changed, 38 insertions, 17 deletions
diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb
index 37403c7..a1a1835 100644
--- a/app/controllers/activities_controller.rb
+++ b/app/controllers/activities_controller.rb
@@ -6,7 +6,7 @@ class ActivitiesController < ApplicationController
def start
@activity = Activity.find(params[:id])
if current_char.start_activity(@activity, queued_actions: params[:queued_actions])
- redirect_to activity_path(@activity)
+ redirect_to look_path
else
message = "You can't do that."
message += " (requires #{@activity.requirements&.join(", ")})" if @activity.requirements
diff --git a/app/controllers/look_controller.rb b/app/controllers/look_controller.rb
new file mode 100644
index 0000000..17cbbcb
--- /dev/null
+++ b/app/controllers/look_controller.rb
@@ -0,0 +1,4 @@
+class LookController < ApplicationController
+ def show
+ end
+end
diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb
index c9c6d25..4516b51 100644
--- a/app/views/activities/show.html.erb
+++ b/app/views/activities/show.html.erb
@@ -1,15 +1,12 @@
-<h1 class="text-2xl"><%= @activity.name %></h1>
-<p><%= @activity.description %></p>
+<h1 class="text-3xl mb-2"><%= @activity.name %></h1>
+<p class="italic"><%= @activity.description %></p>
-<div class="min-w-full my-2 px-1 overflow-auto text-sm border-2 border-gray-800 rounded"
- style="height: 30rem;" id="result_output">
+<div class="my-6">
+ <h2 class="text-xl">Game Data</h2>
+ <p>GID: <span class="text-code"><%= @activity.gid %></span></p>
+ <% if @activity.whatnot %>
+ <div class="text-code my-2"><%= JSON.pretty_generate(@activity.whatnot) %></div>
+ <% else %>
+ <p>Item has no additional data.</p>
+ <% end %>
</div>
-
-<div id="result_controls">
- <%= render "timer" %>
-</div>
-
-<%= form_with url: start_activity_path do |f| %>
- <%= f.hidden_field :id, value: @activity.id %>
- <%= f.submit "Start" %>
-<% end %>
diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb
index c0e2761..c45db15 100644
--- a/app/views/application/_navbar.html.erb
+++ b/app/views/application/_navbar.html.erb
@@ -1,6 +1,9 @@
<ul class="py-2 px-2 col-span-12 text-display">
<% if current_char %>
<li class="mr-6 inline">
+ <%= link_to "Look", look_path %>
+ </li>
+ <li class="mr-6 inline">
<%= link_to "Locations", locations_path %>
</li>
<li class="mr-6 inline">
diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb
index 0732600..79659b6 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: "activities/results", locals: { results: @results }) %>"
+var outputHTML = "<%= j render(partial: "look/results", locals: { results: @results }) %>"
if (resultOutputDiv) {
resultOutputDiv.innerHTML += outputHTML;
@@ -11,5 +11,5 @@ if (resultOutputDiv) {
}
if (resultControlsDiv) {
- resultControlsDiv.innerHTML = "<%= j render(partial: "activities/timer") %>"
+ resultControlsDiv.innerHTML = "<%= j render(partial: "look/timer") %>"
}
diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb
index bed97ac..0001c99 100644
--- a/app/views/locations/show.html.erb
+++ b/app/views/locations/show.html.erb
@@ -7,5 +7,9 @@
<div class="my-4">
<h2 class="text-xl"><%= link_to activity.name, activity_path(activity) %></h2>
<p class="italic"><%= activity.description %></p>
+ <%= form_with url: start_activity_path(activity) do |f| %>
+ <%= f.hidden_field :id, value: activity.id %>
+ <%= f.submit "Start" %>
+ <% end %>
</div>
<% end %>
diff --git a/app/views/activities/_results.html.erb b/app/views/look/_results.html.erb
index 36e8103..36e8103 100644
--- a/app/views/activities/_results.html.erb
+++ b/app/views/look/_results.html.erb
diff --git a/app/views/activities/_timer.html.erb b/app/views/look/_timer.html.erb
index c7d881c..908689b 100644
--- a/app/views/activities/_timer.html.erb
+++ b/app/views/look/_timer.html.erb
@@ -12,5 +12,7 @@
<div><%= most_recent_cs.xp_to_next_level %> XP to next level</div>
</div>
- <%= button_to "Stop", stop_activity_path %>
+ <div class="text-center my-4">
+ <%= button_to "Stop", stop_activity_path %>
+ </div>
<% end %>
diff --git a/app/views/look/show.html.erb b/app/views/look/show.html.erb
new file mode 100644
index 0000000..a0c1bd7
--- /dev/null
+++ b/app/views/look/show.html.erb
@@ -0,0 +1,10 @@
+<h1 class="text-2xl"><%= current_char.activity.name %></h1>
+<p><%= current_char.activity.description %></p>
+
+<div class="min-w-full my-2 px-1 overflow-auto text-sm border-2 border-gray-800 rounded"
+ style="height: 30rem;" id="result_output">
+</div>
+
+<div id="result_controls">
+ <%= render "timer" %>
+</div>
diff --git a/config/routes.rb b/config/routes.rb
index 6be4012..96fec1f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -40,6 +40,7 @@ Rails.application.routes.draw do
post "/bazaar/accept/:id", to: "bazaar#accept_offer", as: :bazzar_accept_offer
delete "/bazaar/cancel/:id", to: "bazaar#cancel_offer", as: :bazzar_cancel_offer
+ get "/look", to: "look#show"
post "/start_activity", to: "activities#start"
post "/stop_activity", to: "game#stop_activity"
post "/finish_activity", to: "game#finish_activity"