diff options
author | David Gay <david@davidgay.org> | 2021-05-25 22:02:33 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-25 22:02:33 -0400 |
commit | c4ba54f606c0c4cc5eaa78e108f6529187de3d78 (patch) | |
tree | 775adc8b06a7f04fd5cc2df58e83c985cb6dcbb2 /app/controllers/characters | |
parent | 4d68d3dc80138e6cc6a3cbec001dbd77e85649cc (diff) |
Improve hearth crafting selection
Diffstat (limited to 'app/controllers/characters')
-rw-r--r-- | app/controllers/characters/hearth_controller.rb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/app/controllers/characters/hearth_controller.rb b/app/controllers/characters/hearth_controller.rb index abe8232..02b8446 100644 --- a/app/controllers/characters/hearth_controller.rb +++ b/app/controllers/characters/hearth_controller.rb @@ -2,6 +2,25 @@ class Characters::HearthController < ApplicationController def index @all_amenities = HearthAmenity.all @construct_activities = Activity.where("gid like ?", "construct_%") - @forge_activities = Activity.where("gid like ?", "craft_%") + + @amenity_activities = { + forge: [], + labratory: [], + } + + Activity.where("gid like ?", "craft_%").each do |activity| + activity.whatnot[:requirements]&.each do |requirement_data| + if requirement_data[:type] == "hearth_amenity" + case requirement_data[:gid] + when "forge" + @amenity_activities[:forge].push(activity) && next + when "labratory" + @amenity_activities[:labratory].push(activity) && next + else + raise "Invalid amenity gid (#{requirement_data[:gid]}" + end + end + end + end end end |