diff options
author | David Gay <david@davidgay.org> | 2021-05-31 13:33:13 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-31 13:33:13 -0400 |
commit | 0fac92a969f8f3049a55a824c1af65255c9d1654 (patch) | |
tree | 0fd96a4932d46f12e6cedb1584ae045f5e0a8af2 /app/controllers/characters | |
parent | ac6275842b2bb879f7d95a7a49da0017efaf6697 (diff) |
Plug in equip requirements
Diffstat (limited to 'app/controllers/characters')
-rw-r--r-- | app/controllers/characters/items_controller.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/characters/items_controller.rb b/app/controllers/characters/items_controller.rb index 722c8ff..470e21c 100644 --- a/app/controllers/characters/items_controller.rb +++ b/app/controllers/characters/items_controller.rb @@ -5,10 +5,15 @@ class Characters::ItemsController < ApplicationController def equip @item = Item.find(params[:item_id]) + unless current_char.can_equip? @item + flash[:alert] = "Couldn't equip #{@item.name}" + flash[:alert] += " (requires #{@item.equip_requirements&.join(", ")})" if @item.equip_requirements.any? + return + end current_char.equip(@item) flash[:notice] = "Equipped #{@item.name}." rescue EquipmentError - flash[:alert] = "Couldn't equip #{@item.name}." + flash[:alert] = "Couldn't equip #{@item.name}. Make sure the slot is free." ensure redirect_to character_items_path(current_char) end |