summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-03 21:26:14 -0400
committerDavid Gay <david@davidgay.org>2021-06-03 21:26:14 -0400
commit60c9de4956547d46390c948146aa6e0c865ffcda (patch)
tree7bbde799de9cec589a53a08b8e4dccf98bfdc8e3 /app
parent7f129f24e351cafafdb4bc58a44ca0d714e30af6 (diff)
Move timer and results to new game containers which are always visible
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/look_controller.rb4
-rw-r--r--app/models/character.rb4
-rw-r--r--app/views/application/_navbar.html.erb3
-rw-r--r--app/views/application/_timer.html.erb37
-rw-r--r--app/views/characters/show.html.erb4
-rw-r--r--app/views/game/finish_activity.js.erb2
-rw-r--r--app/views/layouts/application.html.erb18
-rw-r--r--app/views/look/show.html.erb7
9 files changed, 53 insertions, 28 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7a59299..181841d 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base
end
queued_actions = params[:actions].present? ? params[:actions].to_i - 1 : nil
if current_char.start_activity(activity, queued_actions: queued_actions)
- redirect_to look_path
+ redirect_to character_path(current_char)
else
message = "You can't do that."
message += " (requires #{activity.requirements&.join(", ")})" if activity.requirements.any?
diff --git a/app/controllers/look_controller.rb b/app/controllers/look_controller.rb
deleted file mode 100644
index 17cbbcb..0000000
--- a/app/controllers/look_controller.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-class LookController < ApplicationController
- def show
- end
-end
diff --git a/app/models/character.rb b/app/models/character.rb
index 84583a8..1169672 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -275,6 +275,10 @@ class Character < ApplicationRecord
end
end
+ def rested_until
+ Time.now + rested_duration.seconds
+ end
+
def award_title(title)
title = Title.find_by_gid(title) if title.is_a? String
# TODO: Simplify these lines?
diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb
index c45db15..c0e2761 100644
--- a/app/views/application/_navbar.html.erb
+++ b/app/views/application/_navbar.html.erb
@@ -1,9 +1,6 @@
<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/application/_timer.html.erb b/app/views/application/_timer.html.erb
index 908689b..ec10258 100644
--- a/app/views/application/_timer.html.erb
+++ b/app/views/application/_timer.html.erb
@@ -1,4 +1,5 @@
<% if current_char.activity %>
+ <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2>
<div data-controller="timer"
data-timer-start-value="<%= current_char.activity_time_remaining.ceil %>"
data-timer-post-url-value="<%= finish_activity_url %>"
@@ -12,7 +13,41 @@
<div><%= most_recent_cs.xp_to_next_level %> XP to next level</div>
</div>
- <div class="text-center my-4">
+ <div class="text-center my-3">
<%= button_to "Stop", stop_activity_path %>
</div>
+
+ <div class="text-center text-xs my-2">
+ <% if current_char.activity.gid.include?("beastslay") %>
+ <%= current_char.wounds %> / <%= current_char.max_wounds %> wounds
+ <% 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 %>
diff --git a/app/views/characters/show.html.erb b/app/views/characters/show.html.erb
index b2e8f94..dda770e 100644
--- a/app/views/characters/show.html.erb
+++ b/app/views/characters/show.html.erb
@@ -19,7 +19,7 @@
<% if @character.active_states.any? %>
<ul>
<% @character.active_states.each do |state| %>
- <ul><%= state.condition.name %> (expires in <%= state.remaining_duration %> seconds)</ul>
+ <ul><%= state.condition.name %> (expires in <%= distance_of_time_in_words_to_now(state.expires_at)%>)</ul>
<% end %>
</ul>
<% else %>
@@ -109,7 +109,7 @@
<div class="my-6">
<h2 class="text-2xl mb-4">Rest</h2>
<p class="mb-4">
- You have <%= @character.rested_duration %> seconds of rested time stored.
+ 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 %>
diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb
index d5772f4..f37c142 100644
--- a/app/views/game/finish_activity.js.erb
+++ b/app/views/game/finish_activity.js.erb
@@ -1,5 +1,5 @@
var resultOutputDiv = document.getElementById("result_output");
-var resultControlsDiv = document.getElementById("result_controls");
+var resultControlsDiv = document.getElementById("activity_controls");
var outputHTML = "<%= j render(partial: "application/results", locals: { results: @results }) %>"
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index fc627a2..513fcdd 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -21,21 +21,21 @@
<%= render "navbar" %>
<% end %>
<div class="flex flex-col col-span-12 sm:col-span-8">
- <% if user_signed_in? %>
- <div class="game-container-box mb-2 overflow-auto text-sm" style="height: 10rem;" id="result_output">
- </div>
- <% end %>
- <div class="game-container-box" style="height: 25rem;">
+ <div class="game-container-box mb-2 overflow-y-auto" style="height: 20rem;">
<%= render "flash_messages" %>
<%= yield %>
</div>
+ <% if user_signed_in? %>
+ <div class="game-container-box overflow-auto text-sm p-2" style="height: 15rem;" id="result_output"
+ data-turbolinks-permanent>
+ </div>
+ <% end %>
</div>
<% if user_signed_in? %>
<div class="flex flex-col col-span-12 sm:col-span-4">
- <div class="game-container-box mb-2" style="height: 15rem;">
- <div id="result_controls">
- <%= render "timer" %>
- </div>
+ <div class="game-container-box mb-2 overflow-y-auto" style="height: 15rem;" id="activity_controls"
+ data-turbolinks-permanent>
+ <%= render "timer" %>
</div>
<div id="chat" class="game-container-box col-span-12 sm:col-span-4" style="height: 20rem;"
data-turbolinks-permanent>
diff --git a/app/views/look/show.html.erb b/app/views/look/show.html.erb
deleted file mode 100644
index 4286944..0000000
--- a/app/views/look/show.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<% if current_char.activity %>
- <h1 class="text-2xl"><%= current_char.activity.name %></h1>
- <p><%= current_char.activity.description %></p>
-<% else %>
- <p>You're not currently doing anything. Maybe you'd like to
- <%= link_to "go somewhere", locations_path %>?</p>
-<% end %>