diff options
author | David Gay <david@davidgay.org> | 2021-06-03 21:26:14 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-03 21:26:14 -0400 |
commit | 60c9de4956547d46390c948146aa6e0c865ffcda (patch) | |
tree | 7bbde799de9cec589a53a08b8e4dccf98bfdc8e3 | |
parent | 7f129f24e351cafafdb4bc58a44ca0d714e30af6 (diff) |
Move timer and results to new game containers which are always visible
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/look_controller.rb | 4 | ||||
-rw-r--r-- | app/models/character.rb | 4 | ||||
-rw-r--r-- | app/views/application/_navbar.html.erb | 3 | ||||
-rw-r--r-- | app/views/application/_timer.html.erb | 37 | ||||
-rw-r--r-- | app/views/characters/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/game/finish_activity.js.erb | 2 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 18 | ||||
-rw-r--r-- | app/views/look/show.html.erb | 7 | ||||
-rw-r--r-- | config/routes.rb | 1 |
11 files changed, 62 insertions, 29 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 529bf6c..28a0956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ Note that from this point foward, I am not explicitly listing the activities req amenities, etc that are added unless they are special in some way. ### Added +- Current activity, timer, results, and conditions (boons & banes) are now always visible. Most are located in a new box + above the chat, while the results output is now in a new box below the main box. +- You can now see your resting status and toggle rest in the new timer box when you aren't performing an activity. - Spicework has been implemented. You can now craft food and drugs in your hearth, once you build a spicebench. A character can only have one food condition and one drink condition at a time. If a second food or drink condition is gained, the old one is lost. There is no limit to the number of drug conditions a character can have at once. @@ -14,6 +17,12 @@ amenities, etc that are added unless they are special in some way. - New items: bluster powder, mudtub mash, midoras spice, midoras mudtub mash - New title: Aspirant, gained by reaching 100 total level +### Changed +- Remaining duration of conditions and accumulated rested time are now expressed in "human" terms instead of seconds. + +### Removed +- The "Look" view. + ### Fixed - No blank line was being added to combat activity results if the activity was stopped due to being too wounded. 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 %> diff --git a/config/routes.rb b/config/routes.rb index 4dea419..8510966 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,7 +44,6 @@ 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" |