summaryrefslogtreecommitdiff
path: root/app/controllers/characters
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/characters')
-rw-r--r--app/controllers/characters/bestiary_controller.rb12
-rw-r--r--app/controllers/characters/hearth_controller.rb3
-rw-r--r--app/controllers/characters/item_infixes_controller.rb27
-rw-r--r--app/controllers/characters/items_controller.rb12
-rw-r--r--app/controllers/characters/rankings_controller.rb2
-rw-r--r--app/controllers/characters/skills_controller.rb15
-rw-r--r--app/controllers/characters/spells_controller.rb9
7 files changed, 78 insertions, 2 deletions
diff --git a/app/controllers/characters/bestiary_controller.rb b/app/controllers/characters/bestiary_controller.rb
new file mode 100644
index 0000000..7e37d9c
--- /dev/null
+++ b/app/controllers/characters/bestiary_controller.rb
@@ -0,0 +1,12 @@
+class Characters::BestiaryController < ApplicationController
+ before_action :set_character
+
+ def index
+ @monster_kills = @character.monster_kills.all
+ end
+
+ private
+ def set_character
+ @character = Character.find(params[:character_id])
+ end
+end
diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb
index 82f72d6..c525add 100644
--- a/app/controllers/characters/hearth_controller.rb
+++ b/app/controllers/characters/hearth_controller.rb
@@ -7,6 +7,7 @@ class Characters::HearthController < ApplicationController
forge: [],
laboratory: [],
spicebench: [],
+ binding_array: [],
}
Activity.where("gid like ?", "craft_%").each do |activity|
@@ -20,6 +21,8 @@ class Characters::HearthController < ApplicationController
@amenity_activities[:laboratory].push(activity) && next
when "spicebench"
@amenity_activities[:spicebench].push(activity) && next
+ when "binding_array"
+ @amenity_activities[:binding_array].push(activity) && next
else
raise "Invalid amenity gid (#{requirement_data[:gid]}"
end
diff --git a/app/controllers/characters/item_infixes_controller.rb b/app/controllers/characters/item_infixes_controller.rb
new file mode 100644
index 0000000..0b5f1c5
--- /dev/null
+++ b/app/controllers/characters/item_infixes_controller.rb
@@ -0,0 +1,27 @@
+class Characters::ItemInfixesController < ApplicationController
+ def create
+ # TODO: Can this find-by-id happen automagically?
+ @item_infix = current_char.infix(Item.find(params[:item_id]), Skill.find(params[:skill_id]))
+ if @item_infix
+ flash[:notice] = "Infixed #{@item_infix.item.name}."
+ else
+ flash[:alert] = "Failed to infix item."
+ end
+ redirect_to character_skills_path(current_char)
+ end
+
+ def destroy
+ @item_infix = ItemInfix.find(params[:id])
+ if current_char.remove_infix(@item_infix)
+ flash[:notice] = "Removed #{@item_infix.item.name}."
+ else
+ flash[:alert] = "Failed to remove #{@item_infix.item.name}."
+ end
+ redirect_to character_skills_path(current_char)
+ end
+
+ private
+ def item_infix_params
+ params.require(:item_infix).permit(:item_id, :skill_id)
+ end
+end
diff --git a/app/controllers/characters/items_controller.rb b/app/controllers/characters/items_controller.rb
index 470e21c..e38b69a 100644
--- a/app/controllers/characters/items_controller.rb
+++ b/app/controllers/characters/items_controller.rb
@@ -1,6 +1,7 @@
class Characters::ItemsController < ApplicationController
+ before_action :set_character, only: :index
+
def index
- @character = Character.find(params[:character_id])
end
def equip
@@ -66,4 +67,13 @@ class Characters::ItemsController < ApplicationController
redirect_to character_items_path(current_char)
end
end
+
+ private
+ def set_character
+ @character = Character.find(params[:character_id])
+ unless current_char == @character
+ flash[:alert] = "You can only look at your own items."
+ redirect_to character_path(@character)
+ end
+ end
end
diff --git a/app/controllers/characters/rankings_controller.rb b/app/controllers/characters/rankings_controller.rb
index bbae9fc..429b487 100644
--- a/app/controllers/characters/rankings_controller.rb
+++ b/app/controllers/characters/rankings_controller.rb
@@ -6,4 +6,4 @@ class Characters::RankingsController < ApplicationController
def index
@character = Character.find(params[:character_id])
end
-end \ No newline at end of file
+end
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/spells_controller.rb b/app/controllers/characters/spells_controller.rb
new file mode 100644
index 0000000..a0e6913
--- /dev/null
+++ b/app/controllers/characters/spells_controller.rb
@@ -0,0 +1,9 @@
+class Characters::SpellsController < ApplicationController
+ def index
+ @spell_activities = Activity.where("gid like ?", "havencast_%").where(innate: true).order(:name)
+ # TODO: Don't load into memory
+ @spell_activities = @spell_activities.to_a + current_char.learned_activities
+ .map { |la| la.activity }
+ .select { |a| a.gid.start_with?("havencast_") }
+ end
+end