diff options
Diffstat (limited to 'app/controllers/characters_controller.rb')
-rw-r--r-- | app/controllers/characters_controller.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index d851ad5..77e1a94 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -21,6 +21,21 @@ class CharactersController < ApplicationController end end + def set_combat_styles + @character = Character.find(params[:character_id]) + unless @character == current_char + flash[:alert] = "You can't set the combat styles of another character." + redirect_to character_path(@character) and return + end + if @character.update(offensive_style: params[:offensive_style], + defensive_style: params[:defensive_style]) + flash[:notice] = "Changed combat styles to #{@character.offensive_style} and #{@character.defensive_style}." + else + flash[:alert] = "Failed to set combat styles." + end + redirect_to character_path(@character) + end + private def character_params params.require(:character).permit(:name) |