diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/characters/hearth_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/chat_messages_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/game_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/locations_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/look_controller.rb | 5 | ||||
-rw-r--r-- | app/javascript/controllers/chat_controller.js | 2 | ||||
-rw-r--r-- | app/models/character.rb | 1 | ||||
-rw-r--r-- | app/models/location.rb | 1 | ||||
-rw-r--r-- | app/views/application/_chat.html.erb | 21 | ||||
-rw-r--r-- | app/views/application/_navbar.html.erb | 2 | ||||
-rw-r--r-- | app/views/application/_timer.html.erb | 8 | ||||
-rw-r--r-- | app/views/chat_messages/index.html.erb | 9 | ||||
-rw-r--r-- | app/views/locations/index.html.erb | 8 | ||||
-rw-r--r-- | app/views/look/look.html.erb (renamed from app/views/locations/show.html.erb) | 2 |
14 files changed, 48 insertions, 32 deletions
diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb index c525add..ab9676e 100644 --- a/app/controllers/characters/hearth_controller.rb +++ b/app/controllers/characters/hearth_controller.rb @@ -8,6 +8,7 @@ class Characters::HearthController < ApplicationController laboratory: [], spicebench: [], binding_array: [], + aetherloom: [], } Activity.where("gid like ?", "craft_%").each do |activity| @@ -23,6 +24,8 @@ class Characters::HearthController < ApplicationController @amenity_activities[:spicebench].push(activity) && next when "binding_array" @amenity_activities[:binding_array].push(activity) && next + when "aetherloom" + @amenity_activities[:aetherloom].push(activity) && next else raise "Invalid amenity gid (#{requirement_data[:gid]}" end diff --git a/app/controllers/chat_messages_controller.rb b/app/controllers/chat_messages_controller.rb index 9112bb7..a299379 100644 --- a/app/controllers/chat_messages_controller.rb +++ b/app/controllers/chat_messages_controller.rb @@ -1,7 +1,10 @@ class ChatMessagesController < ApplicationController def index - # TODO: Let's rename this method to #list - @chat_messages = ChatMessage.order(created_at: :desc).limit(100).reverse + @chat_messages = ChatMessage.order(created_at: :desc).limit(2000) + end + + def list + @chat_messages = ChatMessage.order(created_at: :asc).limit(200) render partial: "chat_messages/list" end diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 39ea6c9..4bbbf53 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -18,7 +18,7 @@ class GameController < ApplicationController def stop_activity current_char.stop_activity - redirect_to locations_path + redirect_to look_path end def finish_activity diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb deleted file mode 100644 index 4616c3d..0000000 --- a/app/controllers/locations_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -class LocationsController < ApplicationController - def index - @locations = Location.all - end - - def show - @location = Location.find(params[:id]) - end -end diff --git a/app/controllers/look_controller.rb b/app/controllers/look_controller.rb new file mode 100644 index 0000000..e604670 --- /dev/null +++ b/app/controllers/look_controller.rb @@ -0,0 +1,5 @@ +class LookController < ApplicationController + def look + @location = current_char.location + end +end diff --git a/app/javascript/controllers/chat_controller.js b/app/javascript/controllers/chat_controller.js index 95b61c5..0605b3a 100644 --- a/app/javascript/controllers/chat_controller.js +++ b/app/javascript/controllers/chat_controller.js @@ -18,7 +18,7 @@ export default class extends Controller { load() { this.scrollToBottom(); if (this.outputTarget.innerHTML.trim() === "") { - fetch("/chat_messages") + fetch("/chat_messages/list") .then(response => response.text()) .then(html => { this.outputTarget.innerHTML = html; diff --git a/app/models/character.rb b/app/models/character.rb index 2669626..96dafd0 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,6 +1,7 @@ class Character < ApplicationRecord belongs_to :user belongs_to :activity, optional: true + belongs_to :location has_many :title_awards has_many :titles, through: :title_awards belongs_to :active_title, class_name: "Title", optional: true diff --git a/app/models/location.rb b/app/models/location.rb index e008270..7bd1386 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -2,6 +2,7 @@ class Location < ApplicationRecord include HasWhatnot has_many :activities + has_many :characters has_many :monster_spawns validates :gid, :name, presence: true end diff --git a/app/views/application/_chat.html.erb b/app/views/application/_chat.html.erb index b656ed7..1ba6f8f 100644 --- a/app/views/application/_chat.html.erb +++ b/app/views/application/_chat.html.erb @@ -3,13 +3,20 @@ <div data-chat-target="output" id="chat_output" class="game-container-box overflow-y-auto overflow-x-hidden break-words flex-grow"> </div> <div class="flex-none"> - <%= form_with model: ChatMessage.new, html: { autocomplete: "off" }, local: false, - data: { action: "chat#send" }, class: "flex" do |f| %> - <%= f.collection_select :chat_room_id, ChatRoom.accessible_to(current_char.user), - :id, :short_name, class: "flex-none" %> - <%= f.text_field :body, size: "1", maxlength: 255, required: true, - data: { chat_target: "message" }, class: "flex-grow inline-flex" %> - <% end %> + <div class="flex items-center"> + <div class="flex-grow"> + <%= form_with model: ChatMessage.new, html: { autocomplete: "off" }, local: false, + data: { action: "chat#send" }, class: "flex" do |f| %> + <%= f.collection_select :chat_room_id, ChatRoom.accessible_to(current_char.user), + :id, :short_name, class: "flex-none" %> + <%= f.text_field :body, size: "1", maxlength: 255, required: true, + data: { chat_target: "message" }, class: "flex-grow inline-flex" %> + <% end %> + </div> + <div class="flex-none text-xs mx-2"> + <%= link_to "History", chat_messages_path %> + </div> + </div> </div> </div> <% end %> diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index e315b42..d80e7b6 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -1,7 +1,7 @@ <ul class="py-2 px-2 col-span-12 text-display space-x-2.5"> <% if current_char %> <li class="inline"> - <%= link_to "Locations", locations_path %> + <%= link_to "Look", look_path %> </li> <li class="inline"> <%= link_to "Character", character_path(current_char) %> diff --git a/app/views/application/_timer.html.erb b/app/views/application/_timer.html.erb index 51d9b81..a18e739 100644 --- a/app/views/application/_timer.html.erb +++ b/app/views/application/_timer.html.erb @@ -15,14 +15,18 @@ </div> </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-2"> + <div class="text-center text-sm my-2"> + <% if current_char.queued_actions %> + <div class="my-1"> + <%= pluralize(current_char.queued_actions + 1, "action") %> remaining. + </div> + <% end %> <%= button_to "Stop", stop_activity_path, class: "text-sm" %> </div> diff --git a/app/views/chat_messages/index.html.erb b/app/views/chat_messages/index.html.erb new file mode 100644 index 0000000..8791e7b --- /dev/null +++ b/app/views/chat_messages/index.html.erb @@ -0,0 +1,9 @@ +<h1 class="text-3xl mb-4"> + Chat History +</h1> + +<p class="mb-4">Last 2,000 messages listed from newest to oldest.</p> + +<div class="text-sm"> + <%= render "chat_messages/list" %> +</div> diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb deleted file mode 100644 index 3c9b837..0000000 --- a/app/views/locations/index.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<h1 class="text-3xl mb-4">Locations</h1> - -<% @locations.each do |location| %> - <div class="my-4"> - <h2 class="text-xl"><%= link_to location.name, location_path(location) %></h2> - <p class="italic"><%= location.description %></p> - </div> -<% end %> diff --git a/app/views/locations/show.html.erb b/app/views/look/look.html.erb index fcc668a..2f1074a 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/look/look.html.erb @@ -6,7 +6,7 @@ <% @location.monster_spawns.select(&:alive?).each do |ms| %> <p class="text-yellow-400">A <%= ms.monster.name %> is ravaging this location! (<%= ms.remaining_hp %> HP)</p> <%# TODO: HACK %> - <% activity = Activity.find_by_gid("beastslay_leviathan_floret_region") %> + <% activity = Activity.find_by_gid("beastslay_leviathan_floret") %> <%= form_with url: start_activity_path(activity) do |f| %> <%= f.hidden_field :id, value: activity.id %> <%= f.submit "Hunt" %> |