diff --git a/src/lib/data.rb b/src/lib/data.rb index 2f56c2f..53d2dea 100644 --- a/src/lib/data.rb +++ b/src/lib/data.rb @@ -63,5 +63,6 @@ module Charred def json_get(filename) JSON.parse(File.read(filename)) + end end end diff --git a/src/lib/data/custom.rb b/src/lib/data/custom.rb index 4c74fa5..0a2062b 100644 --- a/src/lib/data/custom.rb +++ b/src/lib/data/custom.rb @@ -3,29 +3,46 @@ require 'json' module Charred module Custom def load_custom(data) - Dir.glob("data/custom/*/") { |dir| - stock_name = File.basename(dir) - - if File.readable?("dir/skills.json") - skills = json_get("dir/skills.json") - verbose_merge data[:skills], skills + Dir.glob("data/custom/**/*") { |file| + if File.file?(file) + case File.extname(file) + when "skills" + verbose_merge data[:skills], json_get(file) + when "traits" + verbose_merge data[:traits], json_get(file) + when "stock" + stock = Stock.new(json_get(file)) + data[:stocks][stock.key] = stock # This overwrites existing data... + when "lifepaths" + # + when "resources" + # + end end + } + # Dir.glob("data/custom/*/") { |dir| + # stock_name = File.basename(dir) - if File.readable?("dir/traits.json") - traits = json_get("dir/traits.json") - verbose_merge data[:traits], traits - end + # if File.readable?("dir/skills.json") + # skills = json_get("dir/skills.json") + # verbose_merge data[:skills], skills + # end - if File.readable?("dir/lifepaths.json") - lifepaths = json_get("dir/lifepaths.json") - data[:lifepaths][stock_name] = lifepaths - end + # if File.readable?("dir/traits.json") + # traits = json_get("dir/traits.json") + # verbose_merge data[:traits], traits + # end - if File.readable?("dir/resources.json") - resources = json_get("dir/resources.json") - data[:resources][stock_name] = resources - end - } + # if File.readable?("dir/lifepaths.json") + # lifepaths = json_get("dir/lifepaths.json") + # data[:lifepaths][stock_name] = lifepaths + # end + + # if File.readable?("dir/resources.json") + # resources = json_get("dir/resources.json") + # data[:resources][stock_name] = resources + # end + # } end end end