From 03b8bfa53b02754d7c375690d92ed83c1cd661da Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 13 Jun 2021 21:40:42 -0400 Subject: Fix wrong param name in new CharacterController `#set_character` --- app/controllers/characters/skills_controller.rb | 15 ++ app/controllers/characters_controller.rb | 2 +- app/views/characters/skills/index.html.erb | 176 ++++++++++++++++++++++++ 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 app/controllers/characters/skills_controller.rb create mode 100644 app/views/characters/skills/index.html.erb (limited to 'app') diff --git a/app/controllers/characters/skills_controller.rb b/app/controllers/characters/skills_controller.rb new file mode 100644 index 0000000..6fcf417 --- /dev/null +++ b/app/controllers/characters/skills_controller.rb @@ -0,0 +1,15 @@ +class Characters::SkillsController < ApplicationController + before_action :set_character, only: :index + + def index + end + + private + def set_character + @character = Character.find(params[:character_id]) + unless current_char == @character + flash[:alert] = "You can only look at your own skills." + redirect_to character_path(@character) + end + end +end diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index 1a91988..2eb906b 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -37,7 +37,7 @@ class CharactersController < ApplicationController end def set_character - @character = Character.find(params[:character_id]) + @character = Character.find(params[:id]) unless current_char == @character flash[:alert] = "You can only manage your own character." redirect_to character_path(@character) diff --git a/app/views/characters/skills/index.html.erb b/app/views/characters/skills/index.html.erb new file mode 100644 index 0000000..f13e611 --- /dev/null +++ b/app/views/characters/skills/index.html.erb @@ -0,0 +1,176 @@ +

Skills

+
+ +
+ +

First entered the planes + <%= pluralize((Date.current - @character.created_at.to_date).to_i, "day") %> ago.

+ +

Learned <%= @character.learned_activities.count %> recipe(s) or technique(s).

+ +
+
+

Boons & Banes

+ <% if @character.active_states.any? %> +
    + <% @character.active_states.each do |state| %> +
      <%= state.condition.name %> (expires in <%= distance_of_time_in_words_to_now(state.expires_at)%>)
    + <% end %> +
+ <% else %> +

No boons or banes affect you.

+ <% end %> +
+
+ <% if @character == current_char %> +

Combat Styles

+ <%= form_with url: character_combat_styles_path(character_id: @character) do |f| %> + <%= f.label :offensive_style, "Offensive" %> + <%= f.select :offensive_style, Character.offensive_styles.keys.to_a, selected: @character.offensive_style %> + + <%= f.label :defensive_style, "Defensive" %> + <%= f.select :defensive_style, Character.defensive_styles.keys.to_a, selected: @character.defensive_style %> + + <%= f.submit "Set" %> + <% end %> + <% end %> +
+
+ + +
+
+
+

Combat Statistics

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Wounds<%= @character.wounds %> / <%= @character.max_wounds %>
Max HP<%= @character.max_hp %>
Speed<%= @character.speed %>
Accuracy<%= @character.accuracy(with_combat_style: true) %>
Power<%= @character.power(with_combat_style: true) %>
Evasion<%= @character.evasion(with_combat_style: true) %>
+
+
+

Resistances

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Slash<%= @character.resistance("slash")%>
Pierce<%= @character.resistance("pierce") %>
Bash<%= @character.resistance("bash") %>
Arcane<%= @character.resistance("arcane") %>
Fire<%= @character.resistance("fire") %>
Frost<%= @character.resistance("frost") %>
Lightning<%= @character.resistance("lightning") %>
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Acid<%= @character.resistance("acid") %>
Thunder<%= @character.resistance("thunder")%>
Radiant<%= @character.resistance("radiant") %>
Necrotic<%= @character.resistance("necrotic") %>
Poison<%= @character.resistance("poison") %>
Bleed<%= @character.resistance("bleed") %>
+
+
+
+
+
+ +
+

Skills

+ + + + + + + + + + + + <% @character.character_skills.ordered_by_skill_name.each do |cs| %> + + + + + + + <% end %> + +
SkillLevelXPTNLTotal XP
<%= cs.skill.name %><%= cs.level %><%= cs.xp_to_next_level %><%= cs.xp %>
+
+ +<% if @character == current_char %> + <%= link_to "Manage account", edit_user_registration_path, class: "text-sm" %> +<% end %> -- cgit v1.2.3