diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/application/_navbar.html.erb | 20 | ||||
-rw-r--r-- | app/views/application/_results.html.erb | 4 | ||||
-rw-r--r-- | app/views/application/_timer.html.erb | 100 | ||||
-rw-r--r-- | app/views/application/components/text/_title.html.erb | 14 | ||||
-rw-r--r-- | app/views/characters/bestiary/index.html.erb | 22 | ||||
-rw-r--r-- | app/views/characters/items/index.html.erb | 4 | ||||
-rw-r--r-- | app/views/characters/show.html.erb | 28 | ||||
-rw-r--r-- | app/views/characters/skills/_infix_slot.html.erb | 3 | ||||
-rw-r--r-- | app/views/characters/skills/index.html.erb | 58 | ||||
-rw-r--r-- | app/views/characters/spells/index.html.erb | 10 | ||||
-rw-r--r-- | app/views/game/finish_activity.js.erb | 10 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 2 |
12 files changed, 190 insertions, 85 deletions
diff --git a/app/views/application/_navbar.html.erb b/app/views/application/_navbar.html.erb index be2d9f2..e315b42 100644 --- a/app/views/application/_navbar.html.erb +++ b/app/views/application/_navbar.html.erb @@ -1,21 +1,27 @@ -<ul class="py-2 px-2 col-span-12 text-display"> +<ul class="py-2 px-2 col-span-12 text-display space-x-2.5"> <% if current_char %> - <li class="mr-6 inline"> + <li class="inline"> <%= link_to "Locations", locations_path %> </li> - <li class="mr-6 inline"> + <li class="inline"> <%= link_to "Character", character_path(current_char) %> </li> - <li class="mr-6 inline"> + <li class="inline"> + <%= link_to "Skills", character_skills_path(current_char) %> + </li> + <li class="inline"> <%= link_to "Inventory", character_items_path(current_char) %> </li> - <li class="mr-6 inline"> + <li class="inline"> + <%= link_to "Spells", character_spells_path(current_char) %> + </li> + <li class="inline"> <%= link_to "Hearth", character_hearth_path(current_char) %> </li> - <li class="mr-6 inline"> + <li class="inline"> <%= link_to "Bazaar", bazaar_path %> </li> - <li class="mr-6 inline"> + <li class="inline"> <%= link_to "Messages", messages_path %> </li> <% end %> diff --git a/app/views/application/_results.html.erb b/app/views/application/_results.html.erb index ec62991..a7dc002 100644 --- a/app/views/application/_results.html.erb +++ b/app/views/application/_results.html.erb @@ -13,7 +13,7 @@ <p>You planted <%= link_to result[:hearth_planting].item.name, item_path(result[:hearth_planting].item) %> in the loam.</p> <% when "activity" %> - <p>You realized how to <%= result[:activity].name %>!</p> + <p>You learned how to <%= result[:activity].name %>!</p> <% when "monster" %> <p>You encountered a <%= result[:monster].name %>.</p> <p class="text-xs italic"><%= result[:monster].description %></p> @@ -24,6 +24,8 @@ <p class="text-xs">You gained <%= result[:xp] %> <%= result[:skill].name %> XP.</p> <% when "title" %> <p>You earned the title <%= render "application/components/text/title", title: result[:title] %>!</p> + <% when "condition" %> + <p>You gained the <%= result[:condition].name %> condition.</p> <% when "message" %> <p><%= result[:body] %></p> <% when "warning" %> diff --git a/app/views/application/_timer.html.erb b/app/views/application/_timer.html.erb index d683c6a..51d9b81 100644 --- a/app/views/application/_timer.html.erb +++ b/app/views/application/_timer.html.erb @@ -1,61 +1,63 @@ -<% if current_char.activity %> - <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2> - <div data-controller="timer" - data-timer-time-remaining-value="<%= current_char.activity_time_remaining %>" - data-timer-activity-duration-value="<%= current_char.activity_duration - current_char.rested_duration_to_spend_on_activity %>" - data-timer-post-url-value="<%= finish_activity_url %>"> - <div class="text-center"> - <span data-timer-target="timer" class="text-xl text-display"></span> - </div> - <div class="border border-gray-800 h-4 my-1"> - <div data-timer-target="progressBar" class="bg-gray-600 h-full" - style="width: <%= current_char.percentage_of_activity_completed %>%"> +<% if current_char %> + <% if current_char.activity %> + <h2 class="text-lg text-display text-center"><%= current_char.activity.name %></h2> + <div data-controller="timer" + data-timer-time-remaining-value="<%= current_char.activity_time_remaining %>" + data-timer-activity-duration-value="<%= current_char.activity_duration - current_char.rested_duration_to_spend_on_activity %>" + data-timer-post-url-value="<%= finish_activity_url %>"> + <div class="text-center"> + <span data-timer-target="timer" class="text-xl text-display"></span> + </div> + <div class="border border-gray-800 h-4 my-1"> + <div data-timer-target="progressBar" class="bg-gray-600 h-full" + style="width: <%= current_char.percentage_of_activity_completed %>%"> + </div> </div> </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"> - <%= button_to "Stop", stop_activity_path, class: "text-sm" %> - </div> - - <div class="text-center text-xs my-2"> - <% if current_char.activity.gid.include?("beastslay") %> - <%= current_char.wounds %> / <%= pluralize(current_char.max_wounds, "wound") %> - <% 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> + <% 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> -<% 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="text-center my-2"> + <%= button_to "Stop", stop_activity_path, class: "text-sm" %> + </div> - <div class="my-2"> - <%= button_to current_char.resting? ? "Stop Resting" : "Start Resting", toggle_resting_path %> + <div class="text-center text-xs my-2"> + <% if current_char.activity.gid.include?("beastslay") %> + <%= current_char.wounds %> / <%= pluralize(current_char.max_wounds, "wound") %> + <% 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> - <div class="text-xs"> - You have <%= distance_of_time_in_words_to_now(current_char.rested_until) %> of rested time. + <% else %> + <div class="text-center"> <% if current_char.resting? %> - This does not include time from your current rest. That time will be added when you stop 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> - </div> + <% end %> <% end %> diff --git a/app/views/application/components/text/_title.html.erb b/app/views/application/components/text/_title.html.erb index a7c2a7e..5e1d5a2 100644 --- a/app/views/application/components/text/_title.html.erb +++ b/app/views/application/components/text/_title.html.erb @@ -10,6 +10,20 @@ <span class="text-purple-200">Aspirant</span> <% when "sentinel" %> <span class="text-gray-500">S</span><span class="text-gray-400">e</span><span class="text-gray-300">n</span><span class="text-gray-200">ti</span><span class="text-gray-300">n</span><span class="text-gray-400">e</span><span class="text-gray-500">l</span> + <% when "spiteful" %> + <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-500 to-red-900">Spiteful</span> + <% when "hateful" %> + <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-600 to-red-800">Hateful</span> + <% when "vicious" %> + <span class="text-transparent bg-clip-text bg-gradient-to-b from-gray-700 to-red-700">Vicious</span> + <% when "slayer" %> + <span class="text-red-400">Slayer</span> + <% when "butcher" %> + <span class="text-red-500">Butcher</span> + <% when "slaughterer" %> + <span class="text-red-600">Slaughterer</span> + <% when "massacrer" %> + <span class="text-red-700">Massacrer</span> <% else %> <%= title.name %> <% end %> diff --git a/app/views/characters/bestiary/index.html.erb b/app/views/characters/bestiary/index.html.erb new file mode 100644 index 0000000..f7376e9 --- /dev/null +++ b/app/views/characters/bestiary/index.html.erb @@ -0,0 +1,22 @@ +<h1 class="text-3xl mb-4">Bestiary</h1> + +<% if @monster_kills.any? %> + <table class="table-auto"> + <thead> + <tr> + <th class="table-header-padded">Monster</th> + <th class="table-header-padded">Kills</th> + </tr> + </thead> + <tbody> + <% @monster_kills.ordered_by_monster_name.each do |mk| %> + <tr> + <td class="table-cell-padded"><%= mk.monster.name %></td> + <td class="table-cell-padded"><%= mk.quantity %></td> + </tr> + <% end %> + </tbody> + </table> +<% else %> + <p>You haven't killed any monsters yet.</p> +<% end %> diff --git a/app/views/characters/items/index.html.erb b/app/views/characters/items/index.html.erb index 671e68f..57e8531 100644 --- a/app/views/characters/items/index.html.erb +++ b/app/views/characters/items/index.html.erb @@ -35,6 +35,10 @@ character_items: @character.character_items.ordered_by_item_name.select { |ci| ci.item.has_tag?("currency") } %> +<%= render "characters/items/inventory_section", heading: "Omens", + character_items: @character.character_items.ordered_by_item_name.select { |ci| + ci.item.has_tag?("omen") } %> + <%= render "characters/items/inventory_section", heading: "Seeds", character_items: @character.character_items.ordered_by_item_name.select { |ci| ci.item.has_tag?("seed") } %> diff --git a/app/views/characters/show.html.erb b/app/views/characters/show.html.erb index a7b7c0e..ce8c461 100644 --- a/app/views/characters/show.html.erb +++ b/app/views/characters/show.html.erb @@ -5,6 +5,7 @@ <div class="text-lg text-display mb-4"> <ul class="flex flex-row"> <li class="mr-2"><%= link_to "Titles", character_titles_path(@character) %></li> + <li class="mr-2"><%= link_to "Bestiary", character_bestiary_path(@character) %></li> <li class="mr-2"><%= link_to "Rankings", character_rankings_path(@character) %></li> </ul> </div> @@ -30,7 +31,7 @@ <div class="my-2"> <% if @character == current_char %> <h2 class="text-xl mb-2">Combat Styles</h2> - <%= form_with url: character_combat_styles_path(character_id: @character) do |f| %> + <%= form_with url: combat_styles_character_path(@character) do |f| %> <%= f.label :offensive_style, "Offensive" %> <%= f.select :offensive_style, Character.offensive_styles.keys.to_a, selected: @character.offensive_style %> @@ -149,31 +150,6 @@ </div> </div> -<div class="my-6"> - <h2 class="text-xl mb-4">Skills</h2> - - <table class="table-auto mb-8"> - <thead> - <tr> - <th class="table-header-padded">Skill</th> - <th class="table-header-padded">Level</th> - <th class="table-header-padded">XPTNL</th> - <th class="table-header-padded">Total XP</th> - </tr> - </thead> - <tbody> - <% @character.character_skills.ordered_by_skill_name.each do |cs| %> - <tr> - <td class="table-cell-padded"><%= cs.skill.name %></td> - <td class="table-cell-padded"><%= cs.level %></td> - <td class="table-cell-padded"><%= cs.xp_to_next_level %></td> - <td class="table-cell-padded"><%= cs.xp %></td> - </tr> - <% end %> - </tbody> - </table> -</div> - <% if @character == current_char %> <%= link_to "Manage account", edit_user_registration_path, class: "text-sm" %> <% end %> diff --git a/app/views/characters/skills/_infix_slot.html.erb b/app/views/characters/skills/_infix_slot.html.erb new file mode 100644 index 0000000..0113596 --- /dev/null +++ b/app/views/characters/skills/_infix_slot.html.erb @@ -0,0 +1,3 @@ +<div class="flex justify-between items-center border-t border-gray-700 p-2"> + <%= yield %> +</div> diff --git a/app/views/characters/skills/index.html.erb b/app/views/characters/skills/index.html.erb new file mode 100644 index 0000000..af40e38 --- /dev/null +++ b/app/views/characters/skills/index.html.erb @@ -0,0 +1,58 @@ +<h2 class="text-3xl mb-2">Skills</h2> +<div class="grid gap-4 grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4"> + <% @character.character_skills.ordered_by_skill_name.each do |cs| %> + <div> + <div class="rounded border border-gray-700"> + <div class="flex p-1"> + <div class="flex-grow"> + <div class="text-xl text-display mb-1"> + <%= cs.skill.name %> + </div> + <div class="flex items-center text-xs space-x-4"> + <div><span class="bg-gray-700 px-1 py-0.5 rounded mr-1">XP</span><%= cs.xp %></div> + <div><span class="bg-gray-700 px-1 py-0.5 rounded mr-1">TNL</span><%= cs.xp_to_next_level %></div> + </div> + </div> + <div class="text-xl m-2 text-display"> + <%= cs.level %> + </div> + </div> + <div class="border border-gray-700 h-2 mt-1 -mb-px -mx-px"> + <div class="bg-gray-600 h-full" style="width: <%= cs.percentage_of_skill_level_completed %>%"> + </div> + </div> + <% @character.item_infixes.where(skill: cs.skill).each do |ii| %> + <%= render "characters/skills/infix_slot" do %> + <div> + <%= ii.item.name %> + </div> + <div> + <%= button_to "Remove", character_item_infix_path(id: ii.id), method: :delete %> + </div> + <% end %> + <% end %> + <% @character.available_infixes(cs.skill).times do %> + <%= render "characters/skills/infix_slot" do %> + <%# TODO: Don't load all into memory %> + <% infixable_items = @character.items.select {|i| i.infixable?(cs.skill)} %> + <% if infixable_items.any? %> + <%= form_with url: character_item_infixes_path, class: "w-full" do |f| %> + <div class="flex space-x-1"> + <div class="flex-grow"> + <%= f.select :item_id, infixable_items.map { |i| [i.name, i.id]}, {}, class: "w-full" %> + <%= f.hidden_field :skill_id, value: cs.skill.id %> + </div> + <div> + <%= f.submit "Infix" %> + </div> + </div> + <% end %> + <% else %> + <div class="text-gray-500">No omens to infix.</div> + <% end %> + <% end %> + <% end %> + </div> + </div> + <% end %> +</div> diff --git a/app/views/characters/spells/index.html.erb b/app/views/characters/spells/index.html.erb new file mode 100644 index 0000000..5f415a3 --- /dev/null +++ b/app/views/characters/spells/index.html.erb @@ -0,0 +1,10 @@ +<h2 class="text-3xl mb-2">Spells</h2> +<div data-controller="activity-select"> + <%= form_with url: start_activity_path, method: :post do |f| %> + <%= f.select :id, @spell_activities.map { |a| [a.name, a.id] }, {}, + { data: { activity_select_target: "select", action: "activity-select#load" } } %> + <%= f.number_field :actions, value: 1, size: 5, min: 1, max: 2_000_000_000 %> + <%= f.submit "Cast" %> + <% end %> + <div data-activity-select-target="output" class="my-1"></div> +</div> diff --git a/app/views/game/finish_activity.js.erb b/app/views/game/finish_activity.js.erb index fa3d228..f281986 100644 --- a/app/views/game/finish_activity.js.erb +++ b/app/views/game/finish_activity.js.erb @@ -4,10 +4,16 @@ var resultControlsDiv = document.getElementById("activity_controls"); var outputHTML = "<%= j render(partial: "application/results", locals: { results: @results }) %>" if (resultOutputDiv) { - resultOutputDiv.innerHTML += outputHTML; - // If scrolled to the bottom or near the bottom, then smooth scroll to the bottom. + // (Check before adding output, because a large output could prevent the scroll when it shouldn't.) + var shouldScroll = false; if ((resultOutputDiv.scrollTop + 100) >= (resultOutputDiv.scrollHeight - resultOutputDiv.offsetHeight)) { + shouldScroll = true; + } + + resultOutputDiv.innerHTML += outputHTML; + + if (shouldScroll) { resultOutputDiv.scrollTo({ top: resultOutputDiv.scrollHeight, left: 0, behavior: 'smooth' }); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 309dc29..048a6ed 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,6 +40,8 @@ </div> <div class="game-container-box overflow-auto text-sm p-2 flex-grow" id="result_output" style="max-height: 60%" + data-controller="results" + data-results-target="output" data-turbolinks-permanent> </div> </div> |